/* ---------------------------------------------------------------
   panchang.hirakonline.com
   Shares the hirakonline app system with Angles / Convene / Puzzles:
   tokens, Source Serif 4 + Inter, sticky 64px header with monogram,
   light / dark / system toggle. Keep tokens in sync with
   ../website/src/styles/global.css and ../puzzles-web/site/styles.css.
   --------------------------------------------------------------- */

:root {
  --bg: #FAFAF7; --bg-elevated: #FFFFFF; --bg-raised: #F2F2EE;
  --border: #E5E5E0; --border-strong: #C8C8C2;
  --text: #1A1A1A; --text-muted: #555550; --text-subtle: #8E8E88;
  --accent: #0F6E56; --accent-bg: #E1F5EE; --accent-contrast: #fff;
  --danger: #a63d2e; --danger-bg: #f7e1dd;
  --radius: 8px; --radius-sm: 4px;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-serif: "Source Serif 4", Georgia, serif;
  --max-width: 1080px;

  /* Timeline (derived from the tokens above) */
  --tl-out: #ECECE7; --tl-day: #FFFFFF; --tl-night: #F2F2EE;
  --tl-ink: #1A1A1A; --tl-line: #8E8E88; --tl-mark: #0F6E56;
  --tl-bad: #a63d2e; --tl-good: #0F6E56;
  --sun: #E9B949; --sun-edge: #C98A1B;

  /* Guidance verdicts: fill / ink */
  --v-excellent: #0F6E56; --v-excellent-ink: #FFFFFF;
  --v-good: #A9DAC6;      --v-good-ink: #0B4F3E;
  --v-mixed: #E6E2D3;     --v-mixed-ink: #555550;
  --v-poor: #F2D3CC;      --v-poor-ink: #8A3125;
  --v-avoid: #a63d2e;     --v-avoid-ink: #FFFFFF;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #161614; --bg-elevated: #1F1F1C; --bg-raised: #252522;
  --border: #33332F; --border-strong: #4D4D48;
  --text: #EDEDE8; --text-muted: #A8A8A2; --text-subtle: #7A7A74;
  --accent: #5DCAA5; --accent-bg: #1A3A30; --accent-contrast: #0b0d10;
  --danger: #e0685b; --danger-bg: #3a1f1b;
  --tl-out: #121210; --tl-day: #24241F; --tl-night: #1A1A17;
  --tl-ink: #EDEDE8; --tl-line: #7A7A74; --tl-mark: #5DCAA5;
  --tl-bad: #e0685b; --tl-good: #5DCAA5;
  --sun: #E2A93F; --sun-edge: #C98A1B;
  --v-excellent: #5DCAA5; --v-excellent-ink: #0b0d10;
  --v-good: #2C5C4C;      --v-good-ink: #CDEFE2;
  --v-mixed: #3A3933;     --v-mixed-ink: #C9C9C2;
  --v-poor: #4A2924;      --v-poor-ink: #F0B4AA;
  --v-avoid: #e0685b;     --v-avoid-ink: #0b0d10;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font-sans); font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
@media (min-width: 600px) { body { font-size: 16px; } }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }
.wrap { max-width: var(--max-width); margin: 0 auto; padding: 1.25rem 1rem 4rem; }

/* ---------- header (same as Convene / Angles / Puzzles) ---------- */
header.site { position: sticky; top: 0; z-index: 50; height: 64px; background: var(--bg); border-bottom: 0.5px solid var(--border); padding-top: env(safe-area-inset-top); box-sizing: content-box; }
header.site .site-inner { max-width: var(--max-width); margin: 0 auto; padding: 0 1rem; height: 100%; display: flex; align-items: center; gap: 0.5rem; }
header.site .header-left { min-width: 0; }
header.site .wordmark { display: flex; align-items: center; gap: 0.45rem; text-decoration: none; color: var(--text); min-width: 0; }
header.site .monogram { display: flex; align-items: center; justify-content: center; flex-shrink: 0; width: 30px; height: 30px; border-radius: 5px;
  background: var(--text); color: var(--bg); font-family: var(--font-serif); font-size: 0.95rem; font-weight: 600; }
