/* =====================================================================================
   [READER] 2DGuild reader — the Webtoons-style face at 2dguild.com/
   -------------------------------------------------------------------------------------
   Deliberately SIMPLE. Big thumbnails, card rails, one clear action per screen.
   This is not the studio and must never grow into it: no dense panels, no
   administrative chrome. Self-contained — shares nothing with app.css.
   Views are swapped client-side by reader.js; see docs/STANDALONE_WEBTOONS_PLAN.md.
   ===================================================================================== */

:root {
    --rd-bg: #ffffff;
    --rd-surface: #ffffff;
    --rd-raise: #f4f6fa;
    --rd-ink: #10131a;
    --rd-muted: #6b7280;
    --rd-line: #e6e9f0;
    --rd-brand: #00d564;          /* webtoon-ish green */
    --rd-brand-ink: #04160c;
    --rd-shadow: 0 10px 30px rgba(16, 19, 26, 0.10);
    --rd-r: 14px;
    --rd-ease: cubic-bezier(.22,1,.36,1);
    --rd-head: 62px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --rd-bg: #0d1016;
        --rd-surface: #141922;
        --rd-raise: #1b212c;
        --rd-ink: #eef1f6;
        --rd-muted: #98a2b3;
        --rd-line: #252c39;
        --rd-shadow: 0 14px 40px rgba(0, 0, 0, .45);
    }
}

* { box-sizing: border-box; }

body.rd {
    margin: 0;
    background: var(--rd-bg);
    color: var(--rd-ink);
    font: 400 16px/1.55 "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
}

.rd-wrap { width: min(1180px, 100% - 32px); margin-inline: auto; }

/* ── Header ──────────────────────────────────────────────────────────────── */
.rd-head {
    position: sticky; top: 0; z-index: 50;
    height: var(--rd-head);
    display: flex; align-items: center; gap: 18px;
    padding-inline: max(16px, calc((100vw - 1180px) / 2));
    background: color-mix(in srgb, var(--rd-bg) 88%, transparent);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--rd-line);
}

.rd-logo {
    display: flex; align-items: center; gap: 9px;
    font-weight: 900; font-size: 1.12rem; letter-spacing: -.02em;
    color: inherit; text-decoration: none; flex-shrink: 0;
}
.rd-logo b {
    display: grid; place-items: center; width: 30px; height: 30px;
    border-radius: 9px; background: var(--rd-brand); color: var(--rd-brand-ink);
    font-size: .82rem; font-weight: 900;
}

.rd-nav { display: flex; gap: 4px; }
.rd-nav a {
    padding: 8px 13px; border-radius: 999px;
    color: var(--rd-muted); font-size: .93rem; font-weight: 600; text-decoration: none;
    transition: background .18s var(--rd-ease), color .18s var(--rd-ease);
}
.rd-nav a:hover { background: var(--rd-raise); color: var(--rd-ink); }
.rd-nav a.is-on { color: var(--rd-ink); background: var(--rd-raise); }

.rd-search { flex: 1; max-width: 340px; margin-left: auto; position: relative; }
.rd-search input {
    width: 100%; height: 40px; padding: 0 14px 0 38px;
    border: 1px solid var(--rd-line); border-radius: 999px;
    background: var(--rd-raise); color: var(--rd-ink); font: inherit; font-size: .92rem;
}
.rd-search input:focus {
    outline: none; border-color: var(--rd-brand);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--rd-brand) 22%, transparent);
}
.rd-search svg { position: absolute; left: 13px; top: 11px; width: 17px; height: 17px; color: var(--rd-muted); }

.rd-cta {
    flex-shrink: 0; padding: 9px 17px; border: 0; border-radius: 999px;
    background: var(--rd-brand); color: var(--rd-brand-ink);
    font: inherit; font-size: .9rem; font-weight: 800; text-decoration: none;
    cursor: pointer; transition: transform .16s var(--rd-ease), filter .16s var(--rd-ease);
}
.rd-cta:hover { filter: brightness(1.06); transform: translateY(-1px); }

/* ── Views ───────────────────────────────────────────────────────────────── */
.rd-view { display: none; padding-block: 28px 64px; animation: rd-in .32s var(--rd-ease) both; }
.rd-view.is-on { display: block; }
@keyframes rd-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.rd-h2 {
    display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
    margin: 34px 0 14px; font-size: 1.24rem; font-weight: 850; letter-spacing: -.02em;
}
.rd-h2 a { color: var(--rd-muted); font-size: .86rem; font-weight: 700; text-decoration: none; }
.rd-h2 a:hover { color: var(--rd-brand); }

