/* ============================================================
   GuidaTV.app — Design system
   Tokens, type scale, spacing, components.
   ============================================================ */

:root {
    color-scheme: light dark;

    /* ---- Color (warm, opinionated) — light-dark() picks based on color-scheme ---- */
    --bg:             light-dark(#fafaf9, #1c1917);
    --bg-alt:         light-dark(#f4f3ef, #292524);
    --bg-elevated:    light-dark(#ffffff, #292524);
    --text:           light-dark(#1c1917, #fafaf9);
    --text-muted:     light-dark(#57534e, #a8a29e);
    --text-subtle:    light-dark(#a8a29e, #78716c);
    --border:         light-dark(#e7e5e0, #44403c);
    --border-strong:  light-dark(#d6d3cc, #57534e);
    --card-bg:        light-dark(#ffffff, #292524);
    --logo-bg:        light-dark(#cbc8c1, #57534e);
    --logo-border:    light-dark(rgba(0, 0, 0, .08), rgba(255, 255, 255, .08));
    --accent:         light-dark(#ee2d45, #ff4561);             /* AP Agency red */
    --accent-hover:   light-dark(#d51e36, #ff5c75);
    --accent-soft:    light-dark(rgba(238, 45, 69, .08), rgba(255, 69, 97, .15));
    --accent-text:    #ffffff;
    --live:           light-dark(#047857, #10b981);
    --live-soft:      light-dark(rgba(4, 120, 87, .12), rgba(16, 185, 129, .15));
    --warn:           #b45309;
    --shadow-sm:      light-dark(0 1px 2px rgba(28, 25, 23, .04), 0 1px 2px rgba(0, 0, 0, .3));
    --shadow-md:      light-dark(0 4px 12px rgba(28, 25, 23, .06), 0 4px 12px rgba(0, 0, 0, .35));
    --shadow-lg:      light-dark(0 12px 32px rgba(28, 25, 23, .08), 0 12px 32px rgba(0, 0, 0, .45));

    /* ---- Type scale (1.25 modular) ---- */
    --font-sans: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: "SF Mono", ui-monospace, "Menlo", "Monaco", "Cascadia Code", monospace;
    --font-display: "Fraunces", "Manrope", -apple-system, BlinkMacSystemFont, sans-serif;

    --fs-xs: 0.75rem;             /* 12 — caption, lcn */
    --fs-sm: 0.875rem;            /* 14 — meta, body small */
    --fs-base: 1rem;              /* 16 — body */
    --fs-md: 1.125rem;            /* 18 — card title */
    --fs-lg: 1.375rem;            /* 22 — h2 */
    --fs-xl: 1.75rem;             /* 28 — h1 */
    --fs-2xl: 2.5rem;             /* 40 — hero */
    --fs-3xl: 3.5rem;             /* 56 — display */

    /* ---- Spacing (4px base) ---- */
    --s-1: 4px;
    --s-2: 8px;
    --s-3: 12px;
    --s-4: 16px;
    --s-5: 20px;
    --s-6: 24px;
    --s-8: 32px;
    --s-10: 40px;
    --s-12: 48px;
    --s-16: 64px;

    /* ---- Radius ---- */
    --r-sm: 6px;
    --r-md: 10px;
    --r-lg: 14px;
    --r-xl: 20px;
    --r-pill: 999px;

    /* ---- Layout ---- */
    --max-width: 1280px;
    --header-height: 64px;

    /* ---- Motion ---- */
    --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-out-soft: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-in: cubic-bezier(0.4, 0, 1, 1);
    --d-fast: 120ms;
    --d-base: 200ms;
    --d-slow: 320ms;
}

/* Explicit theme override (set via JS toggle, persisted in localStorage) */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"]  { color-scheme: dark; }

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.5;
    text-rendering: optimizeLegibility;
}

/* Fraunces optical-size axis: bigger at larger sizes (display behavior) */
.page-title,
.stasera-hero__title,
.program-detail h1,
.info-page h2 {
    font-variation-settings: "opsz" 80, "SOFT" 50;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }

img { max-width: 100%; height: auto; display: block; }

/* ---- Accessibility: visible focus ring ---- */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--r-sm);
}

/* ============================================================
   LAYOUT — Header, container, main, footer
   ============================================================ */

.site-header {
    background: light-dark(rgba(250, 250, 249, .82), rgba(28, 25, 23, .82));
    border-bottom: 1px solid var(--border);
    padding: var(--s-3) 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: saturate(1.8) blur(16px);
    -webkit-backdrop-filter: saturate(1.8) blur(16px);
}

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--s-4);
}

.site-header__inner {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
        "brand toggle"
        "search search";
    align-items: center;
    gap: var(--s-3) var(--s-4);
}

@media (min-width: 768px) {
    .site-header__inner {
        grid-template-columns: auto 1fr auto;
        grid-template-areas: "brand search toggle";
        gap: var(--s-5);
    }
}

.brand {
    grid-area: brand;
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.4rem;
    letter-spacing: -.025em;
    color: var(--text);
    line-height: 1;
}

.brand:hover { color: var(--text); }

.brand__mark {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    object-fit: contain;
    transition: transform var(--d-base) var(--ease-out);
}

.brand:hover .brand__mark { transform: scale(1.08); }

.brand__name {
    display: inline-flex;
    align-items: baseline;
}

.brand__tld {
    color: var(--accent);
    font-weight: 600;
    font-size: 0.78em;
    letter-spacing: 0;
    margin-left: 1px;
}

/* ---- Search form: centered pill with icon prefix ---- */
.search-form {
    grid-area: search;
    position: relative;
    display: flex;
    width: 100%;
    max-width: 540px;
    margin: 0 auto;
}

.search-form__icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-subtle);
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;
    z-index: 1;
    transition: color var(--d-fast) var(--ease-in-out);
}

.search-form input[type="search"] {
    flex: 1;
    width: 100%;
    height: 42px;
    padding: 0 var(--s-4) 0 44px;
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    background: var(--bg-alt);
    color: var(--text);
    font: inherit;
    font-size: var(--fs-sm);
    transition: background var(--d-fast) var(--ease-in-out),
                border-color var(--d-fast) var(--ease-in-out),
                box-shadow var(--d-fast) var(--ease-in-out);
}

.search-form input[type="search"]::placeholder {
    color: var(--text-subtle);
}

.search-form input[type="search"]:hover {
    border-color: var(--border-strong);
}

.search-form input[type="search"]:focus {
    outline: none;
    background: var(--card-bg);
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft);
}

.search-form:focus-within .search-form__icon {
    color: var(--accent);
}

.search-form input[type="search"]::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
}

/* Submit button hidden visually (form submits on Enter); kept for a11y */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---- Theme toggle ---- */
.theme-toggle {
    grid-area: toggle;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
    transition: background var(--d-fast) var(--ease-in-out),
                border-color var(--d-fast) var(--ease-in-out),
                color var(--d-fast) var(--ease-in-out),
                transform var(--d-fast) var(--ease-in-out);
}

.theme-toggle:hover {
    background: var(--bg-alt);
    border-color: var(--text-muted);
    color: var(--accent);
}

.theme-toggle:active {
    transform: scale(0.94);
}

.theme-toggle__icon {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Default (light theme): show moon (click → go dark) */
.theme-toggle__icon--sun { display: none; }
.theme-toggle__icon--moon { display: block; }

/* Dark theme via OS preference (only when no explicit override) */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-toggle__icon--sun { display: block; }
    :root:not([data-theme="light"]) .theme-toggle__icon--moon { display: none; }
}

/* Explicit overrides */
:root[data-theme="dark"]  .theme-toggle__icon--sun  { display: block; }
:root[data-theme="dark"]  .theme-toggle__icon--moon { display: none; }
:root[data-theme="light"] .theme-toggle__icon--sun  { display: none; }
:root[data-theme="light"] .theme-toggle__icon--moon { display: block; }

.site-main {
    padding: var(--s-6) 0 var(--s-16);
}

.page-title {
    font-size: var(--fs-xl);
    margin: 0 0 var(--s-1);
    font-weight: 700;
    letter-spacing: -.025em;
    line-height: 1.15;
}

.page-subtitle {
    color: var(--text-muted);
    font-size: var(--fs-sm);
    margin: 0 0 var(--s-5);
}

/* ============================================================
   NAVIGATION
   ============================================================ */

.site-nav {
    display: flex;
    gap: var(--s-1);
    padding: var(--s-2) var(--s-4) 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.site-nav::-webkit-scrollbar { display: none; }

.site-nav a {
    padding: var(--s-2) var(--s-3);
    border-radius: var(--r-sm);
    font-size: var(--fs-sm);
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
    transition: background .12s ease, color .12s ease;
}

.site-nav a:hover {
    background: var(--bg-alt);
    color: var(--text);
}

/* ============================================================
   CHIPS — filtri categoria/umore
   ============================================================ */

.chips {
    display: flex;
    gap: var(--s-2);
    margin: 0 calc(var(--s-4) * -1) var(--s-5);
    padding: 0 var(--s-4) var(--s-1);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.chips::-webkit-scrollbar { display: none; }

/* Rosso del brand fisso (NON via light-dark): il chip ha sfondo proprio, quindi
   il contrasto è chip-bg vs testo bianco, indipendente dal tema pagina.
   #d51e36 su #fff = 5.2:1 → WCAG AA anche per testo piccolo. */
.chip {
    --chip-bg: #d51e36;
    --chip-bg-active: #a91429;
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    padding: var(--s-2) var(--s-4);
    background: var(--chip-bg);
    border: 1px solid transparent;
    border-radius: var(--r-pill);
    font-size: var(--fs-sm);
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background .12s ease, box-shadow .12s ease, transform .12s ease;
}

.chip:hover {
    background: var(--chip-bg-active);
    color: #fff;
}

.chip.active {
    background: var(--chip-bg-active);
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .6);
}

/* Icona categoria: SVG come mask, colorata con currentColor (bianco). */
.chip__icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    background-color: currentColor;
    -webkit-mask: var(--cat-icon) center / contain no-repeat;
    mask: var(--cat-icon) center / contain no-repeat;
}

/* ============================================================
   LCN — channel number badge (monospace, tabular)
   ============================================================ */

.lcn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 22px;
    padding: 0 var(--s-1);
    background: var(--text);
    color: var(--bg);
    border-radius: var(--r-sm);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: -.02em;
    flex-shrink: 0;
}

/* ============================================================
   NOW PLAYING GRID — logo-first hierarchy
   ============================================================ */

.now-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--s-3);
}

.np-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
    display: flex;
    flex-direction: column;
}

