/* biorhythm.com – base styles. No external fonts or resources (privacy). */
:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --text: #1f1c26;
  --muted: #5f5a6b;
  --line: #ddd8cf;
  --accent: #2b2340;
  --accent-text: #ffffff;
  --weekend: rgba(43, 35, 64, 0.045);
  --today: rgba(214, 160, 40, 0.18);
  --selected: rgba(43, 35, 64, 0.12);
  /* Cycle colours follow the original WinBio from 1995. */
  --c-physical: #8a2fa8;
  --c-emotional: #1f5fd6;
  --c-intellectual: #d42a2a;
  --radius: 12px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-display: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15131b;
    --surface: #1e1b27;
    --text: #ece9f2;
    --muted: #a7a1b4;
    --line: #353043;
    --accent: #d9cdf5;
    --accent-text: #15131b;
    --weekend: rgba(255, 255, 255, 0.035);
    --today: rgba(214, 160, 40, 0.22);
    --selected: rgba(217, 205, 245, 0.14);
    --c-physical: #c77de0;
    --c-emotional: #6f9cff;
    --c-intellectual: #ff6b6b;
  }
}

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

/* The hidden attribute must win over component display rules (e.g. .result { display: grid }). */
[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--font);
}

a {
  color: inherit;
}

h1,
h2 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.2;
}

h1 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  margin: 0 0 1rem;
}

h2 {
  font-size: 1.3rem;
  margin: 0;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 650;
  text-decoration: none;
  margin-right: auto;
}

.main-nav,
.lang-switch {
  display: flex;
  gap: 1rem;
}

.main-nav {
  flex-wrap: wrap;
  row-gap: 0.4rem;
  min-width: 0;
}

.main-nav a,
.lang-switch a {
  text-decoration: none;
  color: var(--muted);
}

.main-nav a:hover,
.lang-switch a:hover,
.main-nav a[aria-current] {
  color: var(--text);
}

.lang-switch {
  gap: 0.6rem;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
}

.lang-switch span {
  font-weight: 700;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 16px 3rem;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: end;
}

.controls label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.9rem;
  color: var(--muted);
}

input[type='date'] {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  min-height: 44px;
}

button {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  padding: 0.55rem 1rem;
  min-height: 44px;
}

button.primary {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
  font-weight: 600;
}

button.icon {
  font-size: 1.4rem;
  line-height: 1;
  padding: 0.3rem 0.8rem;
}

button:focus-visible,
input:focus-visible,
a:focus-visible,
.hit rect:focus-visible {
  outline: 3px solid var(--c-emotional);
  outline-offset: 2px;
}

.privacy-note {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0.6rem 0 1.5rem;
}

.message {
  color: var(--muted);
}

.result {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem;
}

.today-panel,
.chart-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
  gap: 1rem;
  margin: 1rem 0;
}

.card {
  border: 1px solid var(--line);
  border-top: 4px solid var(--cycle);
  border-radius: 10px;
  padding: 0.9rem 1rem;
}

.c-physical {
  --cycle: var(--c-physical);
}
.c-emotional {
  --cycle: var(--c-emotional);
}
.c-intellectual {
  --cycle: var(--c-intellectual);
}

.card-label {
  color: var(--cycle);
  font-weight: 650;
}

.card-value {
  font-size: 1.8rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.bar {
  position: relative;
  height: 6px;
  border-radius: 3px;
  background: var(--line);
  margin: 0.4rem 0 0.5rem;
}

.bar::after {
  content: '';
  position: absolute;
  left: 50%;
  top: -3px;
  width: 1px;
  height: 12px;
  background: var(--muted);
}

.bar-fill {
  position: absolute;
  top: 0;
  height: 100%;
  border-radius: 3px;
  background: var(--cycle);
}

.card-trend {
  font-size: 0.9rem;
  color: var(--muted);
}

.card.is-critical .card-trend {
  color: var(--text);
  font-weight: 600;
}

.summary p {
  margin: 0.3rem 0;
}

.chart-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.chart-head h2 {
  min-width: 10ch;
  text-align: center;
}

.chart-head #today {
  margin-left: auto;
}

.chart-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

#chart {
  min-width: 720px;
}

#chart,
.sheet-chart {
  display: block;
  width: 100%;
  height: auto;
}

