/* I Ching oracle – shared stylesheet for all language folders. No external resources. */

:root {
    --paper: #f7f3ea;
    --paper-2: #efe8d9;
    --ink: #1f1a17;
    --ink-2: #4a423b;
    --muted: #7a7067;
    --line: #d9d0bf;
    --gold: #c9a227;
    --gold-2: #e6c75a;
    --seal: #a0322d;
    --focus: #fff6d6;
    --radius: 12px;
    --max: 780px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --serif: Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    overflow-x: hidden; /* full-bleed sections use 100vw */
    font-family: var(--font);
    font-size: 1.0625rem;
    line-height: 1.65;
    color: var(--ink);
    background: var(--paper);
}

h1, h2, h3, h4 { font-family: var(--serif); line-height: 1.25; letter-spacing: -0.01em; margin: 1.6em 0 0.5em; }
h1 { font-size: clamp(1.8rem, 4.5vw, 2.5rem); margin-top: 0.5em; }
h2 { font-size: clamp(1.4rem, 3vw, 1.8rem); }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.05rem; margin-top: 1.2em; }
h3 small { font-family: var(--font); font-size: 0.8rem; color: var(--muted); font-weight: 400; margin-left: 0.5em; }

p { margin: 0 0 1em; }
a { color: var(--seal); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--ink); }

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 16px 48px; }

.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: #fff; padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; top: 8px; }

/* Header / footer */
.top { border-bottom: 1px solid var(--line); background: var(--paper-2); }
.top-nav { max-width: var(--max); margin: 0 auto; padding: 10px 16px; display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.top-nav a { text-decoration: none; color: var(--ink-2); font-size: 0.95rem; }
.top-nav .brand { font-family: var(--serif); font-size: 1.55rem; font-weight: 600; color: var(--ink); margin-right: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.lang-select select {
    appearance: none; -webkit-appearance: none; font: inherit; font-size: 0.85rem; color: var(--ink-2);
    padding: 4px 26px 4px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fffdf8;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%234a423b' stroke-width='1.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 9px center; cursor: pointer;
}
.lang-select select:hover { border-color: var(--gold); }
.lang-select select:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.foot { border-top: 1px solid var(--line); background: var(--paper-2); color: var(--muted); font-size: 0.85rem; text-align: center; padding: 20px 16px 28px; }
.foot p { margin: 0.3em 0; }

.lead { font-size: 1.15rem; color: var(--ink-2); }
.kicker { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.75rem; color: var(--muted); margin: 0; }
.hanzi { font-family: var(--serif); color: var(--ink-2); font-size: 1.1rem; margin: 0 0 0.6em; }
.notice { background: var(--focus); border: 1px solid var(--gold-2); border-radius: var(--radius); padding: 10px 14px; font-size: 0.95rem; }

/* Buttons */
.btn {
    display: inline-block; padding: 12px 22px; border-radius: 999px; border: 1px solid var(--ink);
    background: transparent; color: var(--ink); font: inherit; font-weight: 600; font-size: 1rem;
    cursor: pointer; text-decoration: none; transition: background 0.2s, color 0.2s, transform 0.1s;
}
.btn:hover { background: var(--ink); color: var(--paper); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--gold); border-color: var(--gold); color: var(--ink); }
.btn-primary:hover { background: var(--gold-2); border-color: var(--gold-2); color: var(--ink); }
.btn[disabled] { opacity: 0.55; cursor: wait; }

/* Hexagram SVG */
.hex { display: block; fill: var(--ink); }
.hex .mark { fill: var(--paper); stroke: var(--seal); stroke-width: 2.5; }
.hex-lg { width: 150px; }
.hex-md { width: 96px; }
.hex-sm { width: 64px; }
.hex-build { width: 150px; }

/* Heading with (i) badge: the whole heading toggles a short explanation */
.info { display: block; }
.info summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; margin: 1.6em 0 0.5em; }
.info summary::-webkit-details-marker { display: none; }
.info summary h2, .info summary h3 { margin: 0; }
.reading-head .info summary { margin-top: 0.8em; }
.info .i {
    flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
    width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--muted); color: var(--muted);
    font-family: var(--serif); font-style: italic; font-weight: 700; font-size: 0.8rem; line-height: 1;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.info summary:hover .i, .info[open] .i { background: var(--gold); border-color: var(--gold); color: var(--ink); }