header.site .wordmark-text { font-family: var(--font-serif); font-size: 1.25rem; font-weight: 500; letter-spacing: -0.01em; }
header.site .byline { color: var(--text-subtle); font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
header.site .spacer { flex: 1 1 auto; }
header.site .header-right { display: flex; align-items: center; gap: 0.2rem; flex-shrink: 0; }
.icon-btn { display: flex; align-items: center; justify-content: center; flex-shrink: 0; width: 32px; height: 32px; min-height: 0; padding: 0;
  border-radius: var(--radius-sm); background: none; border: none; color: var(--text-muted); cursor: pointer; }
.icon-btn:hover { color: var(--text); background: var(--bg-raised); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
@media (max-width: 480px) { header.site .byline { display: none; } }

footer.site { text-align: center; color: var(--text-subtle); font-size: 0.8rem; padding-top: 1rem; margin-top: 2.5rem; border-top: 0.5px solid var(--border); }
footer.site a { color: var(--accent); text-decoration: none; }
footer.site a:hover { text-decoration: underline; }

/* ---------- intro ---------- */
.page-intro { font-family: var(--font-serif); font-weight: 500; font-size: 1.4rem; letter-spacing: -0.01em; line-height: 1.3; margin: 1.25rem 0 0.4rem; }
@media (min-width: 600px) { .page-intro { font-size: 1.65rem; } }
.lede { color: var(--text-muted); margin-bottom: 1.25rem; }
.label-ui { font-family: var(--font-sans); font-size: 11px; font-weight: 500; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-subtle); }

/* ---------- controls ---------- */
.controls { display: grid; gap: 0.6rem; }
.row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
button, input, select {
  font: inherit; font-size: 0.95rem; color: var(--text); background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; min-height: 40px;
}
button { cursor: pointer; white-space: nowrap; }
button:hover { background: var(--bg-raised); }
button.primary { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
input:focus-visible, button:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.search { position: relative; flex: 1 1 240px; }
.search input { width: 100%; }
#results {
  position: absolute; z-index: 5; left: 0; right: 0; top: 100%; margin: 4px 0 0; padding: 4px; list-style: none;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}
#results li { padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer; font-size: 0.88rem; }
#results li:hover { background: var(--bg-raised); }
.place, .status { font-size: 0.85rem; color: var(--text-subtle); }
.status:empty, .place:empty { display: none; }
.status.error { color: var(--danger); }

/* ---------- results ---------- */
#out { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; margin-top: 1.5rem; padding-top: 1.5rem; border-top: 0.5px solid var(--border); }

.headline .label-ui { display: block; margin-bottom: 0.4rem; }
.headline h2 { font-family: var(--font-serif); font-weight: 600; font-size: clamp(1.6rem, 3.4vw, 2.2rem); letter-spacing: -0.015em; line-height: 1.15; }
.headline h2 .accent { color: var(--accent); }
.headline p { color: var(--text-muted); margin-top: 0.35rem; }

.panel { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; min-width: 0; }
.panel > .label-ui { margin-bottom: 0.6rem; }

dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0 2rem; margin: 0; }
dl > div { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: 0.5rem 0; border-bottom: 0.5px solid var(--border); }
dt { color: var(--text-muted); font-size: 0.9rem; }
dd { margin: 0; font-variant-numeric: tabular-nums; text-align: right; font-weight: 500; }
.muted { color: var(--text-muted); }
sup { color: var(--accent); font-size: 0.7em; }

.meta { font-size: 0.75rem; color: var(--text-subtle); line-height: 1.6; }

/* ---------- day timeline ---------- */
.tl-scroll { overflow-x: auto; border-radius: var(--radius-sm); }
#timeline { display: block; width: 100%; min-width: 900px; height: auto; }
#timeline text { fill: var(--tl-ink); font-family: var(--font-sans); font-size: 15px; }
#timeline .hr, #timeline .tm { text-anchor: middle; font-variant-numeric: tabular-nums; font-size: 13px; }
#timeline .hr { fill: var(--text-muted); }
#timeline .nm { text-anchor: middle; }
#timeline .edge { font-size: 11px; fill: var(--tl-line); font-variant-numeric: tabular-nums; }
#timeline .edge.end { text-anchor: end; }
#timeline .bad { fill: var(--tl-bad); font-size: 13px; text-anchor: middle; font-weight: 500; }
#timeline .good { fill: var(--tl-good); font-size: 13px; text-anchor: middle; font-weight: 600; }
#timeline .vara { fill: var(--accent); text-anchor: middle; font-family: var(--font-serif); font-size: 17px; font-weight: 600; }
#timeline .out { fill: var(--tl-out); }
#timeline .day { fill: var(--tl-day); }
#timeline .night { fill: var(--tl-night); }
#timeline .axis, #timeline .row { stroke: var(--tl-line); stroke-width: 1; }
#timeline .tick { stroke: var(--tl-ink); stroke-width: 1; }
#timeline .dash { stroke: var(--tl-line); stroke-dasharray: 3 3; }
#timeline .bow, #timeline .arrow { fill: var(--tl-mark); }
#timeline .brk { stroke: var(--tl-bad); stroke-width: 1.5; fill: none; }
#timeline .brk-good { stroke: var(--tl-good); stroke-width: 2.5; fill: none; }
#timeline .sun { fill: var(--sun); stroke: var(--sun-edge); stroke-width: 1.2; }
#timeline .sunline { stroke: var(--tl-line); }

