/* ==========================================================================
   Maakora TV — public website
   --------------------------------------------------------------------------
   Hand-written CSS. No framework, no build step (spec §3).
   The reasoning behind every choice here is in docs/DESIGN.md.

   Palette comes from kente and adinkra dyeing rather than the national flag.
   Dark is the default because this is a television site, watched in the
   evening on a bright phone in a dim room.
   ========================================================================== */

/* -- type ---------------------------------------------------------------- */

@font-face {
    font-family: 'Bricolage Grotesque';
    src: url('/assets/fonts/bricolage-latin.woff2') format('woff2');
    font-weight: 400 800;
    font-stretch: 75% 100%;
    font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
                   U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191,
                   U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'Literata';
    src: url('/assets/fonts/literata-latin.woff2') format('woff2');
    font-weight: 400 700;
    font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
                   U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191,
                   U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* -- tokens -------------------------------------------------------------- */

:root {
    --display: 'Bricolage Grotesque', ui-sans-serif, system-ui, sans-serif;
    --body: 'Literata', Georgia, 'Times New Roman', serif;

    --t-xs:   0.78rem;
    --t-sm:   0.88rem;
    --t-base: 1.0625rem;
    --t-md:   1.33rem;
    --t-lg:   1.75rem;
    --t-xl:   2.6rem;
    --t-2xl:  3.8rem;

    --sika:    #e3a62c;
    --leaf:    #2f8f5b;
    --oxblood: #a33528;

    /* Genre colours now live in band.css. */

    --radius-row:    3px;
    --radius-well:   10px;
    --radius-tile:   6px;
    --radius-pill:   999px;

    --gut: clamp(1rem, 4vw, 2.5rem);
    --measure: 68ch;
}

/* Dark is the default. */
:root {
    --ground:      #0a1416;
    --ground-lift: #0f1e21;
    --ground-sunk: #06100f;
    --line:        #1b3338;
    --text:        #f2eee6;
    --text-dim:    #9fb0ac;
    --accent:      var(--sika);
    --accent-text: #0a1416;
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme='dark']) {
        --ground:      #fafaf7;
        --ground-lift: #ffffff;
        --ground-sunk: #eeefe9;
        --line:        #dfe1da;
        --text:        #101a1c;
        --text-dim:    #566266;
        /* Gold on paper needs darkening to stay legible. */
        --accent:      #8a5f00;
        --accent-text: #ffffff;
    }
}

:root[data-theme='light'] {
    --ground:      #fafaf7;
    --ground-lift: #ffffff;
    --ground-sunk: #eeefe9;
    --line:        #dfe1da;
    --text:        #101a1c;
    --text-dim:    #566266;
    --accent:      #8a5f00;
    --accent-text: #ffffff;
}

/* -- reset --------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--ground);
    color: var(--text);
    font-family: var(--body);
    font-size: var(--t-base);
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

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

h1, h2, h3, h4 {
    font-family: var(--display);
    font-weight: 700;
    line-height: 1.05;
    letter-spacing: -0.02em;
    margin: 0 0 0.5em;
    text-wrap: balance;
}

h1 { font-size: var(--t-xl); }
h2 { font-size: var(--t-lg); }
h3 { font-size: var(--t-md); letter-spacing: -0.01em; }

p { margin: 0 0 1rem; max-width: var(--measure); }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
    outline: 2px solid var(--sika);
    outline-offset: 3px;
    border-radius: 2px;
}

.dim { color: var(--text-dim); }
.nums { font-variant-numeric: tabular-nums; }

.skip {
    position: absolute; left: -9999px; top: 0; z-index: 200;
    background: var(--sika); color: #0a1416;
    padding: 0.7rem 1.2rem; font-family: var(--display); font-weight: 700;
}
.skip:focus { left: 0; }

.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;
}

/* -- the woven rule ------------------------------------------------------
   The selvedge of a kente strip: alternating blocks of gold, leaf and
   oxblood at irregular widths. The only pure ornament in the system; it
   appears at most three times per page and costs no request. */

.weft {
    height: 5px;
    border: 0;
    margin: 0;
    background-image: repeating-linear-gradient(90deg,
        var(--sika)    0px,  var(--sika)    18px,
        var(--oxblood) 18px, var(--oxblood) 30px,
        var(--leaf)    30px, var(--leaf)    41px,
        var(--sika)    41px, var(--sika)    47px,
        var(--oxblood) 47px, var(--oxblood) 64px,
        var(--leaf)    64px, var(--leaf)    72px
    );
}

