/**
 * trendTopics - bază comună (refactor pilot v3)
 * Fonturi, tokenuri vizuale, navigarea (sidebar, topbar, bara mobilă),
 * butoane și panoul de căutare. Încărcat pe toate paginile.
 */

/* ===== Fonturi locale (OFL, vezi assets/fonts/*-OFL.txt) ===== */
@font-face { font-family: 'DM Sans'; font-style: normal; font-weight: 400; font-display: swap; src: url(../fonts/dmsans-400.woff2) format('woff2'); }
@font-face { font-family: 'DM Sans'; font-style: normal; font-weight: 500; font-display: swap; src: url(../fonts/dmsans-500.woff2) format('woff2'); }
@font-face { font-family: 'DM Sans'; font-style: normal; font-weight: 600; font-display: swap; src: url(../fonts/dmsans-600.woff2) format('woff2'); }
@font-face { font-family: 'DM Sans'; font-style: normal; font-weight: 700; font-display: swap; src: url(../fonts/dmsans-700.woff2) format('woff2'); }
@font-face { font-family: 'Newsreader'; font-style: normal; font-weight: 500; font-display: swap; src: url(../fonts/newsreader-500.woff2) format('woff2'); }
@font-face { font-family: 'Newsreader'; font-style: normal; font-weight: 600; font-display: swap; src: url(../fonts/newsreader-600.woff2) format('woff2'); }
@font-face { font-family: 'Quicksand'; font-style: normal; font-weight: 700; font-display: swap; src: url(../fonts/quicksand-700.woff2) format('woff2'); }

/* ===== Tokenuri (aceleași în feed, dialoguri și imaginea PNG) ===== */
:root {
    --tt-bg: #0c0d0f;
    --tt-surface: #141518;
    --tt-surface-2: #151619;
    --tt-surface-3: #1b1e25;
    --tt-line: #303640;
    --tt-line-soft: #22242a;
    --tt-card-bg: #141518;
    --tt-card-border: #34373f;
    --tt-card-text: #f0f0f3;
    --tt-text: #f3f1ef;
    --tt-muted: #9aa5b7;
    --tt-red: #fa4d58;
    --tt-red-hover: #ff717a;
    --tt-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    --tt-serif: 'Newsreader', Georgia, serif;
    --tt-brand-font: 'Quicksand', var(--tt-sans);
    --tt-sidebar: 212px;
    --tt-header: 72px;
    --tt-mobile-nav: 65px;
    --tt-visual-height: 100dvh;
    --tt-visual-top: 0px;
    /* Distanța panourilor de jos față de marginea de sus: sub notch / bara de stare */
    --tt-sheet-top: calc(env(safe-area-inset-top, 0px) + 12px);
    color-scheme: dark;
}

/* Tokenurile semantice existente urmează paleta pilotului (profil, notificări, autentificare) */
[data-theme="dark"] {
    --bg-primary: #0c0d0f;
    --bg-secondary: #141518;
    --bg-tertiary: #1d2027;
    --text-primary: #f3f1ef;
    --text-secondary: #a8b1c1;
    --text-muted: #9aa5b7;
    --accent: #fa4d58;
    --accent-hover: #ff717a;
    --card-bg: #141518;
    --card-border: #34373f;
    --border-color: #303640;
    --input-bg: #0e141f;
    --input-border: #455570;
    --input-focus-bg: #0e141f;
    --input-placeholder: #8494af;
    --accent-hover-bg: rgba(250, 77, 88, 0.12);
    --bg-unread: rgba(250, 77, 88, 0.08);
    --bg-unread-hover: rgba(250, 77, 88, 0.12);
    --skeleton-base: #1d2027;
    --skeleton-shine: #2a2e37;
}

html, body {
    background: var(--tt-bg);
}

body {
    font-family: var(--tt-sans);
    color: var(--tt-text);
    -webkit-font-smoothing: antialiased;
}

button, input, textarea, select {
    font-family: inherit;
}