.np-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-strong);
}

/* Header strip: logo as primary visual */
.np-card__header {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-4);
    border-bottom: 1px solid var(--border);
    background: var(--bg-alt);
}

.np-card__logo {
    width: 44px;
    height: 44px;
    object-fit: contain;
    border-radius: var(--r-sm);
    background: var(--logo-bg);
    box-shadow: inset 0 0 0 1px var(--logo-border);
    padding: 4px;
    flex-shrink: 0;
}

.np-card__logo--fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--text-subtle);
    font-size: var(--fs-md);
}

.np-card__channel-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.np-card__channel-name {
    font-weight: 600;
    font-size: var(--fs-sm);
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.np-card__channel-meta {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    font-size: var(--fs-xs);
    color: var(--text-muted);
}

/* Body: title, desc, secondary cover */
.np-card__body {
    padding: var(--s-4);
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
    flex: 1;
}

.np-card__media-row {
    display: flex;
    align-items: flex-start;
    gap: var(--s-3);
}

.np-card__cover {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: var(--r-md);
    background: var(--bg-alt);
    flex-shrink: 0;
}

.np-card__title-block {
    flex: 1;
    min-width: 0;
}

.np-card__title {
    font-weight: 600;
    font-size: var(--fs-md);
    line-height: 1.25;
    letter-spacing: -.01em;
    margin: 0 0 var(--s-1);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.np-card__title a { color: var(--text); }
.np-card__title a:hover { color: var(--accent); }

.np-card__desc {
    color: var(--text-muted);
    font-size: var(--fs-sm);
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0;
}

.progress {
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
    margin-top: var(--s-1);
}

.progress__bar {
    height: 100%;
    background: var(--live);
    border-radius: 2px;
    transition: width .3s ease;
}

.np-card__meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--s-2);
    font-size: var(--fs-xs);
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    margin-top: var(--s-1);
}