/* -- shell --------------------------------------------------------------- */

.wrap {
    width: 100%;
    max-width: 1180px;
    margin-inline: auto;
    padding-inline: var(--gut);
}

.masthead {
    background: var(--ground);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 100;
}

.masthead__inner {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: 60px;
}

.logo {
    display: flex; align-items: center; gap: 0.6rem;
    text-decoration: none; color: var(--text);
    font-family: var(--display); font-weight: 800;
    letter-spacing: -0.03em; font-size: 1.1rem;
    flex: 0 0 auto;
}

.logo__mark {
    width: 30px; height: 30px; flex: 0 0 auto;
    display: grid; place-items: center;
    background: var(--sika); color: #0a1416;
    font-size: 1rem; font-weight: 800;
    /* A woven square, slightly notched — reads as a strip end. */
    clip-path: polygon(0 0, 100% 0, 100% 72%, 72% 100%, 0 100%);
}

.nav {
    display: flex; align-items: center; gap: 0.15rem;
    margin-left: auto; flex-wrap: wrap;
}

.nav a {
    font-family: var(--display); font-weight: 600; font-size: var(--t-sm);
    color: var(--text); text-decoration: none;
    padding: 0.45rem 0.6rem; border-radius: var(--radius-row);
}
.nav a:hover { background: var(--ground-lift); }
.nav a[aria-current='page'] { color: var(--accent); }

/* The live pill is always present and always goes straight to the player.
   It is the loudest element in the header on purpose. */
.live-pill {
    display: inline-flex; align-items: center; gap: 0.45rem;
    background: var(--oxblood); color: #fff;
    font-family: var(--display); font-weight: 700; font-size: var(--t-xs);
    letter-spacing: 0.04em;
    padding: 0.38rem 0.8rem; border-radius: var(--radius-pill);
    text-decoration: none; flex: 0 0 auto;
}
.live-pill:hover { filter: brightness(1.12); }
.live-pill--off { background: var(--ground-lift); color: var(--text-dim); border: 1px solid var(--line); }

.dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: currentColor; flex: 0 0 auto;
}
.live-pill:not(.live-pill--off) .dot { background: #fff; animation: pulse 2s ease-in-out infinite; }

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.45; transform: scale(0.82); }
}

.theme-toggle {
    background: transparent; border: 1px solid var(--line);
    color: var(--text-dim); cursor: pointer;
    width: 32px; height: 32px; border-radius: var(--radius-row);
    display: grid; place-items: center; font-size: 0.9rem; padding: 0;
}
.theme-toggle:hover { color: var(--text); border-color: var(--text-dim); }

/* -- hero ---------------------------------------------------------------- */

.hero { padding-block: clamp(1.2rem, 3vw, 2.2rem); }

.hero__grid {
    display: grid;
    gap: clamp(1rem, 3vw, 2rem);
    grid-template-columns: 1fr;
    align-items: start;
}

@media (min-width: 900px) {
    .hero__grid { grid-template-columns: minmax(0, 2.1fr) minmax(260px, 1fr); }
}

/* -- player -------------------------------------------------------------- */

.player {
    background: var(--ground-sunk);
    border: 1px solid var(--line);
    border-radius: var(--radius-well);
    overflow: hidden;
    position: relative;
}

.player__frame {
    position: relative;
    aspect-ratio: 16 / 9;
    background: #000;
}

.player__frame video {
    width: 100%; height: 100%;
    display: block;
    object-fit: contain;
    background: #000;
}

/* Overlay states: offline, error, loading. Each one says what is happening
   and what the visitor can do — never a silent black rectangle. */
.player__state {
    position: absolute; inset: 0;
    display: grid; place-items: center; text-align: center;
    padding: 1.5rem;
    background: linear-gradient(170deg, var(--ground-lift), var(--ground-sunk));
    color: var(--text);
}
.player__state[hidden] { display: none; }
.player__state h2 {
    font-size: var(--t-md); margin-bottom: 0.35rem;
}
.player__state p {
    font-size: var(--t-sm); color: var(--text-dim);
    margin: 0 auto; max-width: 42ch;
}
.player__state .btn { margin-top: 1rem; }

.player__bar {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.6rem 0.85rem;
    border-top: 1px solid var(--line);
    background: var(--ground-lift);
    flex-wrap: wrap;
}

