/* Almanac & Coins — night journal. Tokens from DESIGN.md. */

:root {
  --night: #14121A;
  --night-raised: #1D1B26;
  --night-inset: #0E0C12;
  --paper: #EBE4D4;
  --paper-soft: #F3EEE3;
  --hairline: #2E2B36;
  --hairline-paper: #D7CFBE;
  --gold: #C4A36A;
  --gold-soft: #D4BC8C;
  --gold-deep: #8A6A3A;
  --on-gold: #14121A;
  --ivory: #EFE8D8;
  --ivory-soft: #C4BEB2;
  --mute: #8E8890;
  --ink: #1C1914;
  --ink-soft: #5C564C;
  --error: #C45C4A;
  --success: #7A9A78;
  --focus: #D4BC8C;
  --font-serif: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", Palatino, "Times New Roman", serif;
  --font-sans: "Source Sans 3", ui-sans-serif, system-ui, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-zh: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", "SimSun", "Hiragino Mincho ProN", serif;
  --radius-card: 16px;
  --radius-input: 12px;
  --radius-pill: 999px;
  --space: 8px;
  --content: 1120px;
  --measure: 40rem;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--night);
  color: var(--ivory);
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 400;
  line-height: 1.55;
  min-height: 100vh;
}

img, svg { max-width: 100%; }

a {
  color: var(--ivory);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover { color: var(--gold-soft); }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -40px;
  background: var(--gold);
  color: var(--on-gold);
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  z-index: 20;
  font-family: var(--font-sans);
  font-size: 15px;
}

.skip-link:focus { top: 12px; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--night);
  border-bottom: 1px solid transparent;
}

.header-inner,
.section-inner,
.footer-inner {
  width: min(var(--content), calc(100% - 48px));
  margin: 0 auto;
}

.header-inner {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.wordmark {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 400;
  color: var(--ivory);
  text-decoration: none;
  letter-spacing: 0;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.nav a {
  color: var(--ivory-soft);
  text-decoration: none;
  padding: 8px 0;
  border-bottom: 1px solid transparent;
}

.nav a:hover,
.nav a[aria-current="true"] {
  color: var(--ivory);
  border-bottom-color: var(--gold);
}

.hero {
  padding: 80px 0 40px;
}

.eyebrow {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mute);
  margin: 0 0 12px;
}

.display {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(32px, 5vw, 48px);
  line-height: 1.15;
  margin: 0 0 16px;
}

.lede {
  max-width: var(--measure);
  color: var(--ivory-soft);
  margin: 0;
}

section.block {
  padding: 96px 0;
}

h2.section-title {
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 400;
  line-height: 1.2;
  margin: 0 0 32px;
}

h3 {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 400;
  line-height: 1.25;
  margin: 0 0 12px;
}

.measure { max-width: var(--measure); }

/* Almanac paper card */
.almanac-card {
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--radius-card);
  padding: 32px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.almanac-card .eyebrow { color: var(--gold-deep); }

.almanac-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--hairline-paper);
  margin-bottom: 24px;
}

.greg-date {
  font-size: 28px;
  margin: 0;
  line-height: 1.2;
}

.tz-note,
.meta-line {
  font-family: var(--font-sans);
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  margin: 8px 0 0;
}

label.date-label {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--ink-soft);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

input[type="date"] {
  font-family: var(--font-sans);
  font-size: 15px;
  height: 44px;
  padding: 0 12px;
  border-radius: var(--radius-input);
  border: 1px solid var(--hairline-paper);
  background: var(--paper-soft);
  color: var(--ink);
}

.lunar-line {
  font-family: var(--font-zh);
  font-size: 28px;
  letter-spacing: 0.04em;
  margin: 0 0 8px;
}

.term-row {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr 1fr;
  margin: 24px 0;
}

.term-box {
  background: var(--paper-soft);
  border-radius: 12px;
  padding: 16px 20px;
}

.term-box .name {
  font-size: 22px;
  margin: 0 0 4px;
}