/* ── Hero ────────────────────────────────────────────────────────────────── */
.rd-hero {
    position: relative; overflow: hidden;
    display: grid; grid-template-columns: 1.1fr .9fr; align-items: center; gap: 28px;
    min-height: 300px; padding: 30px;
    border-radius: 22px; color: #fff;
    background: linear-gradient(120deg, #1d2b64, #4f2d7f 55%, #b13a6b);
    box-shadow: var(--rd-shadow);
}
.rd-hero-copy { position: relative; z-index: 2; }
.rd-hero .rd-badge { background: rgba(255,255,255,.16); color: #fff; }
.rd-hero h1 { margin: 12px 0 8px; font-size: clamp(1.7rem, 3.6vw, 2.5rem); font-weight: 900; letter-spacing: -.03em; line-height: 1.1; }
.rd-hero p { margin: 0 0 18px; max-width: 46ch; color: rgba(255,255,255,.86); font-size: .98rem; }
.rd-hero-art {
    aspect-ratio: 4/3; border-radius: 16px;
    background: repeating-linear-gradient(135deg, rgba(255,255,255,.10) 0 14px, rgba(255,255,255,.04) 14px 28px);
    display: grid; place-items: center; color: rgba(255,255,255,.72);
    font-size: .82rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
}

.rd-badge {
    display: inline-block; padding: 4px 11px; border-radius: 999px;
    background: var(--rd-raise); color: var(--rd-muted);
    font-size: .68rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
}

/* ── Card grid + rails ───────────────────────────────────────────────────── */
.rd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 22px 18px; }
.rd-rail { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(168px, 1fr); gap: 18px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x mandatory; }
.rd-rail > * { scroll-snap-align: start; }
.rd-rail::-webkit-scrollbar { height: 8px; }
.rd-rail::-webkit-scrollbar-thumb { background: var(--rd-line); border-radius: 999px; }

.rd-card { border: 0; padding: 0; background: none; color: inherit; text-align: left; cursor: pointer; font: inherit; }
.rd-card-art {
    position: relative; aspect-ratio: 3/4; border-radius: var(--rd-r); overflow: hidden;
    background: var(--rd-raise); display: grid; place-items: center;
    transition: transform .22s var(--rd-ease), box-shadow .22s var(--rd-ease);
}
.rd-card:hover .rd-card-art { transform: translateY(-4px); box-shadow: var(--rd-shadow); }
.rd-card-art span { font-size: 2rem; font-weight: 900; color: color-mix(in srgb, var(--rd-ink) 22%, transparent); }
.rd-card-art::after {
    content: attr(data-tag); position: absolute; left: 8px; top: 8px;
    padding: 3px 8px; border-radius: 6px; background: rgba(0,0,0,.62); color: #fff;
    font-size: .62rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
}
.rd-card h3 { margin: 10px 0 2px; font-size: .95rem; font-weight: 750; line-height: 1.3; }
.rd-card p { margin: 0; color: var(--rd-muted); font-size: .8rem; }

/* ── Chips ───────────────────────────────────────────────────────────────── */
.rd-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.rd-chip {
    padding: 8px 15px; border: 1px solid var(--rd-line); border-radius: 999px;
    background: var(--rd-surface); color: var(--rd-muted);
    font: inherit; font-size: .87rem; font-weight: 650; cursor: pointer;
    transition: all .16s var(--rd-ease);
}
.rd-chip:hover { border-color: var(--rd-brand); color: var(--rd-ink); }
.rd-chip.is-on { background: var(--rd-ink); border-color: var(--rd-ink); color: var(--rd-bg); }

/* ── Series page ─────────────────────────────────────────────────────────── */
.rd-series-head { display: grid; grid-template-columns: 220px minmax(0,1fr); gap: 28px; align-items: start; margin-bottom: 12px; }
.rd-series-cover { aspect-ratio: 3/4; border-radius: 18px; background: var(--rd-raise); display: grid; place-items: center; box-shadow: var(--rd-shadow); }
.rd-series-cover span { font-size: 3rem; font-weight: 900; color: color-mix(in srgb, var(--rd-ink) 20%, transparent); }
.rd-series-head h1 { margin: 6px 0 6px; font-size: clamp(1.5rem, 3vw, 2.1rem); font-weight: 900; letter-spacing: -.02em; }
.rd-byline { margin: 0 0 14px; color: var(--rd-muted); font-size: .93rem; }
.rd-synopsis { max-width: 62ch; color: var(--rd-muted); }
.rd-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.rd-btn {
    padding: 11px 20px; border: 1px solid var(--rd-line); border-radius: 999px;
    background: var(--rd-surface); color: var(--rd-ink);
    font: inherit; font-size: .92rem; font-weight: 750; cursor: pointer;
    transition: all .16s var(--rd-ease);
}
.rd-btn:hover { border-color: var(--rd-brand); }
.rd-btn.is-primary { background: var(--rd-brand); border-color: var(--rd-brand); color: var(--rd-brand-ink); }
.rd-btn.is-on { background: var(--rd-ink); border-color: var(--rd-ink); color: var(--rd-bg); }

.rd-eps { margin-top: 10px; border-top: 1px solid var(--rd-line); }
.rd-ep {
    display: grid; grid-template-columns: 84px minmax(0,1fr) auto; gap: 16px; align-items: center;
    width: 100%; padding: 14px 8px; border: 0; border-bottom: 1px solid var(--rd-line);
    background: none; color: inherit; font: inherit; text-align: left; cursor: pointer;
    transition: background .16s var(--rd-ease);
}
.rd-ep:hover { background: var(--rd-raise); }
.rd-ep-thumb { aspect-ratio: 16/10; border-radius: 8px; background: var(--rd-raise); display: grid; place-items: center; color: var(--rd-muted); font-size: .7rem; font-weight: 800; }
.rd-ep strong { display: block; font-size: .95rem; font-weight: 700; }
.rd-ep small { color: var(--rd-muted); font-size: .8rem; }
.rd-ep-date { color: var(--rd-muted); font-size: .82rem; }

/* ── Reader view ─────────────────────────────────────────────────────────── */
.rd-reader { background: #0b0d12; }
.rd-strip { width: min(760px, 100%); margin: 0 auto; display: grid; gap: 2px; }
.rd-panel {
    aspect-ratio: 3/4.4; display: grid; place-items: center;
    background: repeating-linear-gradient(180deg, #171b24 0 60px, #141821 60px 120px);
    color: #46506a; font-size: .8rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase;
}
.rd-readbar {
    position: sticky; bottom: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    width: min(760px, 100%); margin: 0 auto; padding: 12px 16px;
    background: color-mix(in srgb, var(--rd-bg) 92%, transparent);
    backdrop-filter: blur(10px); border-top: 1px solid var(--rd-line);
}
.rd-progress { position: fixed; left: 0; top: var(--rd-head); height: 3px; background: var(--rd-brand); z-index: 60; transition: width .1s linear; }

/* ── Placeholder marker — a reader must never mistake a stub for a comic ─── */
.rd-stub {
    display: flex; align-items: flex-start; gap: 12px;
    margin: 22px 0; padding: 14px 16px;
    border: 1px dashed color-mix(in srgb, var(--rd-ink) 26%, transparent);
    border-radius: 12px; background: var(--rd-raise);
    color: var(--rd-muted); font-size: .87rem; line-height: 1.5;
}
.rd-stub b { color: var(--rd-ink); }
.rd-stub-dot { flex-shrink: 0; width: 9px; height: 9px; margin-top: 6px; border-radius: 50%; background: #f5a524; }

.rd-empty { padding: 60px 20px; text-align: center; color: var(--rd-muted); }

/* ── Footer ──────────────────────────────────────────────────────────────── */
.rd-foot { margin-top: 40px; padding: 30px 0 50px; border-top: 1px solid var(--rd-line); color: var(--rd-muted); font-size: .85rem; }
.rd-foot a { color: var(--rd-muted); }

/* ── Small screens ───────────────────────────────────────────────────────── */
@media (max-width: 860px) {
    .rd-hero { grid-template-columns: 1fr; }
    .rd-hero-art { display: none; }
    .rd-series-head { grid-template-columns: 130px minmax(0,1fr); gap: 18px; }
    .rd-nav { display: none; }
    .rd-search { max-width: none; }
    .rd-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 18px 12px; }
    .rd-ep { grid-template-columns: 64px minmax(0,1fr); }
    .rd-ep-date { display: none; }
}