.np-card__time {
    font-family: var(--font-mono);
    letter-spacing: -.02em;
}

/* ============================================================
   BADGES
   ============================================================ */

.badge {
    display: inline-block;
    padding: 2px var(--s-2);
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    font-size: var(--fs-xs);
    font-weight: 500;
    color: var(--text-muted);
}

.badge--live {
    display: inline-flex;
    align-items: center;
    gap: var(--s-1);
    background: var(--live-soft);
    color: var(--live);
    border-color: transparent;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    font-size: 0.68rem;
}

.badge--live::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--live);
    animation: live-pulse 1.8s var(--ease-in-out) infinite;
    will-change: opacity, transform;
}

@keyframes live-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.55; transform: scale(0.92); }
}

/* ============================================================
   /STASERA — editorial cards (logo-as-art hero)
   ============================================================ */

.stasera-hero {
    text-align: center;
    padding: var(--s-8) var(--s-4) var(--s-10);
    margin: 0 calc(var(--s-4) * -1) var(--s-5);
    background: linear-gradient(180deg, var(--bg-alt) 0%, var(--bg) 100%);
    border-bottom: 1px solid var(--border);
}

.stasera-hero__title {
    font-family: var(--font-display);
    font-size: var(--fs-2xl);
    font-weight: 800;
    margin: 0 0 var(--s-2);
    letter-spacing: -.04em;
    line-height: 1.05;
}