.tt-ico {
    display: block;
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

.tt-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.tt-skip {
    position: fixed;
    top: -80px;
    left: 20px;
    z-index: 2000;
    background: var(--tt-red);
    color: #111216;
    padding: 12px;
    border-radius: 6px;
    font-weight: 600;
}
.tt-skip:focus { top: 10px; }

.tt-app :is(button, a, input, textarea):focus-visible,
.tt-dialog :is(button, a, input, textarea):focus-visible,
.tt-focusable:focus-visible {
    outline: 2px solid var(--tt-red);
    outline-offset: 3px;
}

/* ===== Brand ===== */
.tt-brand {
    font-family: var(--tt-brand-font);
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -1.4px;
    display: inline-flex;
    align-items: center;
    color: #f0f0f3;
    text-decoration: none;
    line-height: 1;
}
.tt-brand span { color: var(--tt-red); }
.tt-brand i {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--tt-red);
    margin: 12px 0 0 3px;
}

/* ===== Sidebar desktop ===== */
.tt-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--tt-sidebar);
    border-right: 1px solid var(--tt-line-soft);
    padding: 35px 23px 25px;
    display: flex;
    flex-direction: column;
    z-index: 900;
    background: var(--tt-bg);
    font-family: var(--tt-sans);
}

.tt-nav {
    margin-top: 55px;
    display: grid;
    gap: 12px;
}

.tt-nav-item {
    height: 48px;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 13px;
    border-radius: 8px;
    color: #a2a7b1;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    position: relative;
    -webkit-tap-highlight-color: transparent;
}
.tt-nav-item:hover { background: #1a1b20; color: #fff; }
.tt-nav-item.active { color: var(--tt-red); background: #fa4d5810; }
.tt-nav-item.active .tt-ico { stroke-width: 1.9; }
.tt-nav-item .tt-ico { width: 22px; height: 22px; }
.tt-nav-dot {
    margin-left: auto;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--tt-red);
    display: none;
}
.tt-nav-item.active .tt-nav-dot { display: block; }
.tt-nav-count {
    margin-left: auto;
    font-size: 10px;
    font-weight: 500;
    color: #afb4bf;
    background: #24272e;
    border-radius: 4px;
    min-width: 20px;
    line-height: 20px;
    text-align: center;
    padding: 0 4px;
}
.tt-nav-count[hidden] { display: none; }
.tt-nav-item kbd {
    margin-left: auto;
    display: grid;
    place-items: center;
    width: 20px;
    height: 20px;
    border: 1px solid #393c45;
    border-radius: 4px;
    color: #9097a5;
    font: inherit;
    font-size: 11px;
}
.tt-nav-icon {
    position: relative;
    display: inline-flex;
}
.tt-nav-badge {
    position: absolute;
    top: -6px;
    right: -9px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--tt-red);
    color: #151619;
    font-size: 9px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
}
.tt-nav-badge[hidden] { display: none; }
.tt-nav-badge.notification-badge {
    top: -6px;
    right: -9px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border: 0;
    box-shadow: none;
    font-size: 9px;
    line-height: 16px;
    color: #151619 !important;
    -webkit-text-fill-color: #151619;
    background: var(--tt-red) !important;
}

.tt-sidebar-bottom {
    margin-top: auto;
    padding: 24px 12px 0;
}
.tt-sidebar-bottom p {
    margin: 0;
    font: 500 24px/1.35 var(--tt-serif);
    letter-spacing: -0.2px;
    color: #c3c4cb;
}
.tt-sidebar-bottom em {
    color: var(--tt-red);
    white-space: nowrap;
}

/* ===== Topbar ===== */
.tt-topbar {
    position: fixed;
    left: var(--tt-sidebar);
    top: 0;
    right: 0;
    height: var(--tt-header);
    padding: 0 42px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 850;
    background: var(--tt-bg);
    font-family: var(--tt-sans);
}
.tt-view-label {
    font-size: 11px;
    color: #9097a5;
    letter-spacing: 0.2px;
}
.tt-topbar .tt-brand { display: none; }
.tt-topbar-back { display: none; }

/* ===== Bara de navigare mobilă ===== */
.tt-mobile-nav { display: none; }

/* ===== Butoane ===== */
.tt-icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid #3a3f49;
    border-radius: 50%;
    color: #bcc4d1;
    background: none;
    flex-shrink: 0;
    cursor: pointer;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}
