/* Layout concept: a cyanotype plate. The chart is drawn like a technical blueprint;
   the page around it stays quiet so the tool and its numbers carry the identity. */
:root {
  --bg: #eef3f7;          /* cool print paper */
  --surface: #ffffff;
  --ink: #0f2c4c;         /* prussian blue */
  --ink-2: #3a5878;       /* softer ink for secondary text */
  --line: #a9bccf;        /* drafting lines */
  --hair: #d5e0ea;        /* faint rules */
  --accent: #d4553a;      /* coral: selection and highlights only */
  --accent-soft: #f6ddd5;
  --node: #ffffff;

  --f-display: "Gloock", "Georgia", "Times New Roman", serif;
  --f-body: "Instrument Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --step--1: 0.8125rem;
  --step-0: 1rem;
  --step-1: 1.1875rem;
  --step-2: 1.5rem;
  --step-3: 2rem;
  --step-4: clamp(2.1rem, 4.4vw, 3.1rem);

  --radius: 6px;
  --gutter-l: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c2440; --surface: #10304f; --ink: #e8f0f7; --ink-2: #a8bfd4;
    --line: #3f6286; --hair: #1c3d5f; --accent: #ff8a6b; --accent-soft: #4a2e33; --node: #0c2440;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c2440; --surface: #10304f; --ink: #e8f0f7; --ink-2: #a8bfd4;
  --line: #3f6286; --hair: #1c3d5f; --accent: #ff8a6b; --accent-soft: #4a2e33; --node: #0c2440;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: var(--step-0);
  line-height: 1.6;
}
a { color: var(--ink); text-decoration-color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding-left: var(--gutter-l);
  padding-right: var(--gutter-r);
}

/* Header ------------------------------------------------------------- */
.site-header { border-bottom: 1px solid var(--hair); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-block: 14px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-family: var(--f-display); font-size: var(--step-1); }
.brand svg { flex: none; }
.site-nav { display: flex; gap: 18px; flex-wrap: wrap; font-size: var(--step--1); }
.site-nav a { text-decoration: none; color: var(--ink-2); }
.site-nav a:hover { color: var(--accent); }

/* Tool --------------------------------------------------------------- */
.tool { padding-block: 32px 8px; }
.tool-head { display: grid; gap: 20px; align-items: end; }
@media (min-width: 900px) { .tool-head { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); } }
h1 { font-family: var(--f-display); font-weight: 400; font-size: var(--step-4); line-height: 1.08; margin: 0 0 10px; text-wrap: balance; letter-spacing: -0.01em; }
.lede { margin: 0; color: var(--ink-2); max-width: 46ch; }