.term-zh {
  font-family: var(--font-zh);
}

.season-note {
  max-width: var(--measure);
  margin: 0;
}

.season-note-source {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--ink-soft);
  margin: 12px 0 0;
}

.almanac-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.upcoming {
  margin-top: 32px;
}

.upcoming ol {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: grid;
  gap: 8px;
}

.upcoming li {
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--ink-soft);
  padding: 8px 0;
  border-bottom: 1px solid var(--hairline-paper);
}

.upcoming li strong {
  color: var(--ink);
  font-weight: 500;
}

/* Buttons */
button {
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.01em;
  height: 44px;
  padding: 0 20px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  cursor: pointer;
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.button-primary {
  background: var(--gold);
  color: var(--on-gold);
}

.button-primary:hover:not(:disabled) {
  background: var(--gold-soft);
}

.button-primary:active:not(:disabled) {
  background: var(--gold-deep);
  color: var(--ivory);
}

.button-ghost {
  background: transparent;
  color: var(--ivory);
  border-color: var(--hairline);
}

.button-ghost:hover:not(:disabled) {
  border-color: var(--gold-soft);
}

.button-paper {
  background: var(--night);
  color: var(--paper);
}

.button-paper:hover:not(:disabled) {
  background: #221f2a;
}

/* Cast panel */
.cast-panel,
.raised-card,
.pricing-note,
.form-card,
.index-panel,
.journal-card {
  background: var(--night-raised);
  border-radius: var(--radius-card);
  padding: 32px;
}

.question-box {
  width: 100%;
  min-height: 120px;
  resize: vertical;
  background: var(--night-inset);
  color: var(--ivory);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-input);
  padding: 16px;
  font-family: var(--font-serif);
  font-size: 18px;
  line-height: 1.55;
}

.hint {
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--ivory-soft);
  margin: 8px 0 24px;
}

.coin-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin: 24px 0;
}

.coin-step {
  background: var(--night-inset);
  border-radius: 12px;
  min-height: 96px;
  padding: 12px 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.coin-step .n {
  font-family: var(--font-sans);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mute);
}

.coin-disc {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--hairline);
  background: var(--night-raised);
  transition: transform 0.35s ease, background 0.35s ease, border-color 0.35s ease;
}

.coin-step.filled .coin-disc {
  background: var(--ivory);
  border-color: var(--ivory);
}

.coin-step.changing .coin-disc {
  background: var(--gold);
  border-color: var(--gold);
}

.coin-step.tossing .coin-disc {
  transform: rotateY(180deg);
}

.coin-step .label {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--ivory);
}

.coin-step.changing .label { color: var(--gold); }

.cast-actions,
.result-actions,
.journal-actions,
.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.status {
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--ivory-soft);
  margin: 16px 0 0;
}

.status.error { color: var(--error); }
.status.success { color: var(--success); }

.manual-box {
  margin-top: 24px;
  border-top: 1px solid var(--hairline);
  padding-top: 16px;
}

.manual-box summary {
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--ivory-soft);
  cursor: pointer;
}

.manual-box input[type="text"] {
  margin-top: 12px;
  width: min(100%, 28rem);
  height: 44px;
  padding: 0 14px;
  border-radius: var(--radius-input);
  border: 1px solid var(--hairline);
  background: var(--night-inset);
  color: var(--ivory);
  font-family: var(--font-sans);
  font-size: 15px;
}

/* Reading */
.reading {
  margin-top: 40px;
  display: grid;
  gap: 24px;
}

.hex-pair {
  display: grid;
  gap: 24px;
  grid-template-columns: 1fr 1fr;
}

.hex-card {
  background: var(--night-inset);
  border-radius: 16px;
  padding: 24px;
}

.hex-zh {
  font-family: var(--font-zh);
  font-size: 32px;
  letter-spacing: 0.04em;
  margin: 0 8px 0 0;
}

.hex-meta {
  font-family: var(--font-sans);
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--ivory-soft);
}

.hex-gloss {
  margin: 8px 0 16px;
}

