/* ============================================================
   AnimeDekho — Theme core
   "Ink & Ember": manga ink canvas, halftone screentone,
   sakura→ember warm accent, kana eyebrows, speed-line motif.
   Shared across landing (index.html) and catalog (home.html).
   ============================================================ */

/* ---------- Design tokens ---------- */
:root {
    /* Ink canvas */
    --ink:        #0B0A14;
    --ink-2:      #121020;
    --ink-3:      #1A1630;
    --ink-4:      #241E40;
    --line:       rgba(255, 255, 255, 0.08);
    --line-2:     rgba(255, 255, 255, 0.14);

    /* Ink & ember accent */
    --ember:      #FF4D6D;
    --sakura:     #FF8CC6;
    --gold:       #FFC247;
    --iris:       #7C5CFF;  /* used sparingly, for depth only */
    --accent-grad: linear-gradient(100deg, var(--ember) 0%, var(--sakura) 55%, var(--gold) 115%);

    /* Text */
    --text:       #ECEAF5;
    --muted:      #9A93B8;
    --faint:      #6C6690;
    --paper:      #F5F2EA;

    /* Type */
    --font-display: "Bricolage Grotesque", "Zen Kaku Gothic New", system-ui, sans-serif;
    --font-body:    "Zen Kaku Gothic New", system-ui, -apple-system, sans-serif;

    /* Shape & depth */
    --r-sm: 8px;
    --r:    14px;
    --r-lg: 22px;
    --r-xl: 30px;
    --shadow:    0 18px 50px -20px rgba(0, 0, 0, 0.75);
    --shadow-up: 0 30px 80px -24px rgba(255, 77, 109, 0.35);

    /* Layout */
    --maxw: 1240px;
    --gutter: clamp(16px, 4vw, 40px);
    --header-h: 72px;

    /* Signature textures */
    --halftone: radial-gradient(circle, rgba(255, 255, 255, 0.07) 1px, transparent 1.5px);
    --halftone-size: 11px 11px;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

/* Kill the grey flash on tap (iOS/Android) and keep text selection off UI chrome */
* { -webkit-tap-highlight-color: transparent; }

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

body {
    font-family: var(--font-body);
    background: var(--ink);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input { font-family: inherit; }
ul { list-style: none; }

::selection { background: var(--ember); color: #fff; }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: var(--ink); }
::-webkit-scrollbar-thumb { background: var(--ink-4); border-radius: 20px; border: 3px solid var(--ink); }
::-webkit-scrollbar-thumb:hover { background: var(--ember); }

/* ---------- Shared layout helpers ---------- */
.wrap { width: min(100% - (var(--gutter) * 2), var(--maxw)); margin-inline: auto; }

/* Kana / eyebrow label — true to the subject (anime) */
.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--sakura);
}
.eyebrow::before {
    content: "";
    width: 26px; height: 2px;
    background: var(--accent-grad);
    border-radius: 2px;
}
.eyebrow .kana { color: var(--muted); letter-spacing: 0.1em; font-weight: 500; }

/* Section heading */
.sec-head { margin-bottom: clamp(22px, 4vw, 38px); }
.sec-title {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(1.7rem, 4.4vw, 2.8rem);
    line-height: 1.02;
    letter-spacing: -0.02em;
    margin-top: 12px;
}
.sec-title .ink { color: var(--text); }
.sec-title .grad {
    background: var(--accent-grad);
    -webkit-background-clip: text; background-clip: text;
    color: transparent;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 26px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.98rem;
    letter-spacing: 0.01em;
    transition: transform 0.25s cubic-bezier(.2,.8,.2,1), box-shadow 0.25s, background 0.25s, color 0.25s, border-color 0.25s;
    white-space: nowrap;
    will-change: transform;
}
.btn:focus-visible { outline: 3px solid var(--sakura); outline-offset: 3px; }

.btn-primary {
    background: var(--accent-grad);
    color: #1a0612;
    box-shadow: 0 10px 30px -10px rgba(255, 77, 109, 0.6);
}
.btn-primary:hover { transform: translateY(-3px); box-shadow: 0 20px 44px -14px rgba(255, 77, 109, 0.75); }

.btn-ghost {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--line-2);
    color: var(--text);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.09); transform: translateY(-3px); }

.btn-lg { padding: 17px 34px; font-size: 1.05rem; }

/* ---------- Header (shared) ---------- */
.site-header {
    position: fixed;
    inset: 0 0 auto 0;
    height: var(--header-h);
    z-index: 100;
    display: flex;
    align-items: center;
    transition: background 0.3s, backdrop-filter 0.3s, border-color 0.3s;
    border-bottom: 1px solid transparent;
}
.site-header.scrolled {
    background: rgba(11, 10, 20, 0.82);
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    border-bottom-color: var(--line);
}
.header-inner {
    width: min(100% - (var(--gutter) * 2), var(--maxw));
    margin-inline: auto;
    display: flex;
    align-items: center;
    gap: clamp(14px, 3vw, 34px);
    /* Respect the notch / rounded corners on iOS when in landscape */
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* Wordmark */
.brand { display: inline-flex; align-items: center; gap: 11px; flex-shrink: 0; }
.brand .mark { width: 34px; height: 34px; flex-shrink: 0; }
.brand-name {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.42rem;
    letter-spacing: -0.02em;
    line-height: 1;
}
.brand-name .dekho {
    background: var(--accent-grad);
    -webkit-background-clip: text; background-clip: text;
    color: transparent;
}
.brand-name .tv-chip {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 6px 1px;
    border-radius: 7px;
    background: var(--accent-grad);
    color: #1a0612;
    font-size: 0.5em;
    font-weight: 800;
    letter-spacing: 0.1em;
    line-height: 1;
    vertical-align: middle;
    transform: translateY(-3px);
}

.nav { display: flex; align-items: center; gap: 4px; margin-left: 8px; }
.nav a {
    position: relative;
    padding: 9px 15px;
    border-radius: 999px;
    font-size: 0.93rem;
    font-weight: 600;
    color: var(--muted);
    transition: color 0.2s, background 0.2s;
}
.nav a:hover, .nav a.active { color: var(--text); background: rgba(255, 255, 255, 0.06); }

.header-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

/* Header search (compact) */
.h-search {
    display: flex; align-items: center; gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--line-2);
    border-radius: 999px;
    padding: 8px 14px;
    width: clamp(150px, 20vw, 240px);
    transition: border-color 0.2s, background 0.2s;
}
.h-search:focus-within { border-color: var(--sakura); background: rgba(255, 255, 255, 0.08); }
.h-search i { color: var(--faint); font-size: 0.9rem; }
.h-search input { flex: 1; min-width: 0; border: none; background: none; color: var(--text); font-size: 0.9rem; outline: none; }
.h-search input::placeholder { color: var(--faint); }
.h-search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.h-search-clear { flex: 0 0 auto; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; color: var(--faint); font-size: 0.78rem; background: rgba(255,255,255,0.06); transition: color 0.2s, background 0.2s; }
.h-search-clear:hover { color: var(--text); background: rgba(255,255,255,0.12); }