.tt-icon-button:hover { background: #282d36; border-color: #686f7d; color: #fff; }
.tt-icon-button:disabled { opacity: 0.35; cursor: default; }
.tt-icon-button .tt-ico { width: 18px; height: 18px; }

.tt-red-button {
    background: var(--tt-red);
    color: #111216;
    border: 1px solid var(--tt-red);
    font-weight: 600;
    font-size: 12px;
    border-radius: 9px;
    min-height: 44px;
    padding: 11px 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    text-decoration: none;
    font-family: var(--tt-sans);
}
.tt-red-button:hover { background: var(--tt-red-hover); color: #111; }
.tt-red-button .tt-ico { width: 16px; height: 16px; }

/* ===== Dialoguri (bază) ===== */
.tt-dialog {
    border: 1px solid #424c5d;
    border-radius: 20px;
    background: #151922;
    color: var(--tt-text);
    padding: 0;
    box-shadow: 0 40px 180px #000b;
    width: min(590px, calc(100vw - 40px));
    max-height: calc(100vh - 32px);
    max-height: calc(var(--tt-visual-height) - 32px);
    overflow: hidden;
    font-family: var(--tt-sans);
    margin: auto;
}
.tt-dialog[open] { display: flex; flex-direction: column; }
.tt-dialog::backdrop { background: #040507bf; backdrop-filter: blur(8px); }
.tt-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 23px;
    min-height: 65px;
    flex-shrink: 0;
    border-bottom: 1px solid #272c35;
}
.tt-dialog-header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 500;
    letter-spacing: -0.2px;
}
.tt-dialog-header .tt-icon-button { border: 0; width: 44px; height: 44px; }
.tt-sheet-handle { display: none; }

body.tt-dialog-open { overflow: hidden; }

/* Tranziția globală de temă (shared.css) nu anulează tranzițiile componentelor */
html.transitions-ready .tt-topic-dialog { transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0, 0, 0.2, 1); }
html.transitions-ready .tt-detail-backdrop { transition: opacity 0.2s ease; }
html.transitions-ready .tt-story-image { transition: opacity 0.35s ease; }

/* ===== Taburi comune ===== */
.tt-tabs {
    display: flex;
    gap: 25px;
    padding: 0 27px;
    border-bottom: 1px solid #3b404a;
    flex-shrink: 0;
    min-height: 49px;
}
.tt-tabs > button {
    font-size: 12px;
    color: #a8b1c1;
    padding: 15px 0;
    position: relative;
    background: none;
    border: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}
.tt-tabs > button.selected { color: #fff; }
.tt-tabs > button.selected::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--tt-red);
}

