/*
  English News Korea (/ENK/): its own stylesheet, separate from the coding site's.

  The look follows ENK Studio's presentation reader (dark #20232a chrome, #2b2f38 panels,
  purple accent, big tap targets) and the printed editions (white paper, the edition's colour
  gradient on every banner, star ratings, a WORDS table). The gradient is the --rainbow custom
  property, set per issue from its theme colours (ENK Studio's EditionTheme).
*/

:root {
    --bg: #20232a;
    --panel: #2b2f38;
    --panel-line: #3a3f4b;
    --text: #ffffff;
    --muted: #b8bfcc;
    --accent: #7b61ff;
    --accent-text: #b9abff;
    --switch-on: #1f8a7a;
    --paper: #ffffff;
    --ink: #1c1d22;
    --ink-muted: #5b5f6a;
    --star: #f5b301;
    --rainbow: linear-gradient(90deg, #ff4fa3 0%, #ff8a3d 25%, #ffd23f 50%, #33d6c0 75%, #7c6bf2 100%);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
    --gutter: 16px;
    --width: 52rem;
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 18px/1.55 var(--font);
    overflow-wrap: break-word;
}
a { color: var(--accent-text); text-underline-offset: 0.18em; }
a:hover { color: #ffffff; }
:focus-visible { outline: 3px solid var(--star); outline-offset: 2px; border-radius: 4px; }
img { max-width: 100%; height: auto; }
[hidden] { display: none !important; }
h1, h2, h3 { line-height: 1.2; margin: 1.5rem 0 0.75rem; }
h1 { font-size: clamp(1.8rem, 1.3rem + 2.5vw, 2.6rem); }
h2 { font-size: 1.5rem; }
.skip { position: absolute; left: -999px; top: 0; padding: 0.5rem 1rem; background: var(--panel); }
.skip:focus { left: var(--gutter); z-index: 10; }

/* ---------- Chrome ---------- */

.enk-header { background: var(--panel); border-bottom: 1px solid var(--panel-line); }
.enk-bar {
    max-width: var(--width);
    margin: 0 auto;
    padding: 0.7rem var(--gutter);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 1.5rem;
}
.enk-brand { font-weight: 800; font-size: 1.15rem; color: var(--text); text-decoration: none; margin-right: auto; }
.enk-nav { display: flex; gap: 0.25rem 1.25rem; flex-wrap: wrap; }
.enk-nav a { color: var(--muted); text-decoration: none; padding: 0.45rem 0; border-bottom: 3px solid transparent; }
.enk-nav a:hover { color: var(--text); }
.enk-nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }

main { max-width: var(--width); margin: 0 auto; padding: 0 var(--gutter) 3rem; }

.enk-footer {
    max-width: var(--width);
    margin: 0 auto;
    padding: 1.5rem var(--gutter) 2.5rem;
    color: var(--muted);
    font-size: 0.9rem;
    border-top: 1px solid var(--panel-line);
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.5rem 2rem;
}
.enk-footer p { margin: 0; }
.enk-footer a { color: var(--muted); margin-left: 1rem; }
.enk-footer a:first-child { margin-left: 0; }

.enk-lede { color: var(--muted); font-size: 1.15rem; max-width: 40rem; }
.enk-page-header { margin: 2rem 0 1.5rem; }
.enk-page-header h1 { margin-top: 0; }

.pill {
    display: inline-flex;
    align-items: center;
    min-height: 48px;
    padding: 0.5rem 1.2rem;
    border-radius: 999px;
    background: var(--accent);
    color: #ffffff;
    font-weight: 700;
    text-decoration: none;
}
.pill:hover { color: #ffffff; filter: brightness(1.12); }

/* ---------- ENK home ---------- */

.enk-hero { padding: 2.5rem 0 1rem; }
.enk-hero h1 {
    margin: 0 0 0.75rem;
    font-size: clamp(2.2rem, 1.4rem + 4vw, 3.6rem);
    font-weight: 900;
    background: var(--rainbow);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.latest { margin: 1.5rem 0 2.5rem; }
.latest-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1.5rem;
    align-items: center;
    padding: 1rem;
    border-radius: 18px;
    background: var(--panel);
    border-top: 8px solid transparent;
    border-image: var(--rainbow) 1;
    color: var(--text);
    text-decoration: none;
}
.latest-card img { border-radius: 10px; display: block; width: 100%; height: auto; max-height: 26rem; object-fit: contain; }
.latest-text { display: flex; flex-direction: column; gap: 0.6rem; align-items: flex-start; }
.latest-label { color: var(--muted); font-size: 0.95rem; }
.latest-title { font-size: clamp(1.5rem, 1.2rem + 1.5vw, 2.1rem); font-weight: 800; line-height: 1.15; }
.latest-topics { color: var(--muted); }
.latest-card:hover .pill { filter: brightness(1.12); }
@media (max-width: 620px) { .latest-card { grid-template-columns: 1fr; } }

.issue-grid {
    list-style: none;
    padding: 0;
    margin: 0 0 1.5rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr));
    gap: 1rem;
}
.issue-card a {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    height: 100%;
    padding: 0 0 0.9rem;
    border-radius: 14px;
    overflow: hidden;
    background: var(--panel);
    color: var(--text);
    text-decoration: none;
}
.issue-card a::before { content: ""; height: 6px; background: var(--rainbow); }
.issue-card a:hover { background: #343945; }
/* Covers vary from about square to 2.5:1: the whole cover, centred on the card in an even box. */
.issue-card img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: contain; margin-bottom: 0.5rem; }
.issue-card-number, .issue-card-title, .issue-card time { padding: 0 0.9rem; }
.issue-card-number { color: var(--muted); font-size: 0.9rem; font-weight: 700; }
.issue-card-title { font-weight: 800; font-size: 1.1rem; line-height: 1.25; }
.issue-card time { color: var(--muted); font-size: 0.88rem; }

