/* ==========================================================================
   Cryptic answer pages — Minute Cryptic + Parseword (today + archive pages)
   The hero is a "marked-up clue sheet": the clue set like a newspaper
   crossword clue, and each hint you open swipes a highlighter over the part
   of the clue it explains (definition = blue, indicator = pink, fodder =
   yellow — the official Minute Cryptic colours). Works without JavaScript:
   hints and the answer are <details>, and :has() drives the highlights and
   the tile reveal. JS only adds "reveal one letter".
   ========================================================================== */

:root {
    --cs-paper: #fffdf7;
    --cs-paper-edge: #efe7d4;
    --cs-ink: #1f1c17;
    --cs-ink-soft: #5c5548;
    --cs-rule: #ece5d3;
    --cs-accent: #5a67d8;
    --cs-accent-soft: #eef0ff;
    --hl-definition: #b9dcff;
    --hl-definition-ink: #1d5fbf;
    --hl-indicator: #ffc4dd;
    --hl-indicator-ink: #b4236b;
    --hl-fodder: #ffe680;
    --hl-fodder-ink: #8a6100;
    --cs-serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;
}

/* ---- Compact header so the clue sheet lands above the fold ---- */
.cs-page .page-header { margin-bottom: 14px; }
.cs-page .page-header h1 { font-size: clamp(1.55rem, 4.6vw, 2.15rem); line-height: 1.2; margin-bottom: 6px; }
.cs-page .page-meta { color: #6b7280; font-size: .9rem; }
.cs-page .page-meta a { color: var(--cs-accent); }

/* ---- The clue sheet ---- */
.clue-sheet {
    position: relative;
    background: var(--cs-paper);
    border: 1px solid var(--cs-paper-edge);
    border-radius: 14px;
    padding: 22px 22px 18px;
    margin-bottom: 18px;
    box-shadow: 0 1px 0 #fff inset, 0 10px 28px -18px rgba(60, 45, 10, .35);
    background-image: repeating-linear-gradient(to bottom, transparent 0 31px, var(--cs-rule) 31px 32px);
    background-position: 0 14px;
}
.clue-sheet::before {           /* margin rule, like a solver's notepad */
    content: "";
    position: absolute; top: 0; bottom: 0; left: 12px;
    width: 1px; background: #f2c9c9;
}
.cs-kicker {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px;
    font-size: .78rem; letter-spacing: .06em; text-transform: uppercase;
    color: var(--cs-ink-soft); margin-bottom: 10px;
}
.cs-kicker b { color: var(--cs-ink); letter-spacing: .04em; }
.cs-chip {
    display: inline-block; padding: 2px 9px; border-radius: 999px;
    background: #fff; border: 1px solid var(--cs-paper-edge);
    text-transform: none; letter-spacing: 0; font-size: .8rem; color: var(--cs-ink-soft);
}
.cs-clue {
    font-family: var(--cs-serif);
    font-size: clamp(1.4rem, 4.8vw, 1.95rem);
    line-height: 1.45;
    color: var(--cs-ink);
    margin: 4px 0 14px;
    font-weight: 500;
}
.cs-enum { color: var(--cs-ink-soft); white-space: nowrap; }

/* Highlighter swipe: segments carry .seg-{role}; opening the matching hint
   (anywhere inside the same .clue-sheet) runs the marker across them. */
.cs-clue .seg {
    background-repeat: no-repeat;
    background-size: 0% 100%;
    background-position: 0 0;
    border-radius: 3px;
    padding: 0 1px;
    transition: background-size .55s cubic-bezier(.2,.7,.2,1);
    -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
.cs-clue .seg-definition { background-image: linear-gradient(transparent 12%, var(--hl-definition) 12%, var(--hl-definition) 92%, transparent 92%); }
.cs-clue .seg-indicator  { background-image: linear-gradient(transparent 12%, var(--hl-indicator) 12%, var(--hl-indicator) 92%, transparent 92%); }
.cs-clue .seg-fodder     { background-image: linear-gradient(transparent 12%, var(--hl-fodder) 12%, var(--hl-fodder) 92%, transparent 92%); }
.clue-sheet:has(.cs-hint[data-hl="definition"][open]) .seg-definition,
.clue-sheet:has(.cs-hint[data-hl="indicator"][open]) .seg-indicator,
.clue-sheet:has(.cs-hint[data-hl="fodder"][open]) .seg-fodder,
.clue-sheet:has(.cs-answer[open]) .seg { background-size: 100% 100%; }

/* ---- Answer tiles ---- */
.cs-tiles { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0 0 16px; }
.cs-word { display: flex; gap: 5px; }
.cs-tile {
    width: 42px; height: 46px;
    display: grid; place-items: center;
    background: #fff;
    border: 2px solid var(--cs-ink);
    border-radius: 4px;
    font: 700 1.35rem/1 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: transparent;
    box-shadow: 0 3px 0 #c9d6ff;
    user-select: none;
}
.cs-tile.is-revealed,
.clue-sheet:has(.cs-answer[open]) .cs-tile {
    color: var(--cs-ink);
    animation: cs-flip .42s ease both;
}
@keyframes cs-flip { from { transform: rotateX(90deg); } to { transform: none; } }

/* ---- Hint ladder ---- */
.cs-hints { display: grid; gap: 8px; margin-bottom: 12px; }
.cs-hint {
    background: #fff;
    border: 1px solid #e6e1d4;
    border-radius: 10px;
    overflow: hidden;
}
.cs-hint > summary {
    list-style: none;
    display: flex; align-items: center; gap: 10px;
    padding: 11px 14px;
    cursor: pointer;
    font-weight: 600; font-size: .95rem; color: var(--cs-ink);
    min-height: 44px;
}
.cs-hint > summary::-webkit-details-marker { display: none; }
.cs-hint > summary::after {
    content: "Reveal"; margin-left: auto;
    font-weight: 500; font-size: .82rem; color: var(--cs-accent);
}
.cs-hint[open] > summary::after { content: "Hide"; color: #9a9384; }
.cs-dot { width: 12px; height: 12px; border-radius: 3px; flex: none; background: #d6d3cc; transform: rotate(-8deg); }
.cs-hint[data-hl="definition"] .cs-dot { background: var(--hl-definition); box-shadow: inset 0 0 0 1px var(--hl-definition-ink); }
.cs-hint[data-hl="indicator"] .cs-dot { background: var(--hl-indicator); box-shadow: inset 0 0 0 1px var(--hl-indicator-ink); }
.cs-hint[data-hl="fodder"] .cs-dot { background: var(--hl-fodder); box-shadow: inset 0 0 0 1px var(--hl-fodder-ink); }
.cs-hint .cs-hint-body { padding: 0 14px 13px 36px; color: #3f3a31; font-size: .95rem; line-height: 1.55; }
.cs-hint[open] { border-color: #d9d2c0; }
.cs-hint[open] > summary { padding-bottom: 6px; }

/* ---- Actions ---- */
.cs-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.cs-btn, .cs-answer > summary {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px; padding: 10px 18px;
    border-radius: 10px; border: 1.5px solid var(--cs-ink);
    background: #fff; color: var(--cs-ink);
    font-weight: 600; font-size: .95rem; cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease;
}
.cs-btn:hover, .cs-answer > summary:hover { transform: translateY(-1px); box-shadow: 0 3px 0 var(--cs-ink); }
.cs-btn:focus-visible, .cs-answer > summary:focus-visible, .cs-hint > summary:focus-visible { outline: 3px solid #a5b4fc; outline-offset: 2px; }
.cs-btn[disabled] { opacity: .45; cursor: default; transform: none; box-shadow: none; }
.cs-answer { width: 100%; }
.cs-answer > summary { list-style: none; background: var(--cs-ink); color: #fffdf7; }
.cs-answer > summary::-webkit-details-marker { display: none; }
.cs-answer[open] > summary { display: none; }
.cs-actions .cs-answer { flex: 1 1 160px; width: auto; }
.cs-actions .cs-answer > summary { width: 100%; }
.cs-actions .cs-answer[open] { flex-basis: 100%; }

.cs-solution {
    margin-top: 4px;
    background: #fff;
    border: 1px solid #e6e1d4;
    border-left: 4px solid var(--cs-ink);
    border-radius: 10px;
    padding: 14px 16px;
    animation: cs-in .35s ease both;
}
@keyframes cs-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.cs-solution-word { font: 800 1.6rem/1.1 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; letter-spacing: .14em; color: var(--cs-ink); }
.cs-solution h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--cs-ink-soft); margin: 14px 0 6px; }
.cs-parse { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.cs-parse li { display: grid; grid-template-columns: 96px 1fr; gap: 8px; font-size: .94rem; color: #3f3a31; }
.cs-parse .cs-role { font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; padding-top: 2px; }
.cs-parse .cs-role-definition { color: var(--hl-definition-ink); }
.cs-parse .cs-role-indicator { color: var(--hl-indicator-ink); }
.cs-parse .cs-role-fodder { color: var(--hl-fodder-ink); }
.cs-parse .cs-role-answer { color: var(--cs-ink); }
.cs-solution .cs-video { display: inline-block; margin-top: 12px; font-size: .9rem; color: var(--cs-accent); font-weight: 600; }

.cs-play {
    margin-top: 12px; font-size: .86rem; color: var(--cs-ink-soft);
}
.cs-play a { color: var(--cs-accent); font-weight: 600; }

/* ---- Parseword: the parse ladder ---- */
.pw-steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; counter-reset: pw; }
.pw-step {
    counter-increment: pw;
    display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: start;
    font-size: .95rem; color: #3f3a31;
}
.pw-step::before {
    content: counter(pw);
    width: 26px; height: 26px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--cs-ink); color: #fffdf7; font-weight: 700; font-size: .8rem;
}
.pw-from { text-decoration: line-through; text-decoration-color: #c2b9a3; color: #7a7262; }
.pw-arrow { color: #a69d88; margin: 0 6px; }
.pw-to { font-weight: 700; letter-spacing: .06em; color: var(--cs-ink); text-transform: uppercase; }
.pw-type {
    display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px;
    font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
    background: var(--cs-accent-soft); color: #3c46a8; vertical-align: 1px;
}
.pw-ind { display: block; font-size: .85rem; color: var(--cs-ink-soft); margin-top: 2px; }

/* ---- Supporting cards ---- */
.cs-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 6px 0 4px; }
.cs-stat { background: #faf8f3; border: 1px solid #ece6d6; border-radius: 10px; padding: 12px 14px; }
.cs-stat b { display: block; font-size: 1.35rem; color: var(--cs-ink); line-height: 1.2; }
.cs-stat span { font-size: .82rem; color: var(--cs-ink-soft); }

.cs-tomorrow > summary {
    list-style: none; cursor: pointer;
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    font-weight: 700; color: #2d3748; font-size: 1.05rem; min-height: 44px;
}
.cs-tomorrow > summary::-webkit-details-marker { display: none; }
.cs-tomorrow > summary::after { content: "Show"; margin-left: auto; font-size: .85rem; font-weight: 600; color: var(--cs-accent); }
.cs-tomorrow[open] > summary::after { content: "Hide"; color: #9a9384; }
.cs-tomorrow .clue-sheet { margin: 12px 0 0; }
.cs-live-badge { font-size: .74rem; font-weight: 700; color: #0f766e; background: #ccfbf1; padding: 2px 9px; border-radius: 999px; }

.cs-archive { width: 100%; border-collapse: collapse; font-size: .92rem; }
.cs-archive th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: #8a8372; padding: 8px 6px; border-bottom: 2px solid #ece6d6; }
.cs-archive td { padding: 9px 6px; border-bottom: 1px solid #f1ede2; vertical-align: top; }
.cs-archive td:first-child { white-space: nowrap; color: #6b6457; }
.cs-archive td a { color: var(--cs-accent); text-decoration: none; font-weight: 600; }
.cs-archive td a:hover { text-decoration: underline; }
.cs-archive .cs-arch-answer { font-weight: 700; letter-spacing: .06em; white-space: nowrap; }

.cs-figure { margin: 14px 0 6px; }
.cs-figure img { width: 100%; height: auto; border-radius: 12px; border: 1px solid #ece6d6; display: block; }
.cs-figure figcaption { font-size: .84rem; color: #7a7262; margin-top: 6px; text-align: center; }

.cs-links { display: flex; flex-wrap: wrap; gap: 10px; }
.cs-links a {
    display: inline-block; padding: 8px 14px; border-radius: 999px;
    background: #f4f5ff; color: #3c46a8; text-decoration: none; font-weight: 600; font-size: .9rem;
    border: 1px solid #e0e4ff;
}
.cs-links a:hover { background: #e9ecff; }

.cs-page .answer-card h2 { font-size: 1.3rem; color: #2d3748; margin-bottom: 10px; }
.cs-page .answer-card h3 { font-size: 1.05rem; color: #2d3748; margin: 16px 0 6px; }
.cs-page .answer-card p { color: #4a5160; margin-bottom: 10px; line-height: 1.7; }
.cs-page .answer-card ul, .cs-page .answer-card ol { margin: 0 0 10px 20px; color: #4a5160; line-height: 1.7; }
.cs-page .answer-card li { margin-bottom: 4px; }
.cs-page section.answer-card > details { border-bottom: 1px solid #eef0f4; padding: 10px 0; }
.cs-page section.answer-card > details > summary { cursor: pointer; font-weight: 600; color: #2d3748; min-height: 32px; }
.cs-page section.answer-card > details > p { margin: 8px 0 0; }
.cs-page .cs-snippet { background: #f8f7ff; border-left: 4px solid var(--cs-accent); padding: 12px 14px; border-radius: 0 10px 10px 0; }

@media (max-width: 520px) {
    .clue-sheet { padding: 18px 14px 14px 22px; border-radius: 12px; }
    .cs-tile { width: 36px; height: 40px; font-size: 1.15rem; }
    .cs-word { gap: 4px; }
    .cs-hint .cs-hint-body { padding-left: 14px; }
    .cs-parse li { grid-template-columns: 1fr; gap: 0; }
    .cs-archive .cs-arch-clue { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .cs-clue .seg, .cs-tile, .cs-solution { transition: none; animation: none; }
}

/* Tile letters live in data-l (not text) so the hidden answer isn't duplicated as invisible copy. */
.cs-tile::after { content: attr(data-l); }