:is(#chart, .sheet-chart) text {
  fill: var(--muted);
  font: 11px var(--font);
  text-anchor: middle;
}

:is(#chart, .sheet-chart) .day-num {
  fill: var(--text);
  font-weight: 600;
}

:is(#chart, .sheet-chart) .day-line {
  stroke: var(--line);
  stroke-width: 1;
  stroke-dasharray: 2 3;
}

:is(#chart, .sheet-chart) .zero-line {
  stroke: var(--muted);
  stroke-width: 1.5;
}

:is(#chart, .sheet-chart) .weekend {
  fill: var(--weekend);
}

:is(#chart, .sheet-chart) .today-marker {
  fill: var(--today);
}

:is(#chart, .sheet-chart) .selected-marker {
  fill: var(--selected);
}

:is(#chart, .sheet-chart) .curve {
  fill: none;
  stroke: var(--cycle);
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

:is(#chart, .sheet-chart) .crit {
  fill: var(--surface);
  stroke: var(--cycle);
  stroke-width: 2.5;
}

:is(#chart, .sheet-chart) .hit rect {
  fill: transparent;
  cursor: pointer;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.legend .swatch {
  width: 18px;
  height: 3px;
  border-radius: 2px;
  background: var(--cycle);
}

.legend .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--muted);
}

.prose {
  max-width: 68ch;
}

.prose h2 {
  margin: 2rem 0 0.5rem;
}

.site-footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 16px 2.5rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
}

.disclaimer {
  max-width: 75ch;
}

/* Install button and iOS hint */
.install {
  min-height: 36px;
  padding: 0.3rem 0.8rem;
  font-size: 0.85rem;
}

.ios-hint {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: 1100px;
  margin: 0 auto 0.5rem;
  padding: 0.5rem 0.75rem 0.5rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 0.9rem;
}

.ios-hint[hidden] {
  display: none;
}

.ios-hint p {
  margin: 0;
  flex: 1;
}

/* Articles */
.lead {
  font-size: 1.15rem;
  color: var(--muted);
}

.prose figure {
  margin: 1.5rem 0;
}

.prose img {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.prose figcaption {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.4rem;
}

.prose table {
  border-collapse: collapse;
  margin: 1rem 0;
  font-variant-numeric: tabular-nums;
}

.prose th,
.prose td {
  border-bottom: 1px solid var(--line);
  padding: 0.4rem 0.9rem 0.4rem 0;
  text-align: left;
}

.formula {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.6rem 1rem;
  display: inline-block;
}

.read-more {
  margin-top: 3rem;
  max-width: 68ch;
}

.read-more ul {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 0.9rem;
}

.read-more li {
  display: grid;
  gap: 0.15rem;
}

.read-more a {
  font-weight: 600;
}

.read-more span {
  color: var(--muted);
  font-size: 0.9rem;
}

/* Partner comparison */
.bar-plain::after {
  display: none;
}

.card-text {
  font-size: 0.9rem;
  margin: 0.5rem 0 0;
}

.days-apart {
  color: var(--muted);
  margin: 0.25rem 0 0.75rem;
}

.overall-value {
  font-size: 1.5rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.overall p {
  margin: 0.2rem 0 0;
}

table.pair {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.75rem;
  font-variant-numeric: tabular-nums;
}

table.pair th,
table.pair td {
  text-align: left;
  padding: 0.55rem 0.75rem 0.55rem 0;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

table.pair thead th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.9rem;
}

table.pair tbody th {
  color: var(--cycle);
  font-weight: 650;
  white-space: nowrap;
}

table.pair td {
  width: 40%;
}

.pair-value {
  display: block;
  font-weight: 600;
}

/* Intuitive cycle (optional fourth curve, colour as in WinBio) */
:root {
  --c-intuitive: #2f6b3f;
}
@media (prefers-color-scheme: dark) {
  :root {
    --c-intuitive: #6fcf8f;
  }
}
.c-intuitive {
  --cycle: var(--c-intuitive);
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.9rem;
  font-size: 0.9rem;
  color: var(--muted);
  cursor: pointer;
}

.toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--c-intuitive);
}

.legend li[hidden] {
  display: none;
}