/* Guidance row */
#timeline .gblock { cursor: pointer; }
#timeline .gb { stroke: none; }
#timeline .gb.on { stroke: var(--text); stroke-width: 2; }
#timeline .gblock:hover .gb { filter: brightness(0.94); }
#timeline .gt { font-size: 12px; font-weight: 600; text-anchor: middle; pointer-events: none; }
#timeline .sel { fill: var(--accent); fill-opacity: 0.08; stroke: var(--accent); stroke-opacity: 0.5; stroke-width: 1; }
#timeline .now { stroke: var(--danger); stroke-width: 1.5; stroke-dasharray: 4 3; }
#timeline .nowt { fill: var(--danger); font-size: 11px; font-weight: 600; text-anchor: middle; }
#timeline .gb.excellent, .sw.excellent { fill: var(--v-excellent); background: var(--v-excellent); }
#timeline .gb.good, .sw.good { fill: var(--v-good); background: var(--v-good); }
#timeline .gb.mixed, .sw.mixed { fill: var(--v-mixed); background: var(--v-mixed); }
#timeline .gb.poor, .sw.poor { fill: var(--v-poor); background: var(--v-poor); }
#timeline .gb.avoid, .sw.avoid { fill: var(--v-avoid); background: var(--v-avoid); }
#timeline .gt.excellent { fill: var(--v-excellent-ink); }
#timeline .gt.good { fill: var(--v-good-ink); }
#timeline .gt.mixed { fill: var(--v-mixed-ink); }
#timeline .gt.poor { fill: var(--v-poor-ink); }
#timeline .gt.avoid { fill: var(--v-avoid-ink); }

.legend { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; align-items: center; margin-top: 0.75rem; font-size: 0.8rem; color: var(--text-muted); }
.legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.legend .hint { margin-left: auto; color: var(--text-subtle); }

/* Guidance detail */
.guide { margin-top: 1rem; padding-top: 1rem; border-top: 0.5px solid var(--border); }
.guide-head { display: flex; align-items: center; gap: 0.75rem; }
.guide-head button { flex: none; }
.guide-head button:disabled { opacity: 0.35; cursor: default; }
.guide-title { flex: 1; min-width: 0; }
.guide-title h3 { font-family: var(--font-serif); font-weight: 600; font-size: 1.3rem; letter-spacing: -0.01em; margin-top: 0.15rem;
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.6rem; }
.badge { font-family: var(--font-sans); font-size: 0.75rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.badge.excellent { background: var(--v-excellent); color: var(--v-excellent-ink); }
.badge.good { background: var(--v-good); color: var(--v-good-ink); }
.badge.mixed { background: var(--v-mixed); color: var(--v-mixed-ink); }
.badge.poor { background: var(--v-poor); color: var(--v-poor-ink); }
.badge.avoid { background: var(--v-avoid); color: var(--v-avoid-ink); }
.guide-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem 2rem; margin-top: 1rem; }
.guide h4 { margin: 0 0 0.4rem; }
.guide ul { margin: 0; padding: 0; list-style: none; }
.guide-cols li { padding: 0.3rem 0 0.3rem 1.3rem; position: relative; border-bottom: 0.5px solid var(--border); }
.col-do li::before { content: "✓"; position: absolute; left: 0; color: var(--accent); font-weight: 700; }
.col-avoid li::before { content: "✕"; position: absolute; left: 0; color: var(--danger); font-weight: 700; }
.why { margin-top: 1.25rem; }
.why li { display: grid; grid-template-columns: 7.5rem 1fr; gap: 0.75rem; padding: 0.4rem 0 0.4rem 0.6rem; font-size: 0.9rem;
  border-left: 3px solid var(--border-strong); margin-bottom: 0.3rem; color: var(--text-muted); }
.why li b { color: var(--text); font-weight: 600; }
.why li.good { border-left-color: var(--accent); }
.why li.bad { border-left-color: var(--v-poor-ink); }
.why li.block { border-left-color: var(--danger); background: color-mix(in srgb, var(--danger) 7%, transparent); }
.why .fx { font-size: 11px; font-weight: 500; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-subtle); padding-top: 0.15rem; }
@media (max-width: 560px) { .why li { grid-template-columns: 1fr; gap: 0.1rem; } }
.disclaimer { margin-top: 1rem; font-size: 0.75rem; color: var(--text-subtle); }

/* Birth star */
.birth label { font-size: 0.9rem; color: var(--text-muted); }
.birth select { cursor: pointer; }
.birth .hint { font-size: 0.8rem; color: var(--text-subtle); }
.headline .personal { margin-top: 0.5rem; font-size: 0.92rem; color: var(--text); }
.headline .personal b { font-weight: 600; }
.headline .personal .bad { color: var(--danger); font-weight: 600; }
.headline .personal .good { color: var(--accent); font-weight: 600; }
.why li .fx.personal { color: var(--accent); }