.stasera-hero__subtitle {
    color: var(--text-muted);
    font-size: var(--fs-base);
    margin: 0 auto;
    max-width: 480px;
}

@media (min-width: 768px) {
    .stasera-hero { padding: var(--s-12) var(--s-4) var(--s-12); }
    .stasera-hero__title { font-size: var(--fs-3xl); }
    .stasera-hero__subtitle { font-size: var(--fs-md); }
}

/* ============================================================
   PROGRAM LIST + ROW — compact list-item per /stasera e /fascia/*
   ============================================================ */

/* Single column verticale, max-width palinsesto-style. Niente grid 2/3 col:
   /stasera e /fascia sono LISTE da scansionare, non gallery. */
.program-list {
    list-style: none;
    margin: 0 auto var(--s-8);
    padding: 0;
    max-width: 720px;
    display: flex;
    flex-direction: column;
    gap: var(--s-4);   /* gap tra gruppi canale */
}

.program-list > li { list-style: none; }

/* Channel group — contenitore di un canale e dei suoi programmi nella finestra */
.channel-group {
    display: flex;
    flex-direction: column;
    gap: var(--s-1);   /* gap tra row dello stesso canale */
}

/* Header gruppo: identità visiva del canale */
.channel-group__header {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-3) var(--s-2) 0;
    border-top: 1px solid var(--border-strong);
    color: var(--text);
    text-decoration: none;
    transition: color var(--d-fast) var(--ease-in-out);
}

.channel-group:first-child .channel-group__header {
    border-top: none;
    padding-top: 0;
}

.channel-group__header:hover { color: var(--accent); }

.channel-group__logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: var(--r-sm);
    background: var(--logo-bg);
    box-shadow: inset 0 0 0 1px var(--logo-border);
    padding: 3px;
    flex-shrink: 0;
}

.channel-group__logo--fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--text-subtle);
    font-size: var(--fs-sm);
}

.channel-group__name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: var(--fs-md);
    letter-spacing: -.015em;
    line-height: 1.1;
}

.channel-group__lcn {
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--text-muted);
    background: var(--bg-alt);
    padding: 2px var(--s-2);
    border-radius: var(--r-sm);
    font-variant-numeric: tabular-nums;
}

.channel-group__count {
    margin-left: auto;
    font-size: var(--fs-xs);
    color: var(--text-subtle);
    font-variant-numeric: tabular-nums;
}

.program-row {
    display: grid;
    grid-template-columns: 44px 1fr auto;
    gap: var(--s-3);
    align-items: start;
    padding: var(--s-3) var(--s-4);
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    color: var(--text);
    transition: border-color var(--d-fast) var(--ease-in-out),
                background var(--d-fast) var(--ease-in-out),
                transform var(--d-base) var(--ease-in-out);
    min-height: 72px;
}

.program-row:hover {
    border-color: var(--border-strong);
    background: var(--bg-elevated);
    transform: translateY(-1px);
    color: var(--text);
}

.program-row--featured {
    border-color: var(--accent);
    border-left-width: 3px;
    padding-left: calc(var(--s-4) - 2px);
}

.program-row--live {
    background: linear-gradient(90deg, var(--live-soft), transparent 40%);
    border-color: var(--live);
}

.program-row__logo {
    width: 44px;
    height: 44px;
    object-fit: contain;
    border-radius: var(--r-sm);
    background: var(--logo-bg);
    box-shadow: inset 0 0 0 1px var(--logo-border);
    padding: 4px;
    flex-shrink: 0;
}

.program-row__logo--fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--text-subtle);
    font-size: var(--fs-md);
}

.program-row__main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.program-row__pin {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--accent);
    margin-bottom: 2px;
}

.program-row__title {
    font-weight: 600;
    font-size: var(--fs-md);
    line-height: 1.3;
    letter-spacing: -.005em;
    color: var(--text);
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: normal;
    overflow-wrap: anywhere;
}

.program-row__year {
    color: var(--text-subtle);
    font-weight: 500;
}

.program-row__meta {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    font-size: var(--fs-xs);
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    margin-top: 2px;
}

.program-row__channel {
    font-weight: 500;
    color: var(--text);
    flex-shrink: 0;
}

.program-row__sep {
    color: var(--text-subtle);
    flex-shrink: 0;
}

.program-row__cat {
    flex-shrink: 0;
    color: var(--text-muted);
}