/* ===== Căutare ===== */
.tt-search-dialog {
    height: min(780px, calc(100vh - 40px));
    height: min(780px, calc(var(--tt-visual-height) - 40px));
    width: min(650px, calc(100vw - 40px));
}
.tt-search-field {
    margin: 20px 25px 8px;
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 6px 8px 6px 14px;
    border-radius: 11px;
    background: #0c111a;
    border: 1px solid #46536a;
    flex-shrink: 0;
    color: #a2adbf;
}
.tt-search-field:focus-within { border-color: var(--tt-red); }
.tt-dialog .tt-search-field input:focus-visible { outline: none; }
.tt-search-field input {
    background: none;
    border: 0;
    width: 100%;
    outline: none;
    color: #f5f4f2;
    font-size: 15px;
    min-width: 0;
    padding: 8px 0;
}
.tt-search-field input::placeholder { color: #8494af; }
.tt-search-field input::-webkit-search-cancel-button { display: none; }
.tt-search-clear {
    width: 36px;
    height: 36px;
    border: 0;
    background: none;
    color: #a2adbf;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 50%;
}
.tt-search-clear.visible { display: inline-flex; }
.tt-search-clear .tt-ico { width: 18px; height: 18px; }
.tt-search-dialog .tt-tabs { padding: 0 25px; }
.tt-search-results {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 0 26px 28px;
}
.tt-search-results > p {
    font-size: 11px;
    color: #a2aec2;
    padding: 20px 0 5px;
    margin: 0;
}
.tt-search-result {
    width: 100%;
    display: flex;
    gap: 14px;
    align-items: center;
    text-align: left;
    padding: 14px;
    margin-top: 12px;
    background: #1d2430;
    border: 1px solid #364359;
    border-radius: 11px;
    color: inherit;
    text-decoration: none;
}
.tt-search-result:hover { border-color: #5a6a85; }
.tt-search-thumb {
    width: 58px;
    height: 58px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
    background: radial-gradient(circle at 30% 30%, color-mix(in srgb, var(--tt-dot, #fa737b) 35%, transparent), transparent 70%), #20242c;
}
.tt-search-result span {
    display: block;
    color: var(--tt-red);
    font-size: 9px;
    letter-spacing: 0.8px;
    margin-bottom: 6px;
    text-transform: uppercase;
}
.tt-search-result strong {
    display: block;
    font-size: 12px;
    line-height: 1.65;
    font-weight: 500;
    color: #dbe4f4;
}
.tt-search-result small {
    display: block;
    font-size: 10px;
    font-variant-numeric: tabular-nums;
    color: #8fa5c7;
    margin-top: 7px;
    line-height: 1.5;
}
.tt-search-empty {
    text-align: center;
    padding: 35px 10px;
    color: #a4b0c4;
    font-size: 13px;
    line-height: 1.8;
}
.tt-search-spinner {
    width: 28px;
    height: 28px;
    margin: 0 auto 12px;
    border: 3px solid #303640;
    border-top-color: var(--tt-red);
    border-radius: 50%;
    animation: tt-spin 0.9s linear infinite;
}
@keyframes tt-spin { to { transform: rotate(360deg); } }

/* ===== Conținutul paginilor cu shell ===== */
.tt-shell-page {
    margin-left: var(--tt-sidebar);
    padding-top: var(--tt-header);
}

/* ===== Tablete ===== */
@media (max-width: 1000px) and (min-width: 761px) {
    :root { --tt-sidebar: 86px; }
    .tt-sidebar { padding: 27px 12px 18px; align-items: center; }
    .tt-sidebar > .tt-brand {
        font-size: 0;
        width: 40px;
        height: 40px;
        border-radius: 10px;
        background: #fa4d5812;
        letter-spacing: -2px;
        justify-content: center;
    }
    .tt-sidebar > .tt-brand::after { content: 'tT'; color: var(--tt-red); font-size: 25px; }
    .tt-sidebar > .tt-brand span,
    .tt-sidebar > .tt-brand i,
    .tt-nav-item > span:not(.tt-nav-icon),
    .tt-nav-count,
    .tt-nav-dot,
    .tt-nav-item kbd,
    .tt-sidebar-bottom { display: none !important; }
    .tt-nav { margin-top: 40px; width: 100%; gap: 14px; }
    .tt-nav-item { width: 48px; height: 48px; justify-content: center; padding: 0; margin: auto; }
    .tt-topbar { padding-left: 27px; padding-right: 27px; }
}

@media (min-width: 761px) and (max-height: 780px) {
    :root { --tt-header: 58px; }
    .tt-sidebar { padding-top: 24px; }
    .tt-nav { margin-top: 40px; gap: 7px; }
    .tt-sidebar-bottom p { font-size: 22px; }
}

/* ===== Mobil ===== */
@media (max-width: 760px) {
    :root { --tt-header: 61px; --tt-sidebar: 0px; }
    .tt-sidebar { display: none; }
    .tt-topbar {
        left: 0;
        height: calc(var(--tt-header) + env(safe-area-inset-top, 0px));
        padding: env(safe-area-inset-top, 0px) 20px 0;
        border-bottom: 1px solid #272c35;
    }
    .tt-topbar .tt-brand { display: inline-flex; font-size: 24px; letter-spacing: -1.1px; }
    .tt-topbar .tt-brand i { width: 4px; height: 4px; margin-top: 9px; }
    .tt-view-label { display: none; }
    .tt-topbar-back { display: inline-flex; width: 44px; height: 44px; border: 0; background: #1c2027; margin-right: -6px; }

    .tt-mobile-nav {
        position: fixed;
        z-index: 900;
        left: 0;
        right: 0;
        bottom: 0;
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        height: calc(var(--tt-mobile-nav) + env(safe-area-inset-bottom, 0px));
        padding: 0 7px env(safe-area-inset-bottom, 0px);
        background: #0f1013;
        border-top: 1px solid #303641;
        font-family: var(--tt-sans);
    }
    .tt-mobile-nav > a {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 5px;
        color: #9ba6b9;
        font-size: 9px;
        position: relative;
        padding: 0;
        text-decoration: none;
        -webkit-tap-highlight-color: transparent;
    }
    .tt-mobile-nav .tt-ico { width: 22px; height: 22px; }
    .tt-mobile-nav > a.active { color: var(--tt-red); }
    .tt-mobile-nav > a.active::before {
        content: '';
        position: absolute;
        top: -1px;
        width: 24px;
        height: 2px;
        background: var(--tt-red);
    }
    .tt-mobile-nav .tt-nav-count {
        position: absolute;
        top: 6px;
        left: calc(50% + 7px);
        margin: 0;
        font-size: 7px;
        line-height: 12px;
        min-width: 12px;
        border-radius: 7px;
        background: var(--tt-red);
        color: #151619;
        padding: 0 3px;
    }
    .tt-mobile-nav .tt-nav-badge { top: -5px; right: -10px; }

    .tt-shell-page {
        margin-left: 0;
        padding-top: calc(var(--tt-header) + env(safe-area-inset-top, 0px));
        padding-bottom: calc(var(--tt-mobile-nav) + env(safe-area-inset-bottom, 0px));
    }

    .tt-dialog {
        width: 100%;
        max-width: none;
        max-height: calc(var(--tt-visual-height) - var(--tt-sheet-top));
        margin: auto 0 0;
        border-radius: 20px 20px 0 0;
        border-bottom: 0;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
    .tt-dialog::backdrop { backdrop-filter: blur(6px); }
    .tt-sheet-handle {
        display: block;
        width: 34px;
        height: 3px;
        border-radius: 3px;
        background: #626c7c;
        margin: 9px auto 0;
        flex-shrink: 0;
    }
    .tt-dialog-header { padding: 6px 17px 7px; min-height: 56px; }
    .tt-dialog-header h2 { font-size: 15px; }
    .tt-tabs { padding: 0 23px; }

    .tt-search-dialog {
        height: calc(100vh - 12px - env(safe-area-inset-top, 0px));
        height: calc(var(--tt-visual-height) - var(--tt-sheet-top));
        position: fixed;
        inset: auto 0 0;
        top: calc(var(--tt-visual-top) + var(--tt-sheet-top));
        margin: 0;
    }
    .tt-search-field { margin: 16px 22px 8px; }
    .tt-search-field input { font-size: 16px; }
    .tt-search-results { padding-left: 22px; padding-right: 22px; }
    .tt-search-result { padding: 12px; gap: 11px; }
    .tt-search-thumb { width: 49px; height: 49px; }
}

@media (max-width: 760px) and (max-height: 680px) {
    :root { --tt-header: 52px; --tt-mobile-nav: 61px; }
    .tt-mobile-nav > a { font-size: 8px; }
}

@media (max-width: 370px) {
    .tt-topbar { padding-left: 17px; padding-right: 17px; }
    .tt-topbar .tt-brand { font-size: 23px; }
}

@media (prefers-reduced-motion: reduce) {
    .tt-app *, .tt-app *::before, .tt-app *::after,
    .tt-dialog *, .tt-dialog *::before, .tt-dialog *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ===== Lizibilitate: textele secundare au minimum 11 px ===== */
.tt-view-label { font-size: 12px; }
.tt-search-result span { font-size: 10.5px; }
.tt-search-result strong { font-size: 14px; }
.tt-search-result small { font-size: 12px; }
.tt-search-results > p { font-size: 12px; }
@media (max-width: 760px) {
    .tt-mobile-nav > a { font-size: 11px; }
    .tt-mobile-nav .tt-nav-count { font-size: 9px; min-width: 15px; line-height: 15px; }
}
@media (max-width: 760px) and (max-height: 680px) {
    .tt-mobile-nav > a { font-size: 10.5px; }
}
