/* Astrology app. Ink on paper. Tokens and rules: design-brief.md */

@font-face {
  font-family: "Fraunces";
  src: url("fonts/fraunces-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("fonts/inter-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #F6F1E8;
  --paper-2: #EEE6D8;
  --line: #D8CEBB;
  --ink: #1F1A14;
  --ink-2: #5A5044;
  --ink-3: #8C8172;
  --accent: #A63D2F;
  --gold: #B8892E;
  --backdrop: rgba(31, 26, 20, 0.28);

  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 12px;
  --gutter: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #14120F;
    --paper-2: #1E1B16;
    --line: #33302A;
    --ink: #EDE6D8;
    --ink-2: #B3A995;
    --ink-3: #7E7566;
    --accent: #D9634F;
    --gold: #D1A64C;
    --backdrop: rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #14120F;
  --paper-2: #1E1B16;
  --line: #33302A;
  --ink: #EDE6D8;
  --ink-2: #B3A995;
  --ink-3: #7E7566;
  --accent: #D9634F;
  --gold: #D1A64C;
  --backdrop: rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

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

html {
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: clip;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 var(--gutter) calc(48px + env(safe-area-inset-bottom));
  min-height: 100vh;
}

h1, h2, h3, p { margin: 0; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink-2); outline-offset: 2px; border-radius: 6px; }

.skt { font-family: var(--serif); font-style: italic; font-weight: 400; }
.muted { color: var(--ink-3); }
.nw { white-space: nowrap; }
/* tabular figures where numbers line up (not on body: Inter's tabular set also widens hyphens) */
.meta, .row-meta, .ptable, .d-dates, .now-list, .facts dd, .offset-line, .resolved, input, .north-chart text { font-variant-numeric: tabular-nums; }
.pada { font-variant-numeric: proportional-nums; }
.meta { color: var(--ink-2); font-size: 13px; overflow-wrap: anywhere; }
.meta.strong { color: var(--ink); font-size: 15px; }
.hint { color: var(--ink-2); font-size: 13px; margin-top: 6px; }
.note {
  font-size: 13px; color: var(--ink-2);
  border-left: 2px solid var(--gold);
  padding: 2px 0 2px 10px; margin-top: 12px;
}
.error, .warn { color: var(--accent); font-size: 13px; }
.warn { margin-top: 8px; }
.status { color: var(--ink-2); font-size: 13px; margin-top: 12px; }
.empty { color: var(--ink-2); margin-top: 28px; }
.empty-link { margin-top: 8px; font-size: 15px; }
.empty-link a { color: var(--ink); text-underline-offset: 3px; text-decoration-color: var(--line); }
.eyebrow { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); font-weight: 500; }

/* ---------------------------------------------------------------- header */

.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 4px;
  height: 56px;
  margin: 0 calc(-1 * var(--gutter));
  padding: 0 var(--gutter) 0 calc(var(--gutter) - 12px);
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.bar-title {
  font-family: var(--serif); font-optical-sizing: auto;
  font-weight: 400; font-size: 22px; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0;
}
.icon-btn {
  flex: none; display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 10px;
  color: var(--ink); text-decoration: none;
}
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.home-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
  padding: 40px 0 20px;
}
.display {
  font-family: var(--serif); font-optical-sizing: auto;
  font-weight: 300; font-size: 40px; line-height: 1.05; letter-spacing: -0.01em;
}
.text-btn {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 2px;
  color: var(--ink-2); text-decoration: none; font-size: 15px;
}

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 18px;
  border: 1px solid var(--line); border-radius: 10px;
  background: transparent; color: var(--ink);
  font-size: 15px; font-weight: 500; line-height: 1.2;
  text-decoration: none; cursor: pointer;
  -webkit-user-select: none; user-select: none;
}
.btn:active { background: var(--paper-2); }
.btn:disabled { color: var(--ink-3); cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--paper); }
.btn.primary:active { filter: brightness(0.92); }
.btn.wide { width: 100%; }
.btn.quiet { border-color: transparent; color: var(--ink-3); font-weight: 400; }
.link-btn {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 2px;
  background: none; border: 0; color: var(--ink); font-size: 15px; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line);
}
.move-online { margin-top: 12px; }
.account { margin-top: 20px; color: var(--ink-2); font-size: 15px; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------------------------------------------------------------- cards and lists */

.card { background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius); }