/* Explanatory text below the tools */
.seo-text {
  margin-top: 3rem;
}

.seo-text h2 {
  margin-top: 0;
}

.seo-text h3 {
  font-size: 1.05rem;
  margin: 1.5rem 0 0.4rem;
}

.calculator > .lead {
  margin: -0.4rem 0 1.25rem;
  max-width: 60ch;
}

/* Actions below the result */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* Dialogs (print options, share) */
.dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 1.5rem;
  width: min(30rem, calc(100vw - 32px));
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.dialog::backdrop {
  background: rgba(10, 8, 16, 0.55);
}

.dialog h2 {
  margin-bottom: 1rem;
}

.dialog .field {
  display: grid;
  gap: 0.3rem;
  margin-bottom: 0.9rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.dialog input[type='text'],
.dialog select {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  min-height: 44px;
}

.dialog .toggle {
  margin: 0 0 0.75rem;
  align-items: flex-start;
}

.dialog .toggle input {
  margin-top: 0.15rem;
  flex: none;
}

.hint {
  font-size: 0.85rem;
  color: var(--muted);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1rem;
}

.share-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
  gap: 0.6rem;
  margin: 0.5rem 0 1rem;
}

.share-grid a,
.share-grid button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
  font: inherit;
  font-size: 0.95rem;
}

button.wide {
  width: 100%;
}

.share-status {
  min-height: 1.4em;
  font-weight: 600;
  margin: 0.25rem 0 0;
}

/* Print sheet: hidden on screen, the only thing printed when present */
#print-sheet {
  display: none;
}

@media print {
  @page {
    size: A4 landscape;
    margin: 10mm;
  }

  :root {
    --bg: #fff;
    --surface: #fff;
    --text: #1f1c26;
    --muted: #5f5a6b;
    --line: #cfc9be;
    --weekend: rgba(43, 35, 64, 0.06);
    --c-physical: #8a2fa8;
    --c-emotional: #1f5fd6;
    --c-intellectual: #d42a2a;
    --c-intuitive: #2f6b3f;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  body {
    background: #fff;
    font-size: 10pt;
  }

  body.printing > :not(#print-sheet) {
    display: none !important;
  }

  body.printing #print-sheet {
    display: block;
  }

  /* Plain page print without a sheet (e.g. articles) */
  body:not(.printing) :is(.main-nav, .lang-switch, .install, .ios-hint, .actions, .read-more, dialog) {
    display: none !important;
  }

  .sheet-page {
    break-after: page;
    min-height: 186mm;
    display: flex;
    flex-direction: column;
    gap: 3mm;
  }

  .sheet-page:last-child {
    break-after: auto;
  }

  .sheet-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    border-bottom: 0.4mm solid var(--text);
    padding-bottom: 2mm;
  }

  .sheet-brand {
    display: flex;
    align-items: center;
    gap: 2mm;
    font-weight: 650;
    font-size: 12pt;
  }

  .sheet-brand img {
    width: 7mm;
    height: 7mm;
  }

  .sheet-month {
    font-family: var(--font-display);
    font-size: 24pt;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
  }

  .sheet-who {
    margin: 0;
    font-size: 11pt;
  }

  .sheet-chart {
    min-width: 0;
    height: auto;
  }

  .sheet-legend {
    margin: 0;
    font-size: 9pt;
  }

  .sheet-bottom {
    display: grid;
    grid-template-columns: 1fr 1.4fr 38mm;
    gap: 6mm;
    align-items: start;
    break-inside: avoid;
  }

  .sheet-bottom h3 {
    font-size: 10.5pt;
    margin: 0 0 1.5mm;
  }

  .sheet-bottom p {
    margin: 0 0 1mm;
  }

  .sheet-critical ul {
    list-style: none;
    margin: 0;
    padding: 0;
    columns: 2;
    column-gap: 4mm;
    font-size: 9pt;
  }

  .sheet-critical li {
    break-inside: avoid;
    margin-bottom: 0.8mm;
  }

  .sheet-date {
    white-space: nowrap;
    font-weight: 600;
    margin-right: 1.5mm;
  }

  .sheet-tag {
    color: var(--cycle);
    margin-right: 1.5mm;
  }

  .sheet-values {
    display: flex;
    flex-wrap: wrap;
    gap: 1mm 4mm;
    font-weight: 650;
  }

  .sheet-values span {
    color: var(--cycle);
  }

  .sheet-qr {
    text-align: center;
    font-size: 8pt;
  }

  .sheet-qr-code svg {
    width: 30mm;
    height: 30mm;
    display: block;
    margin: 0 auto 1.5mm;
  }

  .sheet-url {
    font-weight: 650;
    font-size: 9pt;
  }

  .sheet-foot {
    margin-top: auto;
    font-size: 7.5pt;
    color: var(--muted);
    border-top: 0.2mm solid var(--line);
    padding-top: 1.5mm;
  }
}