.program-row__desc {
    color: var(--text-subtle);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.program-row__also {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: var(--fs-xs);
    color: var(--text-subtle);
    font-style: italic;
    flex-shrink: 0;
}

.program-row__cover {
    display: none;
}

@media (min-width: 1024px) {
    .program-row {
        grid-template-columns: 40px 1fr 48px auto;
    }
    .program-row__cover {
        display: block;
        width: 48px;
        height: 48px;
        object-fit: cover;
        border-radius: var(--r-sm);
        background: var(--bg-alt);
    }
}

.program-row__time {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 1px;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
    min-width: 56px;
}

.program-row__time-start {
    font-family: var(--font-mono);
    font-size: var(--fs-md);
    font-weight: 600;
    color: var(--text);
    letter-spacing: -.02em;
}

.program-row__time-duration {
    font-size: var(--fs-xs);
    color: var(--text-subtle);
}

.program-row .lcn {
    font-size: 0.65rem;
    min-width: 22px;
    height: 18px;
}

.stasera-footer {
    text-align: center;
    margin-top: var(--s-6);
    padding: var(--s-4);
}

.stasera-footer a {
    color: var(--accent);
    font-weight: 600;
}

.stasera-footer a:hover {
    color: var(--accent-hover);
}

/* ============================================================
   CHANNEL SCHEDULE PAGE
   ============================================================ */

.channel-header {
    display: flex;
    align-items: center;
    gap: var(--s-4);
    margin-bottom: var(--s-6);
    padding-bottom: var(--s-4);
    border-bottom: 1px solid var(--border);
}

.channel-header__logo {
    width: 64px;
    height: 64px;
    object-fit: contain;
    border-radius: var(--r-md);
    background: var(--logo-bg);
    box-shadow: inset 0 0 0 1px var(--logo-border);
    padding: 4px;
}

/* Error page (404 + 5xx) */
.error-page {
    max-width: 720px;
    margin: 0 auto;
    padding: var(--s-6) 0;
}

.error-page__hero {
    text-align: center;
    padding: var(--s-8) var(--s-4) var(--s-10);
    margin-bottom: var(--s-8);
}

.error-page__code {
    font-family: var(--font-display);
    font-size: clamp(5rem, 18vw, 9rem);
    font-weight: 800;
    line-height: 1;
    color: var(--accent);
    letter-spacing: -.05em;
    margin-bottom: var(--s-4);
    opacity: 0.85;
}

.error-page__title {
    font-family: var(--font-display);
    font-size: var(--fs-2xl);
    font-weight: 700;
    margin: 0 0 var(--s-3);
    letter-spacing: -.03em;
    line-height: 1.1;
}

.error-page__subtitle {
    color: var(--text-muted);
    font-size: var(--fs-md);
    margin: 0 auto;
    max-width: 480px;
    line-height: 1.5;
}

.error-page__section-title {
    font-family: var(--font-display);
    font-size: var(--fs-md);
    font-weight: 600;
    margin: 0 0 var(--s-4);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .08em;
    font-size: var(--fs-xs);
}

.error-page__suggestions {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
}

.error-page__link {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--s-4) var(--s-5);
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    color: var(--text);
    transition: border-color var(--d-fast) var(--ease-in-out),
                background var(--d-fast) var(--ease-in-out),
                transform var(--d-base) var(--ease-in-out);
}

.error-page__link:hover {
    border-color: var(--accent);
    background: var(--bg-elevated);
    color: var(--text);
    transform: translateY(-1px);
}

.error-page__link strong {
    font-size: var(--fs-base);
    font-weight: 600;
    letter-spacing: -.005em;
}

.error-page__link span {
    font-size: var(--fs-sm);
    color: var(--text-muted);
}

.error-page__request-id {
    margin-top: var(--s-8);
    color: var(--text-subtle);
    font-size: var(--fs-xs);
    text-align: center;
}

/* Breadcrumb (UI mirror del BreadcrumbList JSON-LD) */
.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s-1);
    font-size: var(--fs-xs);
    color: var(--text-muted);
    margin: 0 0 var(--s-4);
    line-height: 1.4;
}

.breadcrumb__link {
    color: var(--text-muted);
    transition: color var(--d-fast) var(--ease-in-out);
}

.breadcrumb__link:hover { color: var(--accent); }

.breadcrumb__current {
    color: var(--text);
    font-weight: 500;
}

.breadcrumb__sep {
    color: var(--text-subtle);
    font-size: 0.9em;
    user-select: none;
}

/* SEO content paragraph above schedule (AI-generated channel description) */
.channel-about {
    margin: 0 0 var(--s-6);
    padding: var(--s-4) var(--s-5);
    background: var(--bg-alt);
    border-left: 3px solid var(--accent);
    border-radius: var(--r-md);
}