.player__status {
    display: inline-flex; align-items: center; gap: 0.4rem;
    font-family: var(--display); font-weight: 700;
    font-size: var(--t-xs); letter-spacing: 0.04em;
    color: var(--oxblood);
}
.player__status .dot { background: var(--oxblood); animation: pulse 2s ease-in-out infinite; }
.player__status--idle { color: var(--text-dim); }
.player__status--idle .dot { animation: none; background: var(--text-dim); }

.player__title {
    font-family: var(--display); font-weight: 600; font-size: var(--t-sm);
    color: var(--text); margin-right: auto;
}

.player__controls { display: flex; align-items: center; gap: 0.3rem; }

.pbtn {
    background: transparent; border: 1px solid transparent;
    color: var(--text); cursor: pointer;
    width: 34px; height: 30px; border-radius: var(--radius-row);
    display: grid; place-items: center; padding: 0;
    font-size: 0.95rem;
}
.pbtn:hover { background: var(--ground-sunk); border-color: var(--line); }
.pbtn[aria-pressed='true'] { color: var(--accent); }

.quality {
    background: var(--ground-sunk); color: var(--text);
    border: 1px solid var(--line); border-radius: var(--radius-row);
    font-family: var(--display); font-size: var(--t-xs); font-weight: 600;
    padding: 0.25rem 0.4rem;
}

/* -- now / next ---------------------------------------------------------- */

.onair { border-top: 3px solid var(--sika); padding-top: 0.9rem; }

.onair__label {
    font-family: var(--display); font-weight: 700;
    font-size: var(--t-xs); letter-spacing: 0.06em;
    color: var(--accent); margin-bottom: 0.25rem;
}

.onair__title {
    font-family: var(--display); font-weight: 700;
    font-size: var(--t-md); line-height: 1.1; margin: 0 0 0.3rem;
}

.onair__time { font-size: var(--t-sm); color: var(--text-dim); }

.onair__synopsis {
    font-size: var(--t-sm); color: var(--text-dim);
    margin: 0.6rem 0 0; max-width: 46ch;
}

.progress {
    height: 4px; background: var(--ground-lift);
    border-radius: 2px; overflow: hidden; margin: 0.7rem 0 0;
}
.progress__fill { height: 100%; background: var(--sika); }

.onair__next {
    margin-top: 1.1rem; padding-top: 0.9rem;
    border-top: 1px solid var(--line);
}

/* The woven schedule band lives in band.css, shared with the admin
   dashboard so the operator and the viewer see the same component. */

/* -- generic sections ---------------------------------------------------- */

.section { padding-block: clamp(1.4rem, 3.5vw, 2.4rem); }

.section__head {
    display: flex; align-items: baseline; gap: 1rem;
    margin-bottom: 1rem; flex-wrap: wrap;
}
.section__head h2 { margin: 0; }
.section__head a { margin-left: auto; font-family: var(--display); font-size: var(--t-sm); font-weight: 600; }

/* -- listing rows (the schedule page, programme lists) ------------------- */

.rows { list-style: none; margin: 0; padding: 0; }

.row {
    display: grid;
    grid-template-columns: 4.6rem 1fr;
    gap: 0 0.9rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--line);
    align-items: start;
}
.row:last-child { border-bottom: 0; }

.row--now {
    background: linear-gradient(90deg, rgb(227 166 44 / 0.1), transparent 60%);
    border-left: 3px solid var(--sika);
    padding-left: 0.6rem;
    margin-left: -0.6rem;
}

.row__time {
    font-family: var(--display); font-weight: 700; font-size: var(--t-sm);
    font-variant-numeric: tabular-nums; padding-top: 0.15rem;
}
.row__time small { display: block; font-weight: 400; color: var(--text-dim); font-size: 0.72rem; }

.row__title {
    font-family: var(--display); font-weight: 600; font-size: var(--t-md);
    margin: 0 0 0.15rem; line-height: 1.15;
}
.row__title a { color: var(--text); text-decoration: none; }
.row__title a:hover { text-decoration: underline; }

.row__meta {
    font-size: var(--t-xs); color: var(--text-dim);
    display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center;
}

.row__synopsis {
    font-size: var(--t-sm); color: var(--text-dim);
    margin: 0.35rem 0 0; max-width: 62ch;
}

.tag {
    display: inline-block; padding: 0.1rem 0.45rem;
    border: 1px solid var(--line); border-radius: var(--radius-row);
    font-family: var(--display); font-size: 0.72rem; font-weight: 600;
    color: var(--text-dim);
}
.tag--live { border-color: var(--oxblood); color: var(--oxblood); }
.tag--genre { border-color: currentColor; }