.enk-more ul { padding-left: 1.2rem; }
.enk-more li { margin-bottom: 0.4rem; }

.topic-list { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 0.6rem; }
.topic-list a {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 44px;
    padding: 0.3rem 1rem;
    border-radius: 999px;
    background: var(--panel);
    color: var(--text);
    text-decoration: none;
}
.topic-list span { color: var(--muted); font-size: 0.85rem; }

/* ---------- Issue page ---------- */

.issue { padding-top: 1.5rem; }
.issue-banner {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.25rem 1rem;
    padding: 0.55rem 1.1rem;
    border-radius: 999px;
    background: var(--rainbow);
    color: #ffffff;
    font-weight: 900;
    font-size: clamp(1rem, 0.85rem + 0.8vw, 1.35rem);
    text-shadow: -1px -1px 0 #222, 1px -1px 0 #222, -1px 1px 0 #222, 1px 1px 0 #222, 0 2px 3px rgba(0, 0, 0, 0.35);
}

.paper {
    margin: 1.25rem 0;
    padding: 1.25rem;
    border-radius: 18px;
    background: var(--paper);
    color: var(--ink);
}
.paper a { color: #4b32d6; }
.paper h1, .paper h2 { color: var(--ink); }
.issue-intro h1 { margin-top: 0.25rem; }
.issue-cover { display: block; width: 100%; border-radius: 10px; margin-bottom: 1rem; }
.issue-intro-text p { margin: 0 0 0.9rem; }
.issue-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 1rem 0 0; }
.issue-actions .pill { color: #ffffff; }
.issue-topics { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 1rem 0 0; }
.issue-topics a {
    padding: 0.15rem 0.75rem;
    border-radius: 999px;
    background: #efedfc;
    color: #4b32d6;
    text-decoration: none;
    font-size: 0.9rem;
}

/* In this issue: one row per story, each a jump to its card. */
.issue-contents {
    margin: 1.25rem 0;
    padding: 0.9rem 1.1rem 1rem;
    border-radius: 18px;
    background: var(--panel);
    border: 1px solid var(--panel-line);
}
.issue-contents h2 { margin: 0 0 0.5rem; font-size: 1.1rem; color: var(--muted); font-weight: 700; }
.issue-contents ol { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: max-content 1fr; }
.issue-contents li { display: contents; }
.issue-contents li + li a { border-top: 1px solid var(--panel-line); }
.issue-contents a {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: subgrid;
    gap: 0.15rem 1rem;
    align-items: baseline;
    padding: 0.6rem 0.25rem;
    min-height: 44px;
    color: var(--text);
    text-decoration: none;
}
.issue-contents a:hover .issue-contents-title { color: var(--accent-text); text-decoration: underline; }
.issue-contents-level { color: var(--muted); font-size: 0.9rem; white-space: nowrap; }
.issue-contents-level .stars .off { color: #5b6170; }
.issue-contents-title { font-weight: 800; font-size: 1.1rem; line-height: 1.3; }
@media (max-width: 34rem) {
    .issue-contents ol, .issue-contents a { grid-template-columns: 1fr; }
}
.story { scroll-margin-top: 1rem; }
.story-back { margin: 1rem 0 0; font-size: 0.95rem; }
@media print { .issue-contents, .story-back { display: none; } }

/* A story card: category strip, title, stars, picture, sentences, audio, words. */
.story-head { margin-bottom: 0.9rem; }
.story-category {
    display: inline-block;
    margin: 0 0 0.5rem;
    padding: 0.15rem 0.9rem;
    border-radius: 999px;
    background: var(--rainbow);
    color: #ffffff;
    font-weight: 900;
    text-shadow: -1px -1px 0 #222, 1px -1px 0 #222, -1px 1px 0 #222, 1px 1px 0 #222;
}
.story h2 { margin: 0 0 0.3rem; font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2rem); font-weight: 900; }
.story-meta { margin: 0; color: var(--ink-muted); display: flex; flex-wrap: wrap; gap: 0.25rem 0.9rem; align-items: center; }
.stars { letter-spacing: 1px; font-size: 1.1rem; }
.stars .on { color: var(--star); }
.stars .off { color: #d6d8de; }
.story-image { display: block; width: 100%; border-radius: 10px; margin: 0.5rem 0 1rem; }
.story-text { font-size: 1.15rem; line-height: 1.7; }
.sentence { border-radius: 4px; }
.story-audio { display: block; width: 100%; margin: 1rem 0 0.5rem; }

/* The reader (enk-reader.js): only present when the script runs. */
button { font: inherit; }
.pill { border: 0; cursor: pointer; }
.story-head { position: relative; padding-right: 6.5rem; }
.story-play {
    position: absolute; top: 0; right: 0;
    min-width: 5.5rem; min-height: 48px; padding: 0.4rem 1rem;
    border: 0; border-radius: 999px; cursor: pointer;
    background: var(--accent); color: #ffffff; font-weight: 800;
}
.story-play::before { content: "\25B6\FE0E\00A0"; font-size: 0.8em; }
.story-play.on { background: var(--ink); }
.story-play.on::before { content: "\2759\2759\00A0"; letter-spacing: 0.08em; font-size: 0.7em; }
.sentence[role="button"] { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.sentence[role="button"]:focus-visible { outline-offset: 0; }
.sentence.playing { background: #ffe680; box-shadow: 0 0 0 0.12em #ffe680; }
.reader-bar { display: none; }
@media (max-width: 700px) {
    .reader-bar {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
        display: grid; grid-template-columns: 2fr 1fr; gap: 0.6rem;
        padding: 0.6rem var(--gutter) calc(0.6rem + env(safe-area-inset-bottom));
        background: var(--panel); border-top: 1px solid var(--panel-line);
    }
    .reader-bar button {
        min-height: 52px; padding: 0 1.1rem; border-radius: 999px; border: 0; cursor: pointer;
        background: var(--accent); color: #ffffff; font-weight: 800; font-size: 1.05rem;
    }
    .reader-bar .reader-stop { background: var(--bg); border: 2px solid var(--panel-line); }
    .reader-bar .reader-play.on { background: var(--ink); }
    .has-reader-bar { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
}
.story-korean { margin: 0.75rem 0; }
.story-korean summary { cursor: pointer; font-weight: 700; color: #4b32d6; min-height: 44px; display: flex; align-items: center; }
.story-korean ol { padding-left: 1.4rem; margin: 0.25rem 0 0; }
.story-korean li { margin-bottom: 0.4rem; }
.story-korean li span { display: block; color: var(--ink-muted); font-size: 0.92rem; }

.words { width: 100%; border-collapse: collapse; margin-top: 1rem; font-size: 1rem; }
.words caption {
    text-align: left;
    padding: 0.2rem 0.9rem;
    margin-bottom: 0.4rem;
    width: max-content;
    border-radius: 999px;
    background: var(--rainbow);
    color: #ffffff;
    font-weight: 900;
    text-shadow: -1px -1px 0 #222, 1px -1px 0 #222, -1px 1px 0 #222, 1px 1px 0 #222;
}
.words th, .words td { padding: 0.35rem 0.75rem; border-bottom: 1px solid #e6e3f4; text-align: left; }
.words th { font-weight: 700; width: 45%; }
.words td { background: #f6f4ff; }

@media (min-width: 760px) {
    .story-image { float: left; width: 42%; margin: 0.25rem 1.25rem 0.75rem 0; }
    .story::after { content: ""; display: block; clear: both; }
}

/* Older issues: the printed pages as pictures. */
.issue-pages { display: flex; flex-direction: column; gap: 1rem; margin: 1.25rem 0; }
.issue-pages a, .issue-pages img { display: block; }
.issue-pages img { width: 100%; border-radius: 10px; background: var(--paper); }
.swipe-hint, .snap { display: none; }
@media (max-width: 700px) {
    .swipe-hint { display: block; margin: 0; color: var(--muted); font-size: 0.95rem; }
    .spread {
        display: grid;
        grid-template-columns: 100% 100%;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        overscroll-behavior-x: contain;
        border-radius: 10px;
    }
    .spread a { grid-column: 1 / 3; grid-row: 1; }
    .spread img { border-radius: 0; }
    .spread .snap { display: block; grid-row: 1; scroll-snap-align: start; }
    .spread .snap:first-of-type { grid-column: 1; }
    .spread .snap:last-of-type { grid-column: 2; }
}
.issue-about img { display: block; width: 100%; }

.issue-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 2rem 0; }
.issue-nav a {
    display: block;
    padding: 0.9rem 1.1rem;
    border-radius: 14px;
    background: var(--panel);
    color: var(--text);
    font-weight: 800;
    text-decoration: none;
}
.issue-nav a:hover { background: #343945; }
.issue-nav span { display: block; color: var(--muted); font-weight: 400; font-size: 0.85rem; }
.issue-nav .next { grid-column: 2; text-align: right; }
@media (max-width: 520px) {
    .issue-nav { grid-template-columns: 1fr; }
    .issue-nav .next { grid-column: 1; }
}

@media print {
    .enk-header, .enk-footer, .issue-nav, .story-audio, .issue-actions, .story-play, .reader-bar { display: none; }
    .sentence.playing { background: none; box-shadow: none; }
    body { background: #fff; color: #000; }
    .paper { padding: 0; }
}

/* ---------- Bricks Reading (/ENK/Bricks/, bricks.js) ---------- */

.bricks-qr-page {
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}
.bricks-qr-page { border: 0; }
.bricks-qr-page[hidden] { display: none; }

/* The code full screen: as big as the screen allows, black on white with its border, so a tablet
   across the room can read it. */
.bricks-qr {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: var(--gutter);
    box-sizing: border-box;
    background: var(--bg);
    text-align: center;
}
.bricks-qr[hidden] { display: none; }
.bricks-qr h2 { margin: 0; font-size: 1.6rem; line-height: 1.2; }
.bricks-qr-code { width: min(86vw, calc(100vh - 230px)); aspect-ratio: 1; }
.bricks-qr-code svg { display: block; width: 100%; height: 100%; border-radius: 12px; }
.bricks-qr-url { margin: 0; max-width: 100%; color: var(--muted); font-size: 1rem; overflow-wrap: anywhere; }
.bricks-qr .pill { min-width: 9rem; border: 0; font: inherit; font-weight: 700; cursor: pointer; }
body.bricks-qr-open { overflow: hidden; }