.channel-about__heading {
    font-family: var(--font-display);
    font-size: var(--fs-md);
    font-weight: 600;
    margin: 0 0 var(--s-2);
    color: var(--text);
    letter-spacing: -.01em;
}

.channel-about__text {
    margin: 0;
    color: var(--text-muted);
    font-size: var(--fs-sm);
    line-height: 1.65;
}

.schedule-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--s-1);
}

.schedule-item {
    display: grid;
    grid-template-columns: 80px 1fr auto;
    gap: var(--s-4);
    padding: var(--s-3) var(--s-4);
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    align-items: center;
    transition: border-color .12s ease, background .12s ease;
}

.schedule-item:hover {
    border-color: var(--border-strong);
}

.schedule-item--live {
    border-color: var(--live);
    background: linear-gradient(to right, var(--live-soft), transparent 30%);
}

.schedule-item__time {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--text-muted);
    font-size: var(--fs-sm);
    letter-spacing: -.02em;
}

.schedule-item__title { font-weight: 500; }
.schedule-item__title a:hover { color: var(--accent); }

.date-nav {
    display: flex;
    gap: var(--s-2);
    margin-bottom: var(--s-4);
    flex-wrap: wrap;
}

.date-nav a {
    padding: var(--s-2) var(--s-3);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    font-size: var(--fs-sm);
    color: var(--text-muted);
    transition: border-color .12s ease, color .12s ease;
}

.date-nav a:hover {
    border-color: var(--text-muted);
    color: var(--text);
}

.date-nav a.active {
    background: var(--text);
    color: var(--bg);
    border-color: var(--text);
}

/* ============================================================
   SLOT NAV (fasce orarie)
   ============================================================ */

.slot-nav {
    display: flex;
    gap: var(--s-1);
    margin-bottom: var(--s-5);
    flex-wrap: wrap;
    padding-bottom: var(--s-3);
    border-bottom: 1px solid var(--border);
}

.slot-nav a {
    padding: var(--s-2) var(--s-4);
    border-radius: var(--r-md);
    font-size: var(--fs-sm);
    color: var(--text-muted);
    transition: background .12s ease, color .12s ease;
}

.slot-nav a:hover {
    background: var(--bg-alt);
    color: var(--text);
}

.slot-nav a.active {
    background: var(--text);
    color: var(--bg);
}

/* ============================================================
   PROGRAM DETAIL
   ============================================================ */

.program-detail {
    max-width: 800px;
    margin: 0 auto;
}

.program-detail__hero {
    margin: 0 calc(var(--s-4) * -1) var(--s-6);
    background: var(--bg-alt);
    aspect-ratio: 21 / 9;
    background-size: cover;
    background-position: center;
}

@media (min-width: 768px) {
    .program-detail__hero {
        margin: 0 0 var(--s-6);
        border-radius: var(--r-lg);
    }
}

.program-detail h1 {
    font-family: var(--font-display);
    font-size: var(--fs-xl);
    margin: 0 0 var(--s-1);
    letter-spacing: -.025em;
    line-height: 1.15;
}

.program-detail__meta {
    color: var(--text-muted);
    font-size: var(--fs-sm);
    margin: 0 0 var(--s-4);
}

.program-detail__desc {
    line-height: 1.6;
    margin: var(--s-4) 0;
}

.program-detail__channel {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    padding: var(--s-2) var(--s-3);
    background: var(--bg-alt);
    border-radius: var(--r-md);
    margin: var(--s-2) 0;
}

.program-detail__channel img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

/* ============================================================
   SEARCH RESULTS
   ============================================================ */

.search-results {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--s-1);
}

.search-result {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-4);
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    transition: border-color .12s ease;
}

.search-result:hover { border-color: var(--border-strong); }

.search-result img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    background: var(--bg-alt);
    border-radius: var(--r-sm);
}

.empty-state {
    text-align: center;
    padding: var(--s-16) var(--s-4);
    color: var(--text-muted);
}

/* ============================================================
   CHANNEL GRID (/canali)
   ============================================================ */

.channel-filter {
    margin-bottom: var(--s-4);
}

.channel-filter input[type="search"] {
    width: 100%;
    max-width: 480px;
    padding: var(--s-3) var(--s-4);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--bg-elevated);
    color: var(--text);
    font: inherit;
    font-size: var(--fs-base);
}

.channel-filter input[type="search"]:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
    border-color: transparent;
}

.channel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--s-3);
}