.info summary:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 6px; }
.info p { margin: 0 0 12px; padding: 10px 14px; font-size: 0.92rem; line-height: 1.55; color: var(--ink-2); background: var(--focus); border: 1px solid var(--gold-2); border-radius: 8px; }
.info-more { white-space: nowrap; }

/* Guide page */
.toc { margin: 8px 0 24px; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: #fffdf8; }
.toc ol { margin: 0; padding-left: 1.3em; columns: 2; column-gap: 24px; font-size: 0.95rem; }
.toc li { break-inside: avoid; margin: 2px 0; }
.guide section { scroll-margin-top: 16px; }
.guide ul { padding-left: 1.3em; }
.guide li { margin-bottom: 0.45em; }
.guide .cta .btn { margin: 4px; }
@media (max-width: 600px) { .toc ol { columns: 1; } }

/* Breadcrumbs */
.crumbs ol { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-wrap: wrap; gap: 4px; font-size: 0.85rem; color: var(--muted); }
.crumbs li + li::before { content: "›"; margin: 0 6px; }
.crumbs a { color: var(--muted); }

/* ------------------------------------------------------------------ */
/* Oracle                                                              */
/* ------------------------------------------------------------------ */

/* "In short" block (direct answers for search / AI overviews) */
.summary-box { margin: 24px 0 8px; padding: 0 20px; border: 1px solid transparent; border-left: 4px solid transparent; border-radius: var(--radius); background: transparent; }
.summary-box[open] { border-color: var(--line); border-left-color: var(--gold); background: #fffdf8; }
.summary-box summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; padding: 14px 0; }
.summary-box summary::-webkit-details-marker { display: none; }
.summary-box summary::after { content: ""; width: 0.6rem; height: 0.6rem; margin-left: auto; border-right: 2px solid var(--ink); border-bottom: 2px solid var(--ink); transform: rotate(45deg); transition: transform 0.25s; }
.summary-box[open] summary::after { transform: rotate(225deg); }
.summary-box[open] summary { border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.summary-box h2 { margin: 0; font-size: 1.25rem; }
.summary-box > p:last-of-type, .summary-box .facts { margin-bottom: 16px; }
.summary-box h3 { margin: 1em 0 0.4em; font-size: 1.05rem; font-family: var(--font); }
.summary-box ol { padding-left: 1.3em; margin: 0 0 1em; }
.summary-box li { margin-bottom: 0.35em; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px 18px; margin: 0 0 1em; }
.facts div { display: flex; gap: 6px; font-size: 0.95rem; border-bottom: 1px dotted var(--line); padding: 3px 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }

.oracle {
    margin: 28px 0 40px; padding: 24px 18px 28px; border: 1px solid var(--line); border-radius: var(--radius);
    background: #fffdf8; text-align: center;
}
.method { border: 0; padding: 0; margin: 0 0 18px; display: flex; justify-content: center; gap: 18px; flex-wrap: wrap; }
.method legend { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); width: 100%; margin-bottom: 6px; }
.method label { cursor: pointer; }
.method[aria-disabled="true"] { opacity: 0.6; pointer-events: none; }

.stage { min-height: 110px; }

/* Coins */
.coins { display: flex; justify-content: center; gap: 22px; margin: 6px 0 12px; min-height: 76px; }
.coin { width: 72px; height: 72px; perspective: 600px; }
.coin-inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transform: rotateY(0deg); }
.coin.flip-head .coin-inner { animation: flip-head 1s cubic-bezier(0.2, 0.7, 0.3, 1) forwards; }
.coin.flip-tail .coin-inner { animation: flip-tail 1s cubic-bezier(0.2, 0.7, 0.3, 1) forwards; }
.coin.is-tail .coin-inner { transform: rotateY(180deg); }
.coin.flip-head, .coin.flip-tail { animation: toss 1s ease-out; }
.coin:nth-child(2).flip-head, .coin:nth-child(2).flip-tail { animation-delay: 0.08s; }
.coin:nth-child(3).flip-head, .coin:nth-child(3).flip-tail { animation-delay: 0.16s; }