/* Famous people */
.note {
  max-width: 68ch;
  font-size: 0.9rem;
  color: var(--muted);
  border-left: 3px solid var(--line);
  padding-left: 0.9rem;
}

.crumbs {
  font-size: 0.9rem;
}

.person-meta {
  color: var(--muted);
}

.person-values,
.person + .person-values,
.chart-panel + .note {
  margin-top: 1.5rem;
}

.chart-panel h2,
.person-values h2 {
  margin-top: 0;
}

.read-more .people-grid,
.people-grid {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
  gap: 1rem;
}

.read-more:has(.people-grid) {
  max-width: none;
}

.people-grid li {
  display: block;
}

.people-grid a {
  display: grid;
  gap: 0.2rem;
  height: 100%;
  box-sizing: border-box;
  padding: 0.9rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 400;
}

.people-grid a:hover {
  border-color: var(--muted);
}

.people-grid strong {
  font-size: 1.05rem;
}

.read-more .people-grid span,
.people-grid span {
  font-size: 0.85rem;
  color: var(--muted);
}

.people-grid .person-values {
  display: flex;
  gap: 0.8rem;
  margin-top: 0.3rem;
  font-variant-numeric: tabular-nums;
}

.read-more .people-grid .person-values span,
.people-grid .person-values span {
  color: var(--cycle);
  font-weight: 600;
}

.cta-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  margin: 2rem 0;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.cta-box p {
  margin: 0;
  font-weight: 600;
}

a.button {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
}

a.button.primary {
  background: var(--accent);
  color: var(--accent-text);
}

/* Widget page */
.widget-tool {
  max-width: 68ch;
  display: grid;
  gap: 0.6rem;
}

.widget-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.widget-tool .field {
  display: grid;
  gap: 0.3rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.widget-tool select,
.widget-tool input,
.widget-tool textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  min-height: 44px;
  box-sizing: border-box;
}

.widget-tool textarea {
  width: 100%;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.8rem;
  resize: vertical;
}

.widget-preview {
  padding: 1rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

/* Embedded widget (inside an iframe on other sites) */
body.embed {
  margin: 0;
  padding: 12px;
  font-size: 15px;
}

.embed-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: end;
}

.embed-form label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.embed-date {
  margin: 0.8rem 0 0.4rem;
  font-weight: 600;
}

.embed-values {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.embed-value {
  display: grid;
  border-top: 3px solid var(--cycle);
  padding-top: 0.25rem;
}

.embed-value span {
  font-size: 0.8rem;
  color: var(--cycle);
  font-weight: 600;
}

.embed-value strong {
  font-size: 1.2rem;
  font-variant-numeric: tabular-nums;
}

#embed-chart {
  margin-top: 0.5rem;
}

.embed-summary {
  font-size: 0.9rem;
  margin: 0.4rem 0;
}

.embed-brand {
  font-size: 0.8rem;
  margin: 0.6rem 0 0;
  text-align: right;
}

.chart-panel .sheet-chart {
  min-width: 560px;
}

/* Example chart for first-time visitors */
.example-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--accent);
  border-left-width: 4px;
  border-radius: var(--radius);
  background: var(--surface);
}

.example-banner[hidden] {
  display: none;
}

.example-banner p {
  flex: 1 1 28ch;
  margin: 0;
}

.result.is-example .summary,
.result.is-example .actions,
.result.is-example #ics-status {
  display: none;
}

.embed-hint {
  margin: 0.7rem 0 0;
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
  border-left: 3px solid var(--accent);
  background: var(--surface);
  border-radius: 4px;
}