/* Broadcaster group (Rai, Mediaset, Sky, ...): header + grid interna */
.channel-broadcaster-group {
    margin-bottom: var(--s-8);
}

.channel-broadcaster-group__header {
    display: flex;
    align-items: baseline;
    gap: var(--s-3);
    margin: 0 0 var(--s-4);
    padding: var(--s-2) 0;
    border-top: 1px solid var(--border-strong);
}

.channel-broadcaster-group:first-child .channel-broadcaster-group__header {
    border-top: none;
    padding-top: 0;
}

.channel-broadcaster-group__name {
    font-family: var(--font-display);
    font-size: var(--fs-lg);
    font-weight: 700;
    margin: 0;
    letter-spacing: -.02em;
    color: var(--text);
}

.channel-broadcaster-group__count {
    font-size: var(--fs-xs);
    color: var(--text-subtle);
    font-variant-numeric: tabular-nums;
    margin-left: auto;
}

.channel-tile {
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
    padding: var(--s-3);
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
    text-align: center;
}

.channel-tile:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
    border-color: var(--border-strong);
    color: var(--text);
}

.channel-tile__logo {
    aspect-ratio: 1 / 1;
    background: var(--logo-bg);
    box-shadow: inset 0 0 0 1px var(--logo-border);
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.channel-tile__logo img {
    max-width: 80%;
    max-height: 80%;
    object-fit: contain;
}

.channel-tile__logo-fallback {
    font-weight: 700;
    color: var(--text-subtle);
    text-transform: uppercase;
    font-size: var(--fs-lg);
}

.channel-tile__info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-1);
    font-size: var(--fs-sm);
    font-weight: 500;
}

.channel-tile__name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================================================
   INFO PAGES (privacy, disclaimer, credits)
   ============================================================ */

.info-page {
    max-width: 720px;
    margin: 0 auto;
    line-height: 1.65;
    color: var(--text);
}

.info-page h2 {
    font-family: var(--font-display);
    font-size: var(--fs-lg);
    font-weight: 700;
    margin: var(--s-8) 0 var(--s-3);
    letter-spacing: -.015em;
}

.info-page p {
    margin: 0 0 var(--s-3);
}

.info-page code {
    background: var(--bg-alt);
    padding: 2px 6px;
    border-radius: var(--r-sm);
    font-size: 0.88em;
    font-family: var(--font-mono);
    border: 1px solid var(--border);
}

.info-list {
    margin: var(--s-2) 0 var(--s-4) 0;
    padding-left: 22px;
}

.info-list li { margin-bottom: var(--s-2); }
.info-list li::marker { color: var(--text-subtle); }

.info-page a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-color: rgba(238, 45, 69, .35);
    text-underline-offset: 2px;
}

.info-page a:hover { text-decoration-color: var(--accent); }

.info-page__related {
    margin-top: var(--s-10);
    padding-top: var(--s-5);
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-muted);
    font-size: var(--fs-sm);
}

.tmdb-attribution {
    padding: var(--s-3) var(--s-4);
    background: var(--bg-alt);
    border-left: 3px solid #01d277;
    border-radius: var(--r-sm);
    font-size: var(--fs-sm);
    margin: 0 0 var(--s-4);
}

/* ============================================================
   ALERT CTA / BUTTONS
   ============================================================ */

.alert-cta {
    margin: var(--s-6) 0;
    padding: var(--s-5);
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    padding: var(--s-3) var(--s-5);
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    background: var(--card-bg);
    color: var(--text);
    font: inherit;
    font-size: var(--fs-sm);
    font-weight: 600;
    cursor: pointer;
    transition: background .12s ease, border-color .12s ease, transform .12s ease;
}

.btn:hover {
    background: var(--bg-alt);
    border-color: var(--text-muted);
}

.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* Authoritative, calmer alert button — black on white instead of Mediaset red */
.btn--alert {
    background: var(--text);
    color: var(--bg);
    border-color: var(--text);
}

.btn--alert:hover {
    background: var(--accent);
    border-color: var(--accent);
    transform: translateY(-1px);
}

.btn--active {
    background: var(--live-soft);
    color: var(--live);
    border-color: transparent;
}

.btn--active:hover {
    background: var(--live);
    color: var(--bg);
    border-color: var(--live);
}

.alert-cta__hint {
    margin: var(--s-2) 0 0;
    color: var(--text-muted);
    font-size: var(--fs-xs);
    line-height: 1.45;
}

/* ============================================================
   SECTION TITLES
   ============================================================ */

.section-title {
    font-family: var(--font-display);
    font-size: var(--fs-md);
    font-weight: 600;
    margin: 0 0 var(--s-3);
    color: var(--text-muted);
    letter-spacing: -.01em;
    text-transform: uppercase;
    font-size: var(--fs-xs);
    letter-spacing: .08em;
}