.list { list-style: none; margin: 28px 0 0; padding: 0; overflow: hidden; }
.list li + li { border-top: 1px solid var(--line); }
.chart-row {
  display: grid; gap: 1px;
  padding: 14px 16px; min-height: 44px;
  text-decoration: none; color: var(--ink);
}
.chart-row:active { background: var(--paper); }
.row-name { font-family: var(--serif); font-optical-sizing: auto; font-size: 20px; font-weight: 400; line-height: 1.25; overflow-wrap: anywhere; }
.row-meta { color: var(--ink-2); font-size: 13px; }
.row-sub { color: var(--ink-2); font-size: 13px; }
.row-sub .skt { font-size: 14px; color: var(--ink); }

/* ---------------------------------------------------------------- forms */

.form { display: grid; gap: 18px; padding-top: 20px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field label, .field .label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field-row { display: grid; grid-template-columns: 1.25fr 1fr; gap: 12px; }

input[type="text"], input[type="password"], input[type="search"], input[type="date"], input[type="time"], select {
  width: 100%; min-width: 0; height: 48px;
  padding: 0 12px;
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px;
  font-size: 17px; font-variant-numeric: tabular-nums;
  appearance: none; -webkit-appearance: none;
}
input::placeholder { color: var(--ink-3); }
input:focus, select:focus { outline: none; border-color: var(--ink-2); }
input:disabled { color: var(--ink-3); background: var(--paper-2); }
input[type="search"]::-webkit-search-cancel-button { display: none; }
input[type="date"], input[type="time"] { display: block; line-height: 46px; }
input::-webkit-date-and-time-value { text-align: left; }
input::-webkit-calendar-picker-indicator { opacity: 0.55; }
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
  background-position: calc(100% - 19px) 21px, calc(100% - 14px) 21px;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
  padding-right: 36px;
}

.check {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 44px; font-size: 15px; cursor: pointer;
}
.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }

.place-field { position: relative; }
.place-field .btn { justify-self: start; margin-top: 4px; }
.results { list-style: none; margin: 2px 0 0; padding: 4px 0; overflow: hidden; }
.result {
  display: grid; width: 100%; text-align: left; gap: 0;
  padding: 10px 14px; min-height: 48px;
  border: 0; background: transparent; cursor: pointer;
}
.result:active, .result:focus-visible { background: var(--paper); }
.result-name { font-size: 15px; color: var(--ink); }
.result-rest { font-size: 13px; color: var(--ink-2); }

.resolved { padding: 16px; display: grid; gap: 2px; }
.resolved-place { font-family: var(--serif); font-optical-sizing: auto; font-size: 17px; line-height: 1.3; }
.offset-line { font-size: 15px; font-weight: 500; margin-top: 6px; }
.resolved .field { margin-top: 14px; }

.seg {
  display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  background: var(--paper);
}
.seg label { flex: 1 1 0; min-width: 0; position: relative; }
.seg label + label { border-left: 1px solid var(--line); }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 44px; padding: 0 6px; font-size: 15px; color: var(--ink-2); line-height: 1.2;
}
.seg input:checked + span { background: var(--ink); color: var(--paper); }
.seg input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: -4px; }

.section {
  font-family: var(--serif); font-optical-sizing: auto;
  font-size: 22px; font-weight: 400; margin-top: 10px;
}
.settings .section:first-child { margin-top: 0; }

.fixed { margin: 0; padding: 4px 16px; }
.fixed div, .facts div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; }
.fixed div + div, .facts div + div { border-top: 1px solid var(--line); }
.fixed dt, .facts dt { color: var(--ink-2); font-size: 15px; }
.fixed dd, .facts dd { margin: 0; text-align: right; font-size: 15px; }

/* ---------------------------------------------------------------- chart screen */

.chart-head { display: grid; gap: 2px; padding: 16px 0 4px; }

.tabs {
  position: relative;
  display: flex; gap: 22px;
  margin: 12px calc(-1 * var(--gutter)) 0;
  padding: 0 var(--gutter);
  border-bottom: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; display: flex; align-items: center;
  min-height: 44px; padding: 0;
  color: var(--ink-2); text-decoration: none;
  font-size: 15px; font-weight: 500;
}
.tab.active { color: var(--ink); }
.tab-line {
  position: absolute; left: 0; bottom: 0;
  height: 2px; width: 0; background: var(--gold);
  transition: transform 150ms ease, width 150ms ease;
}
.tab-line.no-anim { transition: none; }