/* -- tiles (on-demand artwork needs a frame) ----------------------------- */

.tiles {
    display: grid; gap: clamp(0.7rem, 2vw, 1.2rem);
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    list-style: none; margin: 0; padding: 0;
}

.tile { min-width: 0; }

.tile a { text-decoration: none; color: var(--text); display: block; }

.tile__art {
    aspect-ratio: 16 / 9;
    background: var(--ground-lift);
    border: 1px solid var(--line);
    border-radius: var(--radius-tile);
    overflow: hidden;
    display: grid; place-items: center;
    position: relative;
}
.tile__art img { width: 100%; height: 100%; object-fit: cover; }
.tile__art-empty {
    font-family: var(--display); font-weight: 800; font-size: 1.6rem;
    color: var(--line);
}
.tile a:hover .tile__art { border-color: var(--accent); }

.tile__title {
    font-family: var(--display); font-weight: 600; font-size: var(--t-sm);
    line-height: 1.2; margin: 0.45rem 0 0.1rem;
}
.tile__meta { font-size: var(--t-xs); color: var(--text-dim); }

.tile__duration {
    position: absolute; right: 0.3rem; bottom: 0.3rem;
    background: rgb(6 16 15 / 0.85); color: #f2eee6;
    font-size: 0.68rem; padding: 0.05rem 0.3rem; border-radius: 2px;
    font-variant-numeric: tabular-nums;
}

/* -- category chips ------------------------------------------------------ */

.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; list-style: none; margin: 0; padding: 0; }

.chip {
    display: inline-block; padding: 0.4rem 0.75rem;
    border: 1px solid var(--line); border-radius: var(--radius-row);
    font-family: var(--display); font-weight: 600; font-size: var(--t-sm);
    color: var(--text); text-decoration: none;
    border-left: 3px solid var(--line);
}
.chip:hover { background: var(--ground-lift); }
.chip[aria-current='page'] { border-color: var(--accent); color: var(--accent); }

/* -- buttons and forms -------------------------------------------------- */

.btn {
    display: inline-block; cursor: pointer;
    font-family: var(--display); font-weight: 700; font-size: var(--t-sm);
    padding: 0.6rem 1.1rem; border-radius: var(--radius-row);
    border: 1px solid var(--line); background: var(--ground-lift);
    color: var(--text); text-decoration: none; text-align: center;
}
.btn:hover { border-color: var(--text-dim); }

.btn--primary {
    background: var(--sika); color: #0a1416; border-color: var(--sika);
}
.btn--primary:hover { filter: brightness(1.1); }

.btn--live {
    background: var(--oxblood); color: #fff; border-color: var(--oxblood);
    display: inline-flex; align-items: center; gap: 0.45rem;
}

.form { display: grid; gap: 1rem; max-width: 34rem; }

.field { display: grid; gap: 0.3rem; }
.field > span { font-family: var(--display); font-weight: 600; font-size: var(--t-sm); }
.field input, .field textarea, .field select {
    font: inherit; font-size: var(--t-base);
    padding: 0.6rem 0.7rem;
    background: var(--ground-lift); color: var(--text);
    border: 1px solid var(--line); border-radius: var(--radius-row);
    width: 100%;
}
.field textarea { min-height: 9rem; resize: vertical; }
.field__hint { font-size: var(--t-xs); color: var(--text-dim); }
.field__error { font-size: var(--t-xs); color: var(--oxblood); }
.field input[aria-invalid='true'], .field textarea[aria-invalid='true'] { border-color: var(--oxblood); }

.notice {
    padding: 0.8rem 1rem; border-radius: var(--radius-row);
    border: 1px solid var(--line); border-left-width: 3px;
    font-size: var(--t-sm); margin-bottom: 1.2rem;
    max-width: var(--measure);
}
.notice--ok { border-left-color: var(--leaf); }
.notice--warn { border-left-color: var(--sika); }
.notice--err { border-left-color: var(--oxblood); }

/* -- empty states --------------------------------------------------------
   Spec §18: no mock-ups presented as working features. Where there is no
   data the page says so, and says which phase brings it. */