/* ============================================================
   FOOTER
   ============================================================ */

.site-footer {
    border-top: 1px solid var(--border);
    padding: var(--s-6) 0;
    color: var(--text-muted);
    font-size: var(--fs-sm);
    margin-top: var(--s-12);
}

.site-footer .container {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--s-3);
}

.site-footer a:hover { color: var(--accent); }

/* ============================================================
   ENTER ANIMATIONS — stagger primi 16, gli altri istantanei
   ============================================================ */

@keyframes row-enter {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes card-enter {
    from { opacity: 0; transform: translateY(10px) scale(0.99); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes page-enter {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes hero-enter {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.now-grid > * {
    opacity: 0;
    animation: card-enter var(--d-slow) var(--ease-out) forwards;
}

.program-list > * {
    opacity: 0;
    animation: row-enter var(--d-base) var(--ease-out) forwards;
}

.now-grid > *:nth-child(1)  { animation-delay: 0ms; }
.now-grid > *:nth-child(2)  { animation-delay: 20ms; }
.now-grid > *:nth-child(3)  { animation-delay: 40ms; }
.now-grid > *:nth-child(4)  { animation-delay: 60ms; }
.now-grid > *:nth-child(5)  { animation-delay: 80ms; }
.now-grid > *:nth-child(6)  { animation-delay: 100ms; }
.now-grid > *:nth-child(7)  { animation-delay: 120ms; }
.now-grid > *:nth-child(8)  { animation-delay: 140ms; }
.now-grid > *:nth-child(9)  { animation-delay: 160ms; }
.now-grid > *:nth-child(10) { animation-delay: 180ms; }
.now-grid > *:nth-child(11) { animation-delay: 200ms; }
.now-grid > *:nth-child(12) { animation-delay: 220ms; }
.now-grid > *:nth-child(13) { animation-delay: 240ms; }
.now-grid > *:nth-child(14) { animation-delay: 260ms; }
.now-grid > *:nth-child(15) { animation-delay: 280ms; }
.now-grid > *:nth-child(16) { animation-delay: 300ms; }
.now-grid > *:nth-child(n+17) { animation-duration: 0ms; animation-delay: 0ms; }

/* Channel groups (al posto delle program-row): 12 gruppi animati con cadenza più lenta
   (30ms step), perché ogni gruppo è ~3-5 row → cadenza visiva equivalente */
.program-list > *:nth-child(1)  { animation-delay: 0ms; }
.program-list > *:nth-child(2)  { animation-delay: 30ms; }
.program-list > *:nth-child(3)  { animation-delay: 60ms; }
.program-list > *:nth-child(4)  { animation-delay: 90ms; }
.program-list > *:nth-child(5)  { animation-delay: 120ms; }
.program-list > *:nth-child(6)  { animation-delay: 150ms; }
.program-list > *:nth-child(7)  { animation-delay: 180ms; }
.program-list > *:nth-child(8)  { animation-delay: 210ms; }
.program-list > *:nth-child(9)  { animation-delay: 240ms; }
.program-list > *:nth-child(10) { animation-delay: 270ms; }
.program-list > *:nth-child(11) { animation-delay: 300ms; }
.program-list > *:nth-child(12) { animation-delay: 330ms; }
.program-list > *:nth-child(n+13) { animation-duration: 0ms; animation-delay: 0ms; }

.site-main > .container {
    animation: page-enter var(--d-base) var(--ease-out);
}

.stasera-hero {
    animation: hero-enter 280ms var(--ease-out);
}

.stasera-hero__title {
    animation: hero-enter 320ms var(--ease-out) 60ms backwards;
}

.stasera-hero__subtitle {
    animation: hero-enter 320ms var(--ease-out) 120ms backwards;
}

/* ============================================================
   VIEW TRANSITIONS — progressive enhancement
   ============================================================ */

@view-transition {
    navigation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: var(--d-base);
    animation-timing-function: var(--ease-out);
}

/* ============================================================
   NAV PROGRESS BAR
   ============================================================ */

.nav-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 2px;
    background: var(--accent);
    width: 100%;
    z-index: 9999;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform var(--d-slow) var(--ease-out), opacity var(--d-fast) ease;
    pointer-events: none;
    opacity: 0;
}

.nav-progress.is-loading {
    transform: scaleX(0.7);
    opacity: 1;
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .now-grid > *,
    .program-list > *,
    .site-main > .container,
    .stasera-hero,
    .stasera-hero__title,
    .stasera-hero__subtitle {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
}