.face {
    position: absolute; inset: 0; border-radius: 50%; backface-visibility: hidden;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    font-family: var(--serif); font-weight: 700; color: #5a3f05; box-shadow: inset 0 0 0 3px rgba(90, 63, 5, 0.25), 0 3px 6px rgba(0, 0, 0, 0.18);
}
.face::before { content: ""; position: absolute; top: 50%; left: 50%; width: 16px; height: 16px; transform: translate(-50%, -50%); background: var(--paper); border: 2px solid rgba(90, 63, 5, 0.35); }
.face .f-label { font-size: 0.62rem; letter-spacing: 0.04em; text-transform: uppercase; margin-top: 30px; }
.face .f-value { position: absolute; top: 7px; font-size: 0.85rem; }
.face.front { background: radial-gradient(circle at 35% 30%, #ffe89a, #d9a92b 60%, #b88a14); }
.face.back { background: radial-gradient(circle at 35% 30%, #f1efe6, #c9c3b4 60%, #a9a292); color: #3d3a33; transform: rotateY(180deg); box-shadow: inset 0 0 0 3px rgba(60, 55, 45, 0.25), 0 3px 6px rgba(0, 0, 0, 0.18); }
.face.back::before { border-color: rgba(60, 55, 45, 0.35); }
.coins.is-yarrow .face::before { display: none; }
.coins.is-yarrow .face .f-label { margin-top: 0; font-size: 1.5rem; }
.coins.is-yarrow .face .f-value { display: none; }

@keyframes flip-head { 0% { transform: rotateY(0deg); } 100% { transform: rotateY(1440deg); } }
@keyframes flip-tail { 0% { transform: rotateY(0deg); } 100% { transform: rotateY(1620deg); } }
@keyframes toss {
    0% { transform: translateY(0); }
    35% { transform: translateY(-46px); }
    70% { transform: translateY(0); }
    85% { transform: translateY(-8px); }
    100% { transform: translateY(0); }
}

.status { min-height: 1.6em; margin: 0 0 10px; font-weight: 600; color: var(--ink-2); }
.status-error { color: var(--seal); }

.build { display: flex; justify-content: center; align-items: center; gap: 28px; flex-wrap: wrap; margin: 6px 0 16px; }
.hex-build .slot { fill: var(--line); }
.hex-build .slot-ghost { fill: none; stroke: var(--line); stroke-dasharray: 4 4; }
.hex-build .mark { fill: #fffdf8; }
.cast-lines { list-style: none; padding: 0; margin: 0; text-align: left; font-size: 0.9rem; min-width: 190px; }
.cast-lines:empty { display: none; }
.cast-lines li { display: flex; gap: 8px; align-items: baseline; padding: 2px 0; border-bottom: 1px dotted var(--line); }
.cast-lines .ln { color: var(--muted); min-width: 52px; }
.cast-lines .lv { font-weight: 700; min-width: 14px; }
.cast-lines .lc { color: var(--seal); font-size: 0.8rem; }
.cast-lines .lp { color: var(--muted); font-size: 0.8rem; margin-left: auto; }

/* Once a reading is shown on the home page, the explanatory home texts disappear (same view as the permalink page). */
.has-reading .hero .lead,
.has-reading .summary-box,
.has-reading .how,
.has-reading .trigrams,
.has-reading .source,
.has-reading .faq { display: none; }
.has-reading .oracle { margin-top: 12px; }

/* ------------------------------------------------------------------ */
/* Reading                                                             */
/* ------------------------------------------------------------------ */

.reading { padding-top: 8px; }
.reading-title { margin-top: 0.3em; }
.reading-out { margin-top: 32px; }

/* Cast: hexagram as tall as the six-row line list beside it */
.reading-cast { display: flex; gap: 32px; align-items: stretch; flex-wrap: wrap; margin: 4px 0 8px; }
.reading-cast .hex-lg { height: 198px; width: auto; flex: 0 0 auto; }
.line-list { list-style: none; padding: 0; margin: 0; font-size: 0.95rem; flex: 1 1 240px; max-width: 360px; }
.line-list li { display: flex; gap: 12px; align-items: center; height: 33px; border-bottom: 1px dotted var(--line); }
.line-list li:last-child { border-bottom: 0; }
.line-list .ln { color: var(--muted); min-width: 118px; }
.line-list .lv { font-weight: 700; min-width: 16px; }
.line-list .is-changing .lt { color: var(--seal); font-weight: 600; }

.trigram-pair dl { margin: 0; }
.trigram-pair dt { font-weight: 700; }
.trigram-pair dd { margin: 0 0 0.9em; color: var(--ink-2); }

blockquote { margin: 0 0 1.2em; padding: 10px 16px; border-left: 3px solid var(--gold); background: #fffdf8; font-family: var(--serif); font-size: 1.1rem; }
blockquote p { margin: 0; }
blockquote.focus, .line-texts li.focus { background: var(--focus); border-left-color: var(--seal); }

/* Changing lines: 2px rule across the full viewport width */
.reading .changing { margin-top: 28px; border-top: 2px solid var(--gold); margin-left: calc(50% - 50vw); margin-right: calc(50% - 50vw); padding: 4px calc(50vw - 50%) 0; }
.reading .changing.no-changing { border-top: 0; margin-top: 0; padding-top: 0; }
.rule { color: var(--ink-2); font-size: 0.95rem; padding: 8px 12px; border: 1px dashed var(--line); border-radius: 8px; }
.line-texts { list-style: none; padding: 0; margin: 0 0 1em; }
.line-texts li { padding: 10px 14px; border-left: 3px solid var(--line); margin-bottom: 10px; background: #fffdf8; }
.line-texts h3, .line-texts h4 { margin: 0 0 0.3em; font-size: 1rem; font-family: var(--font); }
.line-texts h4 em { color: var(--seal); font-style: normal; font-weight: 600; }
.line-texts p { margin: 0; }
.line-details summary { cursor: pointer; color: var(--ink-2); margin-bottom: 8px; }

.hex-card { display: flex; gap: 18px; align-items: flex-start; margin: 10px 0 14px; }
.hex-card h4, .hex-card h3 { margin: 0 0 0.3em; }
.hex-card .future { font-style: italic; color: var(--ink-2); }
.hex-cards { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.hex-cards a { display: flex; gap: 12px; align-items: center; text-decoration: none; color: var(--ink); padding: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: #fffdf8; }
.hex-cards a:hover { border-color: var(--gold); }
.hex-cards small { display: block; color: var(--muted); font-size: 0.75rem; }
.hex-cards strong { font-family: var(--serif); font-weight: 600; }

/* Life areas: white band across the full viewport width, content stays aligned with the column */
.life {
    background: #fff;
    margin: 32px calc(50% - 50vw) 8px;
    padding: 10px calc(50vw - 50%) 26px;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}
.life > h2, .life > h3:first-child { margin-top: 0.9em; }
.life h4, .life h3:not(:first-child) { margin-top: 1.3em; color: var(--ink); }
.life p:last-child { margin-bottom: 0; }

.permalink { margin-top: 28px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper-2); }
.permalink h3 { margin-top: 0; }
.permalink-row { display: flex; gap: 8px; flex-wrap: wrap; }
.permalink-row input { flex: 1 1 220px; font: inherit; font-size: 0.9rem; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink-2); min-width: 0; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0 0; }

/* ------------------------------------------------------------------ */
/* Hexagram page / list                                                */
/* ------------------------------------------------------------------ */

.hex-head { text-align: center; padding-bottom: 8px; }
.hex-head .hex { margin: 10px auto 0; }
.prevnext { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 20px 0; font-size: 0.95rem; }
.cta { text-align: center; padding: 24px 16px; border: 1px solid var(--gold-2); border-radius: var(--radius); background: #fffdf8; margin-top: 28px; }
.cta h2 { margin-top: 0; }

.hex-grid { list-style: none; padding: 0; margin: 20px 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.hex-grid a { display: flex; gap: 12px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: #fffdf8; text-decoration: none; color: var(--ink); }
.hex-grid a:hover { border-color: var(--gold); }
.hex-grid .grid-text { display: flex; flex-direction: column; line-height: 1.35; }
.hex-grid .hanzi { font-size: 0.9rem; margin: 0; }
.hex-grid .tri { color: var(--muted); font-size: 0.8rem; }

/* Home sections */
.table-wrap { overflow-x: auto; margin: 0 0 1em; }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
th, td { padding: 8px 10px; border: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: var(--paper-2); font-weight: 600; }

.trigram-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.trigram-grid li { padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: #fffdf8; display: flex; flex-direction: column; }
.tri-symbol { font-size: 1.8rem; line-height: 1; }
.tri-family { color: var(--muted); font-size: 0.85rem; }

.faq-item { border: 1px solid var(--line); border-radius: var(--radius); background: #fffdf8; margin-bottom: 8px; padding: 0 16px; }
.faq-item summary { cursor: pointer; padding: 12px 0; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 12px; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: ""; flex: 0 0 0.55rem; width: 0.55rem; height: 0.55rem; margin-left: auto; border-right: 2px solid var(--ink-2); border-bottom: 2px solid var(--ink-2); transform: rotate(45deg); transition: transform 0.25s; }
.faq-item[open] summary::after { transform: rotate(225deg); }
.faq-item p { padding-bottom: 12px; color: var(--ink-2); }

@media (max-width: 600px) {
    body { font-size: 1rem; line-height: 1.6; }
    h1 { font-size: 1.65rem; }
    h2 { font-size: 1.3rem; }
    h3 { font-size: 1.12rem; }
    .wrap { padding-bottom: 36px; }
    .top-nav { gap: 12px; font-size: 0.9rem; }
    .top-nav .brand { font-size: 1.25rem; }
    .crumbs ol { font-size: 0.78rem; }
    .lead { font-size: 1.05rem; }

    .oracle { padding: 18px 12px 22px; margin: 20px 0 32px; }
    .method { gap: 12px; }
    .coins { gap: 14px; }
    .coin { width: 60px; height: 60px; }
    .build { gap: 16px; }
    .btn { width: 100%; text-align: center; }
    .actions .btn, .permalink-row .btn { width: auto; flex: 1 1 auto; }

    .reading-cast { flex-direction: column; align-items: center; gap: 14px; }
    .reading-cast .hex-lg { height: 150px; }
    .line-list { width: 100%; max-width: 340px; flex: 0 0 auto; font-size: 0.9rem; }
    .line-list li { height: 30px; }
    .line-list .ln { min-width: 104px; }

    blockquote { font-size: 1.02rem; padding: 8px 12px; }
    .hex-card { gap: 12px; }
    .hex-cards { grid-template-columns: 1fr; }
    .hex-grid { grid-template-columns: 1fr; }
    .prevnext { flex-direction: column; }
    .permalink { padding: 12px; }
    .permalink-row input { flex-basis: 100%; }
    .trigram-grid { grid-template-columns: repeat(2, 1fr); }
    .faq-item { padding: 0 12px; }
    .cta { padding: 18px 12px; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .coin.flip-head .coin-inner, .coin.flip-tail .coin-inner, .coin.flip-head, .coin.flip-tail { animation-duration: 0.25s; }
}