.empty {
    border: 1px dashed var(--line);
    border-radius: var(--radius-row);
    padding: clamp(1.2rem, 4vw, 2.2rem);
    text-align: left;
    max-width: var(--measure);
}
.empty h3 { font-size: var(--t-md); margin-bottom: 0.3rem; }
.empty p { color: var(--text-dim); font-size: var(--t-sm); margin-bottom: 0; }
.empty__phase {
    display: inline-block; margin-top: 0.8rem;
    font-family: var(--display); font-weight: 600; font-size: var(--t-xs);
    color: var(--accent); border: 1px solid var(--accent);
    padding: 0.15rem 0.5rem; border-radius: var(--radius-row);
}

/* -- prose pages (about, legal) ----------------------------------------- */

.prose { max-width: var(--measure); padding-block: clamp(1.4rem, 4vw, 2.6rem); }
.prose h2 { margin-top: 2rem; }
.prose h3 { margin-top: 1.5rem; }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li { margin-bottom: 0.4rem; }
.prose dl { display: grid; grid-template-columns: max-content 1fr; gap: 0.4rem 1.2rem; }
.prose dt { font-family: var(--display); font-weight: 600; color: var(--text-dim); }
.prose dd { margin: 0; }

/* -- programme detail ---------------------------------------------------- */

.detail__grid {
    display: grid; gap: clamp(1rem, 3vw, 2rem);
    grid-template-columns: 1fr;
    padding-block: clamp(1.2rem, 3vw, 2rem);
}
@media (min-width: 760px) {
    .detail__grid { grid-template-columns: minmax(200px, 300px) minmax(0, 1fr); }
}
.detail__art {
    aspect-ratio: 16 / 9; border-radius: var(--radius-tile);
    border: 1px solid var(--line); background: var(--ground-lift);
    display: grid; place-items: center; overflow: hidden;
}
.detail__art img { width: 100%; height: 100%; object-fit: cover; }

.detail__meta {
    display: flex; flex-wrap: wrap; gap: 0.4rem;
    margin: 0 0 1rem; padding: 0; list-style: none;
}

/* -- search -------------------------------------------------------------- */

.search-form { display: flex; gap: 0.5rem; max-width: 34rem; margin-bottom: 1.5rem; }
.search-form input { flex: 1 1 auto; }

/* -- footer -------------------------------------------------------------- */

.footer {
    border-top: 1px solid var(--line);
    margin-top: clamp(2rem, 6vw, 4rem);
    padding-block: clamp(1.6rem, 4vw, 2.6rem);
    font-size: var(--t-sm);
}

.footer__grid {
    display: grid; gap: 1.6rem;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.footer h3 {
    font-size: var(--t-xs); letter-spacing: 0.05em;
    color: var(--text-dim); margin-bottom: 0.6rem;
    font-weight: 700;
}
.footer ul { list-style: none; margin: 0; padding: 0; }
.footer li { margin-bottom: 0.35rem; }
.footer a { color: var(--text); text-decoration: none; }
.footer a:hover { text-decoration: underline; }

.footer__base {
    margin-top: 1.8rem; padding-top: 1.2rem;
    border-top: 1px solid var(--line);
    display: flex; gap: 1rem; flex-wrap: wrap;
    color: var(--text-dim); font-size: var(--t-xs);
    align-items: center;
}

.social { display: flex; gap: 0.5rem; list-style: none; margin: 0; padding: 0; }
.social a {
    width: 32px; height: 32px; border: 1px solid var(--line);
    border-radius: var(--radius-row); display: grid; place-items: center;
    color: var(--text-dim);
}
.social a:hover { color: var(--accent); border-color: var(--accent); }

/* -- phones -------------------------------------------------------------- */

@media (max-width: 760px) {
    :root { --t-xl: 2rem; --t-2xl: 2.5rem; --t-lg: 1.45rem; }

    .masthead__inner { flex-wrap: wrap; min-height: 52px; padding-block: 0.4rem; }
    .nav { order: 3; width: 100%; margin-left: 0; border-top: 1px solid var(--line); padding-top: 0.3rem; }
    .nav { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
    .nav::-webkit-scrollbar { display: none; }
    .nav a { white-space: nowrap; }

    .band { height: 56px; }
    .row { grid-template-columns: 3.9rem 1fr; }
    .tiles { grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); }
}

@media (max-width: 380px) {
    .tiles { grid-template-columns: 1fr 1fr; }
}

/* -- print --------------------------------------------------------------- */

@media print {
    .masthead, .footer, .player, .weft, .theme-toggle { display: none; }
    body { background: #fff; color: #000; }
    .row { break-inside: avoid; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
    html { scroll-behavior: auto; }
}