.date-form { background: var(--surface); border: 1px solid var(--hair); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; }
.fields { display: grid; grid-template-columns: 0.8fr 1.4fr 1fr; gap: 10px; }
.field { display: grid; gap: 4px; min-width: 0; }
.field label, .eyebrow { font-family: var(--f-mono); font-size: 0.6875rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); }
.field input, .field select {
  width: 100%; min-width: 0; font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 4px; padding: 10px 10px; font-variant-numeric: tabular-nums;
}
.field input:focus, .field select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.form-row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.form-row .field { flex: 1 1 180px; }
.btn {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 4px; padding: 11px 18px;
  border: 1px solid var(--ink); background: var(--ink); color: var(--bg); min-height: 44px;
}
.btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.ghost:hover { color: #fff; }
.form-error { color: var(--accent); font-size: var(--step--1); margin: 0; min-height: 1.2em; }

.example-note { font-family: var(--f-mono); font-size: var(--step--1); color: var(--ink-2); margin: 18px 0 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.example-note .tag { border: 1px solid var(--line); border-radius: 3px; padding: 1px 6px; text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.6875rem; }

/* Result ------------------------------------------------------------- */
.result { display: grid; gap: 20px; margin-top: 14px; }
@media (min-width: 960px) { .result { grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr); align-items: start; } }
.chart-box { min-width: 0; }
#chart { width: 100%; height: auto; display: block; max-width: 640px; margin: 0 auto; }

/* SVG chart styles */
.c-ring { fill: none; stroke: var(--line); stroke-width: 1; }
.c-tick { stroke: var(--line); stroke-width: 1; }
.c-tick.decade { stroke: var(--ink-2); stroke-width: 1.5; }
.c-tick.now { stroke: var(--accent); stroke-width: 3; }
.c-age { fill: var(--ink-2); font-family: var(--f-mono); font-size: 11px; }
.c-age.now { fill: var(--accent); font-weight: 600; }
.c-shape { fill: none; stroke: var(--ink-2); stroke-width: 1.4; }
.c-axis { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 4; }
.c-diag { stroke: var(--line); stroke-width: 1; }
.c-lovemoney { stroke: var(--ink-2); stroke-width: 1.2; stroke-dasharray: 6 4; }
.c-link { stroke: var(--accent); stroke-width: 1.6; opacity: 0.85; }
.c-sym { fill: var(--ink-2); font-family: var(--f-body); font-size: 12px; font-weight: 600; }
.node { cursor: pointer; }
.node circle.hit { fill: transparent; stroke: none; }
.node circle:not(.hit) { fill: var(--node); stroke: var(--ink); stroke-width: 1.4; transition: stroke 0.15s, fill 0.15s; }
.node text { fill: var(--ink); font-family: var(--f-mono); font-weight: 600; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.node.main circle:not(.hit) { fill: var(--ink); }
.node.main text { fill: var(--bg); }
.node.center circle:not(.hit) { stroke-width: 2.5; }
.node.minor circle:not(.hit) { stroke: var(--line); }
.node:hover circle:not(.hit), .node:focus-visible circle:not(.hit) { stroke: var(--accent); }
.node:focus { outline: none; }
.node.input circle:not(.hit) { stroke: var(--accent); stroke-width: 2.4; stroke-dasharray: 3 2; }
.node.selected circle:not(.hit) { fill: var(--accent); stroke: var(--accent); }
.node.selected text { fill: #fff; }

/* Detail panel */
.panel { background: var(--surface); border: 1px solid var(--hair); border-radius: var(--radius); padding: 20px; display: grid; gap: 12px; min-width: 0; }
@media (min-width: 960px) { .panel { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 16px); } }
.panel-number { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.panel-number .big { font-family: var(--f-display); font-size: 3.4rem; line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums; }
.panel-number .arcana { font-family: var(--f-display); font-size: var(--step-2); line-height: 1.1; }
.panel h2 { font-family: var(--f-body); font-size: var(--step-1); font-weight: 600; margin: 0; line-height: 1.3; }
.panel p { margin: 0; }
.keywords { color: var(--ink-2); font-size: var(--step--1); }
.math {
  font-family: var(--f-mono); font-size: var(--step--1); background: var(--bg); border: 1px dashed var(--line);
  border-radius: 4px; padding: 10px 12px; overflow-wrap: anywhere; line-height: 1.55;
}
.math b { color: var(--accent); font-weight: 600; }
.panel .more { font-weight: 600; font-size: var(--step--1); }
.panel-hint { font-size: var(--step--1); color: var(--ink-2); }

/* Actions */
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.actions .status { font-size: var(--step--1); color: var(--ink-2); align-self: center; }

/* Key numbers */
.keys { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0; margin-top: 28px; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--hair); }
.key { all: unset; box-sizing: border-box; cursor: pointer; padding: 14px 14px 16px; display: grid; gap: 4px; border-right: 1px solid var(--hair); min-width: 0; }
.key:last-child { border-right: 0; }
.key:hover .key-val, .key:focus-visible .key-val { color: var(--accent); }
.key:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.key-val { font-family: var(--f-mono); font-size: var(--step-2); font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.key-sub { font-size: var(--step--1); color: var(--ink-2); }

/* Ad placement previews */
.ad-slot { margin-block: 28px; min-height: 100px; border: 1px dashed var(--line); border-radius: var(--radius); display: grid; place-items: center; color: var(--ink-2); font-family: var(--f-mono); font-size: 0.6875rem; letter-spacing: 0.08em; text-transform: uppercase; text-align: center; padding: 12px; }

/* Data sections */
.data-sections { display: grid; gap: 36px; margin-top: 8px; }
.data-sections > section, .result > *, .tool-head > * { min-width: 0; }
@media (min-width: 960px) { .data-sections { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .data-sections .wide { grid-column: 1 / -1; } }
.data-sections h2, .content h2 { font-family: var(--f-display); font-weight: 400; font-size: var(--step-3); line-height: 1.15; margin: 0 0 6px; text-wrap: balance; }
.section-sub { color: var(--ink-2); margin: 0 0 14px; font-size: var(--step--1); max-width: 62ch; }
.scroll-x { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: var(--step--1); }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--hair); vertical-align: top; }
th { font-family: var(--f-mono); font-weight: 500; font-size: 0.6875rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); }
td.num { font-family: var(--f-mono); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--accent-soft); }
tr.total td { border-top: 1px solid var(--ink); font-weight: 600; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; vertical-align: middle; }

