/* Miopinion — Threads-inspired feed UI (v1) */

:root {
    --bg: #fafafa;
    --card: #ffffff;
    --text: #0f0f0f;
    --muted: #777777;
    --border: #e6e6e6;
    --line: #d0d0d0;
    --accent: #0f0f0f;
    --accent-soft: #f0f0f0;
    --danger: #e11d48;
    --success: #16a34a;
    --radius: 12px;
    --feed-max: 640px;
    --header-h: 56px;
    --tabbar-h: 64px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }

.feed-shell {
    width: 100%;
    max-width: var(--feed-max);
    margin: 0 auto;
    padding: 0 16px;
}

/* Header */
.site-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: rgba(250, 250, 250, 0.92);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    min-height: var(--header-h);
}

.site-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: var(--header-h);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    text-decoration: none !important;
    color: inherit;
}
.brand__logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
    display: block;
    flex-shrink: 0;
}
.brand__name {
    line-height: 1;
}

.site-nav ul {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.site-nav a { color: var(--muted); font-weight: 600; font-size: 0.9rem; text-decoration: none; }
.site-nav a:hover { color: var(--text); }
.nav-search-form input {
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.4rem 0.85rem;
    background: #fff;
    min-width: 140px;
}

.mobile-menu-toggle {
    display: none;
    border: none;
    background: none;
    font-size: 1.35rem;
    cursor: pointer;
}

.main-feed {
    min-height: 70vh;
    padding-top: 12px;
    padding-bottom: calc(var(--tabbar-h) + 28px);
}

/* Feed */
.feed-header { margin-bottom: 12px; }
.feed-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}
.feed-tab {
    color: var(--muted, #777);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 6px 2px;
    border-bottom: 2px solid transparent;
}
.feed-tab.is-active {
    color: var(--text, #111);
    border-bottom-color: var(--text, #111);
}
.feed-header h2 {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 10px;
}

.trending-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 6px;
    scrollbar-width: none;
}
.trending-chips::-webkit-scrollbar { display: none; }
.trending-chip {
    flex: 0 0 auto;
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 999px;
    padding: 0.35rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none !important;
}
.trending-chip:hover { color: var(--text); border-color: #bbb; }

.feed-list { border-top: 1px solid var(--border); }

.thread-card {
    display: flex;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
    background: transparent;
}

.thread-card--empty,
.card-soft,
.muted-box {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin: 12px 0;
}

.thread-card__rail {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 40px;
    flex-shrink: 0;
}

.thread-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #111;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    flex-shrink: 0;
}

.thread-card__body { flex: 1; min-width: 0; }
.thread-card__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    color: var(--muted);
    margin-bottom: 4px;
}
.thread-card__user { font-weight: 700; color: var(--text); text-decoration: none !important; }
.thread-card__dot { opacity: 0.5; }
.thread-card__title {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin: 0 0 6px;
    line-height: 1.3;
}
.thread-card__title a { text-decoration: none !important; }
.thread-card__title a:hover { text-decoration: underline !important; }
.thread-card__title--lg { font-size: 1.25rem; margin-bottom: 10px; }
.thread-card__preview,
.thread-card__content {
    color: var(--text);
    font-size: 0.95rem;
    margin-bottom: 10px;
    white-space: pre-wrap;
}
.thread-card__preview { color: #333; }

.category-pill {
    margin-left: auto;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.15rem 0.5rem;
    color: var(--muted);
    text-decoration: none !important;
}

.thread-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.thread-stat,
.thread-action-btn {
    font-size: 0.82rem;
    color: var(--muted);
    font-weight: 600;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    text-decoration: none !important;
}
.thread-stat:hover,
.thread-action-btn:hover { color: var(--text); }

.vote-buttons { display: inline-flex; align-items: center; gap: 4px; }
.vote-btn {
    border: none;
    background: transparent;
    padding: 2px;
    margin: 0;
    width: auto;
    height: auto;
    min-width: 0;
    cursor: pointer;
    color: #000;
    line-height: 0;
    border-radius: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.vote-btn:hover,
.vote-btn:focus-visible {
    background: transparent;
    color: #000;
    opacity: 0.4;
    outline: none;
}
.vote-btn:focus-visible {
    outline: 1px solid #000;
    outline-offset: 2px;
    opacity: 1;
}
.vote-icon {
    display: block;
    width: 14px;
    height: 14px;
}
.vote-icon--down {
    transform: rotate(180deg);
}
.vote-score {
    font-weight: 600;
    min-width: 0.9rem;
    text-align: center;
    font-size: 0.8rem;
    color: #000;
}
.vote-score--up,
.vote-score--down {
    color: #000;
}

/* Nested thread tree */
.section-label {
    font-size: 0.95rem;
    font-weight: 800;
    margin: 18px 0 10px;
}
.thread-tree { border-top: 1px solid var(--border); }
.thread-node {
    display: flex;
    gap: 12px;
    padding: 12px 0;
}
.thread-node__rail {
    width: 36px;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
}
.thread-node__line {
    width: 2px;
    flex: 1;
    min-height: 12px;
    background: var(--line);
    margin-top: 6px;
    border-radius: 2px;
}
.thread-node__line--tall { min-height: 40px; }
.thread-node__main { flex: 1; min-width: 0; }
.thread-node__meta {
    display: flex;
    gap: 6px;
    align-items: center;
    font-size: 0.82rem;
    color: var(--muted);
    margin-bottom: 4px;
}
.thread-node__user { font-weight: 700; color: var(--text); text-decoration: none !important; }
.thread-node__body { font-size: 0.95rem; margin-bottom: 8px; }
.thread-children { margin-top: 4px; }
.thread-node--reply { padding-left: 0; }

.thread-reply-form {
    margin-top: 10px;
    padding: 10px;
    background: var(--accent-soft);
    border-radius: 10px;
}
.thread-reply-form[hidden] { display: none !important; }
.thread-reply-form__actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.thread-compose-inline h3 {
    font-size: 0.95rem;
    margin-bottom: 10px;
}

.muted { color: var(--muted); }
.muted-box { text-align: center; }

/* Forms / buttons */
.form-group { margin-bottom: 12px; }
label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 0.85rem; }
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
select,
textarea {
    width: 100%;
    padding: 0.75rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    font: inherit;
    background: #fff;
}
textarea { min-height: 100px; resize: vertical; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #111;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0.55rem 1rem;
    background: #000;
    color: #fff;
    border: 1px solid #000;
    border-radius: 0.375rem;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none !important;
    line-height: 1.25;
}
.btn:hover { background: #212529; border-color: #212529; color: #fff; }
.btn:focus-visible {
    outline: 2px solid #000;
    outline-offset: 2px;
}
.btn-dark { background: #000; color: #fff; border-color: #000; }
.btn-dark:hover { background: #212529; border-color: #212529; color: #fff; }
.btn-light {
    background: #fff;
    color: #000;
    border: 1px solid #000;
}
.btn-light:hover { background: #f8f9fa; color: #000; }
.btn-outline-dark,
.btn-secondary,
.btn-ghost {
    background: transparent;
    color: #000;
    border: 1px solid #000;
}
.btn-outline-dark:hover,
.btn-ghost:hover,
.btn-secondary:hover {
    background: #000;
    color: #fff;
}
.btn-small { padding: 0.4rem 0.75rem; font-size: 0.8rem; }
.btn-block { width: 100%; }

/* Breadcrumbs */
.breadcrumb {
    background: #f8f9fa;
    border-radius: 0.5rem;
    padding: 0.65rem 1rem;
    margin: 0 0 14px;
}
.breadcrumb__list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0;
    margin: 0;
    padding: 0;
}
.breadcrumb__item {
    display: inline-flex;
    align-items: center;
    font-size: 0.9rem;
    font-weight: 600;
    max-width: 100%;
}
.breadcrumb__sep {
    display: inline-flex;
    color: #adb5bd;
    margin: 0 0.45rem;
}
.breadcrumb__link {
    color: #000;
    text-decoration: none !important;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.breadcrumb__link:hover { text-decoration: underline !important; }
.breadcrumb__current {
    color: #6c757d;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: min(52vw, 280px);
}
.breadcrumb__home { display: block; }
.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.message {
    padding: 0.85rem 1rem;
    border-radius: 10px;
    margin-bottom: 12px;
    font-size: 0.9rem;
}
.message.success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.message.error { background: #fff1f2; color: #9f1239; border: 1px solid #fecdd3; }

.share-btn.whatsapp {
    color: #128C7E;
    font-weight: 700;
    text-decoration: none !important;
}

/* Legacy card compatibility */
.card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 14px;
}
.card-header { margin-bottom: 10px; }
.card-title { font-size: 1.1rem; font-weight: 800; }
.card-meta { color: var(--muted); font-size: 0.85rem; }
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.category-badge {
    display: inline-block;
    padding: 0.2rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--muted);
}
.trending-section {
    background: #111;
    color: #fff;
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 14px;
}
.trending-section a { color: #fff; }
.trending-list { list-style: none; }
.trending-item { padding: 0.55rem 0; border-bottom: 1px solid rgba(255,255,255,0.15); }
.trending-item:last-child { border-bottom: none; }

.site-footer {
    border-top: 1px solid var(--border);
    padding: 24px 0 100px;
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
}
.site-footer .tagline { margin-top: 4px; opacity: 0.85; }
.site-footer__links {
    margin-top: 10px;
}
.site-footer__links a {
    color: #000;
    font-weight: 600;
    text-decoration: none;
}
.site-footer__links a:hover { text-decoration: underline; }

/* Qué es MiOpinión */
.info-page__hero {
    text-align: center;
    margin-bottom: 18px;
}
.info-page__logo {
    width: 72px;
    height: 72px;
    object-fit: contain;
    margin-bottom: 10px;
}
.info-page__title {
    font-size: 1.45rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin-bottom: 8px;
}
.info-page__lead {
    color: var(--muted);
    font-size: 0.98rem;
    line-height: 1.5;
    max-width: 36em;
    margin: 0 auto;
}
.info-page__block {
    margin-bottom: 10px;
}
.info-page__h2 {
    font-size: 1.05rem;
    font-weight: 800;
    margin-bottom: 8px;
}
.info-page__block p {
    color: var(--text);
    font-size: 0.95rem;
    line-height: 1.55;
}
.info-page__list {
    margin: 0;
    padding-left: 1.15rem;
    font-size: 0.95rem;
    line-height: 1.55;
}
.info-page__list li + li { margin-top: 6px; }
.info-page__cta {
    text-align: center;
    margin-top: 14px;
    padding: 16px;
}
.info-page__cta p { margin-bottom: 12px; color: var(--muted); }
.info-page__cta .btn { margin: 4px; }

/* Mobile tab bar + compose */
.mobile-tabbar {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: rgba(255,255,255,0.96);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(10px);
    grid-template-columns: repeat(4, 1fr);
    align-items: center;
    justify-items: center;
}

.mobile-tabbar__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none !important;
    padding: 6px;
}
.mobile-tabbar__icon { font-size: 1rem; line-height: 1; }
.mobile-tabbar__compose {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: #111;
    color: #fff;
    font-size: 1.6rem;
    font-weight: 400;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none !important;
    margin-top: -18px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.25);
    cursor: pointer;
}

.compose-sheet[hidden] { display: none !important; }
.compose-sheet {
    position: fixed;
    inset: 0;
    z-index: 80;
}
.compose-sheet__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.45);
}
.compose-sheet__panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: min(92vh, 720px);
    background: #fff;
    border-radius: 18px 18px 0 0;
    padding: 12px 16px calc(16px + env(safe-area-inset-bottom, 0px));
    overflow: auto;
    animation: sheetUp 0.22s ease-out;
}
@keyframes sheetUp {
    from { transform: translateY(24px); opacity: 0.6; }
    to { transform: translateY(0); opacity: 1; }
}
.compose-sheet__head {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    margin-bottom: 12px;
}
.compose-sheet__head strong { text-align: center; }
.compose-sheet__author {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    font-weight: 700;
}
.compose-sheet__form > * + * { margin-top: 10px; }

body.compose-open { overflow: hidden; }

@media (max-width: 768px) {
    .mobile-menu-toggle { display: none; }
    .site-nav { display: none; }
    .site-header { position: sticky; }
    .site-header__inner { position: relative; }
    .mobile-tabbar { display: grid; }
}

@media (min-width: 769px) {
    .mobile-tabbar { display: none; }
    .main-feed { padding-bottom: 40px; }
    .site-footer { padding-bottom: 40px; }
}