.hex-figure {
  width: 112px;
  margin: 8px 0 0;
}

.yao {
  height: 10px;
  margin: 8px 0;
  width: 100%;
}

.yao.yang {
  background: var(--ivory);
  border-radius: 2px;
}

.yao.yin {
  display: flex;
  justify-content: space-between;
}

.yao.yin span {
  display: block;
  width: 42%;
  background: var(--ivory);
  border-radius: 2px;
}

.yao.changing.yang { background: var(--gold); }
.yao.changing.yin span { background: var(--gold); }

.legge,
.reflection {
  max-width: var(--measure);
}

.legge p,
.reflection p {
  margin: 0 0 12px;
}

.attr,
.fine {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--mute);
}

.line-excerpt {
  margin: 0 0 8px;
}

/* Index */
.index-tools {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.index-tools input {
  flex: 1;
  height: 44px;
  padding: 0 14px;
  border-radius: var(--radius-input);
  border: 1px solid var(--hairline);
  background: var(--night-inset);
  color: var(--ivory);
  font-family: var(--font-sans);
  font-size: 15px;
}

.hex-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.hex-tile {
  background: var(--night-inset);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 16px 12px;
  color: inherit;
  text-align: left;
  height: auto;
  cursor: pointer;
  font-weight: 400;
}

.hex-tile:hover,
.hex-tile[aria-pressed="true"] {
  border-color: var(--gold);
}

.hex-tile .zh {
  font-family: var(--font-zh);
  font-size: 22px;
  display: block;
}

.hex-tile .sub {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--ivory-soft);
}

.index-detail {
  margin-top: 24px;
}

/* Pricing & form */
.pricing-list {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
}

.pricing-list li {
  padding: 12px 0;
  border-bottom: 1px solid var(--hairline);
}

.pay-note {
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--ivory-soft);
}

.form-card input[type="email"],
.form-card input[type="text"] {
  width: min(100%, 28rem);
  height: 48px;
  padding: 0 16px;
  border-radius: var(--radius-input);
  border: 1px solid var(--hairline);
  background: var(--night-raised);
  color: var(--ivory);
  font-family: var(--font-sans);
  font-size: 15px;
}

.form-card input::placeholder { color: var(--mute); }

.form-card .field {
  margin: 0 0 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-card label {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--ivory-soft);
}

/* Journal */
.journal-list {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
  display: grid;
  gap: 12px;
}

.journal-item {
  background: #e8e0ce;
  color: var(--ink);
  border-radius: 12px;
  padding: 16px 20px;
}

.journal-item p { margin: 0 0 6px; }

.journal-item .when {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--ink-soft);
}

/* Footer */
.site-footer {
  padding: 64px 0 48px;
  border-top: 1px solid var(--hairline);
}

.disclaimer {
  max-width: 44rem;
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.5;
  color: var(--ivory-soft);
  margin: 0 0 24px;
}

.footer-meta {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--mute);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  align-items: center;
}

.reviewer {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--mute);
}

.reviewer input {
  width: 16px;
  height: 16px;
  accent-color: var(--gold);
}

[hidden] { display: none !important; }

@media (max-width: 1023px) {
  .hex-pair,
  .term-row { grid-template-columns: 1fr; }
}

@media (max-width: 767px) {
  .header-inner,
  .section-inner,
  .footer-inner {
    width: min(var(--content), calc(100% - 32px));
  }

  .header-inner {
    flex-direction: column;
    align-items: flex-start;
    padding: 12px 0;
    min-height: 0;
    gap: 8px;
  }

  .hero { padding-top: 48px; }
  section.block { padding: 80px 0; }

  .almanac-card,
  .cast-panel,
  .raised-card,
  .pricing-note,
  .form-card,
  .index-panel {
    padding: 24px;
  }

  .coin-row {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .button-primary,
  .button-ghost,
  .button-paper {
    width: 100%;
  }

  .cast-actions,
  .result-actions,
  .almanac-actions,
  .form-row {
    width: 100%;
  }
}