/* Age map */
.now-box { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; border: 1px solid var(--accent); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 14px; background: var(--surface); }
.now-box .big { font-family: var(--f-display); font-size: 2.4rem; line-height: 1; color: var(--accent); }
.agegrid { display: grid; gap: 4px; min-width: 520px; }
.agerow { display: grid; grid-template-columns: 64px repeat(8, minmax(0, 1fr)); gap: 4px; align-items: stretch; }
.agerow .decade { font-family: var(--f-mono); font-size: 0.6875rem; color: var(--ink-2); align-self: center; }
.agecell { border: 1px solid var(--hair); border-radius: 3px; padding: 4px 2px; text-align: center; background: var(--surface); }
.agecell .v { font-family: var(--f-mono); font-weight: 600; font-variant-numeric: tabular-nums; display: block; }
.agecell .a { font-size: 0.625rem; color: var(--ink-2); display: block; font-variant-numeric: tabular-nums; }
.agecell.corner { border-color: var(--ink-2); }
.agecell.now { border-color: var(--accent); background: var(--accent-soft); }

/* Content ------------------------------------------------------------ */
.content { padding-block: 24px 48px; border-top: 1px solid var(--hair); margin-top: 40px; }
.content .cols { display: grid; gap: 40px; }
@media (min-width: 960px) { .content .cols:not(.single) { grid-template-columns: minmax(0, 1fr) 300px; } }
.prose { max-width: 68ch; min-width: 0; }
.prose p, .prose li { margin: 0 0 12px; }
.prose section { margin-bottom: 36px; }
.worked { font-family: var(--f-mono); font-size: var(--step--1); background: var(--surface); border-left: 3px solid var(--accent); padding: 12px 14px; margin: 12px 0; display: grid; gap: 4px; overflow-x: auto; }
.positions { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.positions li { margin: 0; padding-left: 14px; border-left: 1px solid var(--line); }
.positions b { display: block; }
details { border-bottom: 1px solid var(--hair); padding-block: 12px; }
summary { cursor: pointer; font-weight: 600; }
details p { margin: 8px 0 0; color: var(--ink-2); }
.tools-aside { display: grid; gap: 12px; align-content: start; }
.tool-card { display: grid; gap: 4px; padding: 14px 16px; border: 1px solid var(--hair); border-radius: var(--radius); background: var(--surface); text-decoration: none; }
.tool-card b { font-weight: 600; }
.tool-card span { color: var(--ink-2); font-size: var(--step--1); }
.tool-card:hover { border-color: var(--accent); }

/* Footer */
.site-footer { border-top: 1px solid var(--hair); font-size: var(--step--1); color: var(--ink-2); }
.site-footer .wrap { padding-block: 24px 32px; display: grid; gap: 10px; }
.site-footer nav { display: flex; gap: 16px; flex-wrap: wrap; }
.site-footer a { color: var(--ink-2); }

/* Image modal */
.modal { position: fixed; inset: 0; background: rgba(8, 20, 36, 0.72); display: grid; place-items: center; z-index: 50;
  padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
.modal-inner { background: var(--surface); border-radius: var(--radius); padding: 16px; max-width: 560px; width: 100%; display: grid; gap: 12px; max-height: 100%; overflow: auto; }
.modal-inner img { width: 100%; border: 1px solid var(--hair); }
.modal-inner p { margin: 0; font-size: var(--step--1); color: var(--ink-2); }

@media (max-width: 520px) {
  .fields { grid-template-columns: 0.8fr 1.3fr 1fr; gap: 8px; }
  .panel-number .big { font-size: 2.8rem; }
  .key { border-right: 0; border-bottom: 1px solid var(--hair); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
.prose section { scroll-margin-top: 16px; }
.crumbs { font-size: var(--step--1); color: var(--ink-2); margin: 24px 0 8px; }
.crumbs a { color: var(--ink-2); }
.prose h1 { margin-top: 8px; }
.prose h2 { font-size: var(--step-2); margin-top: 28px; }