.panel { padding-top: 16px; }

.chart-card { padding: 10px; }
.chart-svg { display: block; width: 100%; height: auto; aspect-ratio: 1; overflow: visible; }

.north-chart .nc-lines rect, .north-chart .nc-lines path {
  fill: none; stroke: var(--ink-3); stroke-width: 1;
  vector-effect: non-scaling-stroke; shape-rendering: geometricPrecision;
}
.north-chart .nc-signs text {
  font-family: var(--serif); font-optical-sizing: auto; font-size: 14px; font-weight: 400;
  fill: var(--ink-3);
}
.north-chart .nc-abbr { font-family: var(--sans); font-weight: 500; fill: var(--ink); }
.north-chart .nc-deg { font-family: var(--sans); font-weight: 400; fill: var(--ink-2); font-variant-numeric: tabular-nums; }
.north-chart .nc-rx { fill: none; stroke: var(--gold); stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.north-chart .nc-asc .nc-abbr { fill: var(--accent); font-weight: 600; }
.north-chart .nc-tr .nc-abbr, .north-chart .nc-tr .nc-deg { fill: var(--accent); }
.north-chart .nc-tr .nc-abbr { font-weight: 500; }
.north-chart .nc-hit { fill: transparent; stroke: none; }
.north-chart .nc-pl { cursor: pointer; outline: none; }
.north-chart .nc-pl:focus-visible .nc-hit { stroke: var(--ink-2); stroke-width: 1; vector-effect: non-scaling-stroke; }
/* by-degree placement: a quiet ruler of ticks per house, hairlines from a moved label to its
   true degree, and a paper-coloured halo so a tick never shows through a label */
.north-chart .nc-ruler path { fill: none; stroke: var(--ink-3); stroke-width: 1; opacity: .45; vector-effect: non-scaling-stroke; }
.north-chart .nc-ruler .nc-ruler-tr path { stroke: var(--accent); opacity: .35; }
.north-chart .nc-lead line { stroke: var(--ink-3); stroke-width: .8; opacity: .8; vector-effect: non-scaling-stroke; }
.north-chart .nc-lead circle { fill: var(--ink-3); }
.north-chart .nc-lead-tr line { stroke: var(--accent); opacity: .6; }
.north-chart .nc-lead-tr circle { fill: var(--accent); }
.north-chart.nc-by-degree .nc-abbr, .north-chart.nc-by-degree .nc-deg {
  paint-order: stroke; stroke: var(--paper-2); stroke-width: 3px; stroke-linejoin: round;
}

.legend { font-size: 13px; color: var(--ink-2); margin: 10px 2px 0; }
.legend span { font-weight: 500; }
.lg-natal { color: var(--ink); }
.lg-tr { color: var(--accent); margin-left: 12px; }

/* retrograde mark, drawn (the fonts have no ℞) */
svg.rx {
  width: 0.62em; height: 0.62em; margin-left: 2px;
  vertical-align: 0.4em;
  fill: none; stroke: var(--gold); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------------------------------------------------------------- tables */

.ptable {
  width: 100%; margin-top: 16px;
  border-collapse: collapse;
  font-size: 15px; font-variant-numeric: tabular-nums;
}
.ptable th {
  text-align: left; font-size: 11px; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3);
  padding: 0 6px 8px; white-space: nowrap;
}
.ptable td { padding: 9px 6px; vertical-align: top; line-height: 1.3; }
.ptable th:first-child, .ptable td:first-child { padding-left: 8px; }
.ptable th:last-child, .ptable td:last-child { padding-right: 8px; }
.ptable tbody tr:nth-child(odd) td { background: var(--paper-2); }
.ptable tbody tr:nth-child(odd) td:first-child { border-radius: 8px 0 0 8px; }
.ptable tbody tr:nth-child(odd) td:last-child { border-radius: 0 8px 8px 0; }
.ptable .num { text-align: right; }
.ptable .c-planet { white-space: nowrap; }
.ptable.tappable tbody tr { cursor: pointer; }
.ptable tbody tr:focus-visible { outline: 2px solid var(--ink-2); outline-offset: -2px; }
.deg-inline { display: none; }

/* A 360px phone cannot fit five columns at 15px: the degree moves under the sign. */
@media (max-width: 459px) {
  .ptable th, .ptable td { padding-left: 4px; padding-right: 4px; }
  .ptable th:first-child, .ptable td:first-child { padding-left: 6px; }
  .ptable th:last-child, .ptable td:last-child { padding-right: 6px; }
  .ptable th { letter-spacing: 0.05em; }
  .ptable .c-deg { display: none; }
  .ptable .deg-inline { display: block; color: var(--ink-2); font-size: 13px; }
}

.bhava-intro, .dasha-intro { margin-bottom: 4px; }

/* ---------------------------------------------------------------- dashas */

.now { padding: 16px; margin-bottom: 16px; }
.now-lords {
  font-family: var(--serif); font-optical-sizing: auto; font-weight: 400;
  font-size: 28px; line-height: 1.2; margin-top: 4px;
}
.now-lords .sep { color: var(--ink-3); margin: 0 8px; font-weight: 300; }
.now-list { margin: 12px 0 0; display: grid; gap: 4px; }
.now-list div { display: flex; gap: 12px; font-size: 15px; }
.now-list dt { width: 88px; flex: none; color: var(--ink-2); }
.now-list dd { margin: 0; }

.dasha-tree { margin-top: 12px; border-top: 1px solid var(--line); }
.drow {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  width: 100%; min-height: 48px; padding: 8px 4px 8px 8px;
  border: 0; border-bottom: 1px solid var(--line);
  background: transparent; text-align: left; cursor: pointer;
}
.drow:disabled { cursor: default; color: var(--ink); }
.drow.running::before {
  content: ""; position: absolute; left: 0; top: 6px; bottom: 6px;
  width: 3px; border-radius: 2px; background: var(--accent);
}
.drow .chev { flex: none; width: 16px; height: 16px; fill: none; stroke: var(--ink-3); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.drow.open .chev { transform: rotate(90deg); }
.chev-space { flex: none; width: 16px; }
.d-lord { flex: 1 1 auto; min-width: 0; }
.d-dates { flex: none; color: var(--ink-2); font-size: 15px; white-space: nowrap; }
.drow.lvl1 .d-lord { font-family: var(--serif); font-optical-sizing: auto; font-size: 17px; }
.drow.lvl2 { padding-left: 24px; }
.drow.lvl2.running::before { left: 16px; }
.drow.lvl2 .d-lord { font-size: 15px; }
.drow.lvl3 { padding-left: 40px; min-height: 44px; }
.drow.lvl3.running::before { left: 32px; }
.drow.lvl3 .d-lord, .drow.lvl3 .d-dates { font-size: 13px; }
.drow.running .d-lord { font-weight: 600; }
.drow.lvl1.running .d-lord { font-weight: 500; }
.dsub { background: color-mix(in srgb, var(--paper-2) 60%, transparent); }

/* ---------------------------------------------------------------- transits */

.transit-controls { display: grid; gap: 4px; margin-bottom: 14px; }
.control-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ---------------------------------------------------------------- bottom sheet */

.sheet-wrap { position: fixed; inset: 0; z-index: 20; }
.sheet-backdrop {
  position: absolute; inset: 0; background: var(--backdrop);
  opacity: 0; transition: opacity 200ms ease-out;
}
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-width: 560px; margin: 0 auto;
  max-height: 85vh; overflow-y: auto;
  padding: 20px var(--gutter) calc(16px + env(safe-area-inset-bottom));
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--line); border-bottom: 0;
  border-radius: 16px 16px 0 0;
  transform: translateY(100%);
  transition: transform 200ms ease-out;
}
.sheet-wrap.open .sheet { transform: none; }
.sheet-wrap.open .sheet-backdrop { opacity: 1; }
.sheet:focus { outline: none; }
.sheet-title {
  font-family: var(--serif); font-optical-sizing: auto; font-weight: 400;
  font-size: 28px; line-height: 1.2; margin-top: 2px;
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px;
}
.retro-tag { font-family: var(--sans); font-size: 13px; color: var(--gold); font-weight: 500; }
.retro-tag svg.rx { vertical-align: -0.05em; margin: 0 2px 0 0; width: 0.9em; height: 0.9em; }
.sheet-sub { color: var(--ink-2); margin-top: 2px; font-size: 15px; }
.sheet-sub .skt { font-size: 17px; color: var(--ink); }
.facts { margin: 14px 0 18px; }

.danger-zone { margin-top: 36px; display: flex; justify-content: center; }

@media (prefers-reduced-motion: reduce) {
  .tab-line, .sheet, .sheet-backdrop { transition: none; }
}
