/* =============================================================================
   FilmDB - design system
   Palette: deep blue / light blue / white / sand. All text pairs meet WCAG AA
   (4.5:1 for body text); verified by tools/check-contrast.py.
   Font: Manrope, self-hosted (see public/assets/fonts/README.txt), with a
   system fallback if the woff2 file is not present.
   ============================================================================= */

@font-face {
    font-family: "Manrope";
    src: url("../fonts/manrope-variable.woff2") format("woff2");
    font-weight: 200 800;
    font-style: normal;
    font-display: swap;
}

:root {
    /* Blues */
    --c-blue-900: #0b2a4a;   /* navigation, headings on light */
    --c-blue-700: #0f3d6e;   /* primary buttons */
    --c-blue-600: #124a85;   /* primary hover */
    --c-blue-500: #1a5f9e;   /* links, accents (6.6:1 on white) */
    --c-blue-300: #8db8e0;   /* decorative accents, focus halo */
    --c-blue-100: #e3eef8;   /* tinted surfaces, chips */

    /* Sand */
    --c-sand-50:  #faf7f1;   /* page background (lightest) */
    --c-sand-100: #f4eee3;   /* page background */
    --c-sand-200: #e8dec9;   /* borders, secondary surfaces */
    --c-sand-300: #d8c9a9;   /* strong borders */
    --c-sand-700: #6b5b3e;   /* text on sand (5.7:1) */

    /* Neutrals and states */
    --c-white:    #ffffff;
    --c-ink:      #14202e;   /* body text */
    --c-muted:    #51606f;   /* secondary text (6.4:1 on white) */
    --c-danger:   #a32a2a;
    --c-danger-bg: #fbeaea;
    --c-success:  #1e6b45;
    --c-success-bg: #e6f4ec;
    --c-warn-bg:  #fff4d6;

    /* Semantic tokens */
    --bg:           var(--c-sand-100);
    --surface:      var(--c-white);
    --text:         var(--c-ink);
    --text-muted:   var(--c-muted);
    --link:         var(--c-blue-500);
    --border:       var(--c-sand-200);
    --primary:      var(--c-blue-700);
    --primary-hover: var(--c-blue-600);
    --nav-bg:       var(--c-blue-900);
    --focus:        var(--c-blue-500);

    --radius:   10px;
    --radius-s: 6px;
    --shadow:   0 1px 2px rgb(11 42 74 / 6%), 0 4px 14px rgb(11 42 74 / 6%);
    --space:    1rem;

    --font: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

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

body {
    margin: 0;
    font-family: var(--font);
    font-size: 1rem;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1, h2, h3 { color: var(--c-blue-900); line-height: 1.2; margin: 0 0 .5rem; letter-spacing: -0.01em; }
h1 { font-size: 1.75rem; font-weight: 800; }
h2 { font-size: 1.15rem; font-weight: 700; }
p  { margin: 0 0 var(--space); }

a { color: var(--link); text-underline-offset: 2px; }
a:hover { color: var(--c-blue-900); }

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

.muted { color: var(--text-muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.visually-hidden {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
    position: absolute; left: .5rem; top: -4rem; z-index: 100;
    background: var(--c-white); color: var(--c-blue-900);
    padding: .5rem .9rem; border-radius: var(--radius-s); box-shadow: var(--shadow);
}
.skip-link:focus { top: .5rem; }

/* ---- Top bar --------------------------------------------------------------- */
.topbar { background: var(--nav-bg); color: var(--c-white); }
.topbar__inner {
    max-width: 1180px; margin: 0 auto; padding: .6rem 1.25rem;
    display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: .65rem; color: var(--c-white); text-decoration: none; font-weight: 800; font-size: 1.15rem; }
.brand:hover { color: var(--c-white); }
.brand__logo { height: 32px; width: auto; max-width: 120px; object-fit: contain; border-radius: 4px; }

.nav { flex: 1 1 auto; min-width: 0; }
.nav__list { list-style: none; margin: 0; padding: 0; display: flex; gap: .25rem; flex-wrap: wrap; }
.nav__link {
    display: inline-block; padding: .45rem .8rem; border-radius: var(--radius-s);
    color: #dce9f6; text-decoration: none; font-weight: 600; font-size: .95rem;
}
a.nav__link:hover { background: rgb(255 255 255 / 10%); color: var(--c-white); }
.nav__link.is-active { background: var(--c-white); color: var(--c-blue-900); }
.nav__link.is-disabled { color: #9db5cf; cursor: not-allowed; }
.topbar :focus-visible { outline-color: var(--c-white); }

.topbar__tools { display: flex; align-items: center; gap: .75rem; margin-left: auto; }
.topbar__tools form { margin: 0; }

/* ---- Page ------------------------------------------------------------------- */
.page { flex: 1 0 auto; width: 100%; max-width: 1180px; margin: 0 auto; padding: 2rem 1.25rem 3rem; }
.page-head { margin-bottom: 1.5rem; }
.page-head p { margin-bottom: 0; }

.footer { text-align: center; padding: 1.25rem; color: var(--c-sand-700); font-size: .85rem; }

/* ---- Cards, stats ------------------------------------------------------------ */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.card--flush { padding: 0; overflow: hidden; }
.card__meta { padding: .9rem 1.25rem; margin: 0; color: var(--text-muted); font-size: .9rem; border-bottom: 1px solid var(--border); background: var(--c-sand-50); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--c-blue-500); border-radius: var(--radius); padding: 1.1rem 1.25rem; box-shadow: var(--shadow); }
.stat__value { font-size: 2rem; font-weight: 800; color: var(--c-blue-900); line-height: 1.1; margin: 0; }
.stat__label { margin: .25rem 0 0; color: var(--text-muted); font-weight: 600; }

/* ---- Tables ------------------------------------------------------------------ */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .8rem 1.25rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--c-sand-700); background: var(--c-sand-50); white-space: nowrap; }
.table th:last-child.num, .table td.num { text-align: right; }
.table tbody tr:last-child td { border-bottom: 0; }
.table--hover tbody tr:hover { background: var(--c-blue-100); }
.sort-link { color: inherit; text-decoration: none; }
.sort-link:hover { color: var(--c-blue-900); text-decoration: underline; }
.empty { padding: 2rem 1.25rem; margin: 0; color: var(--text-muted); text-align: center; }

.chip, .badge {
    display: inline-block; padding: .15rem .6rem; border-radius: 999px;
    font-size: .8rem; font-weight: 700; background: var(--c-blue-100); color: var(--c-blue-900);
}
.badge--now  { background: var(--c-success-bg); color: var(--c-success); }
.badge--soon { background: var(--c-blue-100); color: var(--c-blue-900); }

/* ---- Forms and buttons --------------------------------------------------------- */
.form { display: flex; flex-direction: column; gap: 1rem; }
.form--narrow { max-width: 460px; }
.field { display: flex; flex-direction: column; gap: .35rem; }
.field--grow { flex: 1 1 240px; }
.field label { font-weight: 700; font-size: .9rem; color: var(--c-blue-900); }

input[type="text"], input[type="search"], input[type="password"], input[type="email"],
input[type="date"], input[type="number"], select, textarea {
    font: inherit; color: var(--text); background: var(--c-white);
    border: 1px solid var(--c-sand-300); border-radius: var(--radius-s);
    padding: .6rem .75rem; width: 100%; min-height: 2.75rem;
}
input:focus, select:focus, textarea:focus { outline: 3px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
.select--compact { min-height: 2.25rem; padding: .3rem .5rem; width: auto; font-size: .9rem; }
.has-error input, .has-error select { border-color: var(--c-danger); }
.field__error { color: var(--c-danger); font-weight: 600; font-size: .875rem; margin: 0; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    font: inherit; font-weight: 700; font-size: .95rem; cursor: pointer; text-decoration: none;
    padding: .6rem 1.1rem; min-height: 2.75rem; border-radius: var(--radius-s);
    border: 1px solid var(--c-sand-300); background: var(--c-white); color: var(--c-blue-900);
}
.btn:hover { background: var(--c-sand-50); color: var(--c-blue-900); }
.btn--primary { background: var(--primary); border-color: var(--primary); color: var(--c-white); }
.btn--primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--c-white); }
.btn--small { min-height: 2.25rem; padding: .3rem .8rem; font-size: .875rem; }
.btn--block { width: 100%; }
.btn--ghost-light { background: transparent; border-color: rgb(255 255 255 / 45%); color: var(--c-white); min-height: 2.25rem; padding: .3rem .9rem; }
.btn--ghost-light:hover { background: rgb(255 255 255 / 12%); color: var(--c-white); }
.btn.is-disabled { opacity: .55; cursor: not-allowed; }

.toolbar { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 1.25rem; }
.toolbar .field:not(.field--grow) { min-width: 200px; }
.toolbar__actions { display: flex; gap: .5rem; }

.pager { display: flex; align-items: center; justify-content: center; gap: 1rem; margin: 1rem 0 0; }
.pager__info { color: var(--text-muted); font-size: .9rem; }

.alert { padding: .8rem 1rem; border-radius: var(--radius-s); margin-bottom: 1rem; border: 1px solid; font-weight: 600; }
.alert--error   { background: var(--c-danger-bg); border-color: #e6b3b3; color: var(--c-danger); }
.alert--success { background: var(--c-success-bg); border-color: #b4dcc7; color: var(--c-success); }
.alert--info    { background: var(--c-blue-100); border-color: var(--c-blue-300); color: var(--c-blue-900); }

.code, textarea.code, pre.code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem;
    background: var(--c-sand-50); word-break: break-all; white-space: pre-wrap;
}

.error-card { text-align: center; max-width: 520px; margin: 3rem auto; }
.error-card__code { font-size: 3.5rem; font-weight: 800; color: var(--c-blue-500); margin: 0; line-height: 1; }

/* ---- Login ------------------------------------------------------------------------ */
.auth-body { align-items: center; justify-content: center; padding: 1.5rem; background: linear-gradient(180deg, var(--c-sand-100), var(--c-sand-200)); }
.auth-card {
    width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border);
    border-radius: 16px; box-shadow: var(--shadow); padding: 2rem 2rem 1.5rem;
}
.auth-card__brand { text-align: center; margin-bottom: 1.25rem; }
.auth-card__logo { height: 64px; width: auto; max-width: 180px; object-fit: contain; }
.auth-card__name { font-weight: 800; font-size: 1.3rem; color: var(--c-blue-900); margin: .4rem 0 0; }
.auth-card__tagline { color: var(--text-muted); margin: 0; font-size: .9rem; }
.auth-card__title { font-size: 1.25rem; margin-bottom: 0; }
.auth-card__lang { margin-top: 1.25rem; text-align: center; }

/* ---- Responsive ---------------------------------------------------------------------- */
@media (max-width: 720px) {
    .topbar__inner { gap: .75rem; }
    .nav { order: 3; flex-basis: 100%; overflow-x: auto; }
    .nav__list { flex-wrap: nowrap; }
    .nav__link { white-space: nowrap; }
    .page { padding: 1.25rem .9rem 2rem; }
    .table th, .table td { padding: .65rem .8rem; }
    h1 { font-size: 1.45rem; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---- Print (reports reuse this in stage 4) ------------------------------------------------ */
@media print {
    body { background: #fff; color: #000; }
    .topbar, .footer, .toolbar, .pager, .skip-link, .no-print { display: none !important; }
    .page { max-width: none; padding: 0; }
    .card, .stat { box-shadow: none; border-color: #999; }
    a { color: inherit; text-decoration: none; }
}