/* Search toggle — only shown on phones, where search expands full-width.
   Needs .icon-btn specificity to beat app.css's .icon-btn { display:grid }. */
.icon-btn.search-toggle { display: none; }

/* Mobile menu toggle */
.menu-toggle { display: none; width: 42px; height: 42px; align-items: center; justify-content: center; border-radius: 12px; border: 1px solid var(--line-2); font-size: 1.15rem; }

/* ---------- Footer (shared) ---------- */
.site-footer {
    position: relative;
    margin-top: 80px;
    border-top: 1px solid var(--line);
    background:
        var(--halftone),
        linear-gradient(180deg, var(--ink-2), var(--ink));
    background-size: var(--halftone-size), cover;
    padding: clamp(44px, 7vw, 72px) 0 calc(32px + env(safe-area-inset-bottom));
}
.footer-grid {
    display: grid;
    grid-template-columns: 1.6fr repeat(3, 1fr);
    gap: clamp(28px, 5vw, 56px);
    margin-bottom: 44px;
}
.footer-about p { color: var(--muted); max-width: 42ch; margin-top: 16px; font-size: 0.94rem; }
.footer-col h4 {
    font-family: var(--font-display);
    font-size: 0.82rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--sakura);
    margin-bottom: 16px;
}
.footer-col a { display: block; color: var(--muted); padding: 5px 0; font-size: 0.94rem; transition: color 0.2s, transform 0.2s; }
.footer-col a:hover { color: var(--text); transform: translateX(4px); }
.footer-bottom {
    display: flex; flex-wrap: wrap; gap: 14px; justify-content: space-between; align-items: center;
    padding-top: 26px; border-top: 1px solid var(--line);
    color: var(--faint); font-size: 0.85rem;
}
.footer-bottom .disclaimer { max-width: 70ch; }

/* ---------- Content page (doc viewer) ---------- */
.page-main { padding-top: calc(var(--header-h) + 42px); padding-bottom: 50px; min-height: 72vh; }
.crumb { display: flex; align-items: center; gap: 8px; color: var(--faint); font-size: 0.85rem; margin-bottom: 18px; }
.crumb a { color: var(--sakura); }
.crumb i { font-size: 0.7rem; }
.doc { max-width: 820px; }
.doc h1 { font-family: var(--font-display); font-weight: 800; font-size: clamp(2rem, 5vw, 3rem); letter-spacing: -0.02em; line-height: 1.04; margin-bottom: 22px; }
.doc-body { color: var(--muted); font-size: 1.02rem; }
.doc-body h2, .doc-body h3 { color: var(--text); font-family: var(--font-display); margin: 28px 0 12px; letter-spacing: -0.01em; }
.doc-body p { margin-bottom: 16px; }
.doc-body a { color: var(--sakura); text-decoration: underline; }
.doc-body ul, .doc-body ol { margin: 0 0 16px 22px; display: grid; gap: 6px; }

/* ---------- Footer page links ---------- */
.footer-links { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 14px; font-size: 0.88rem; }
.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--text); }

/* ---------- Utility ---------- */
[hidden] { display: none !important; }
.visually-hidden {
    position: absolute !important; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.rating-pill {
    display: inline-flex; align-items: center; gap: 5px;
    font-weight: 700; font-size: 0.82rem; color: var(--gold);
}

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* ---------- Responsive header ---------- */
@media (max-width: 900px) {
    .nav { display: none; }
    .menu-toggle { display: inline-flex; }
    .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
    :root { --header-h: 64px; }
    /* Phone search: tap the icon to drop a full-width search bar under the
       header, so it isn't squeezed by the wordmark. */
    .icon-btn.search-toggle { display: inline-flex; }
    .h-search {
        position: fixed; top: var(--header-h); left: 0; right: 0;
        width: auto; margin: 10px var(--gutter); padding: 12px 16px;
        display: none; z-index: 95;
        background: var(--ink-2); border-color: var(--line-2);
        box-shadow: var(--shadow);
    }
    .h-search.open { display: flex; }
    .search-toggle.active { color: var(--text); border-color: var(--ember); background: rgba(255,77,109,0.1); }
    /* 16px font stops iOS Safari auto-zooming when an input is focused. */
    .h-search input, .range-row input { font-size: 16px; }
    .footer-grid { grid-template-columns: 1fr; gap: 28px; }
}
