/* CalcStocks - shared stylesheet.
   Dark instrument-panel direction: deep slate ground, one cyan accent for
   interaction, amber for assumption inputs, directional colour only where a
   number genuinely has a direction. Numbers are the loudest thing on screen. */

:root {
  --bg: #0b1016;
  --surface: #131b24;
  --surface-2: #1a242f;
  --border: #253241;
  --text: #e6edf3;
  --text-muted: #8fa3b8;
  --accent: #22d3ee;
  --accent-ink: #062b31;
  --amber: #f5b04c;
  --amber-soft: rgba(245, 176, 76, 0.12);
  --pos: #4ade80;
  --neg: #f87171;
  --focus: #7dd3fc;
  --radius: 12px;
  --wrap: 1180px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  overflow-x: hidden;
}

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 0.5em; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.75rem, 4vw, 2.6rem); }
h2 { font-size: clamp(1.3rem, 2.5vw, 1.75rem); }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1rem; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: #67e8f9; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

.wrap { width: min(100% - 2rem, var(--wrap)); margin-inline: auto; }
.wrap.narrow { width: min(100% - 2rem, 760px); }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: var(--accent-ink);
  padding: 0.6rem 1rem; border-radius: 0 0 var(--radius) 0; font-weight: 600;
}
.skip-link:focus { left: 0; }

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

.site-head {
  border-bottom: 1px solid var(--border);
  background: rgba(11, 16, 22, 0.9);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 30;
}
.site-head__inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.75rem 0; }
.brand { display: inline-flex; align-items: center; gap: 0.55rem; color: var(--text); text-decoration: none; font-weight: 700; }
.brand__mark { color: var(--accent); flex: none; }
.brand__name { font-size: 1.05rem; letter-spacing: -0.02em; }
.site-head__right { display: flex; align-items: center; gap: 1rem; }
.site-head__tagline { color: var(--text-muted); font-size: 0.85rem; }

@media (max-width: 640px) { .site-head__tagline { display: none; } }

/* language switcher */
.lang-switch { position: relative; }
.lang-switch__trigger {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.35rem 0.6rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); font-size: 0.85rem; color: var(--text);
}
.lang-switch__trigger::-webkit-details-marker { display: none; }
.lang-switch__menu {
  position: absolute; right: 0; top: calc(100% + 0.4rem); min-width: 170px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 0.3rem; z-index: 40; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}
.lang-switch__item {
  display: flex; align-items: center; gap: 0.5rem; padding: 0.45rem 0.6rem;
  border-radius: 7px; color: var(--text); text-decoration: none; font-size: 0.9rem;
}
.lang-switch__item:hover { background: var(--surface-2); }
.lang-switch__item.is-current { color: var(--accent); font-weight: 600; }

/* ---------------------------------------------------------------- crumbs */

.crumbs { border-bottom: 1px solid var(--border); font-size: 0.85rem; color: var(--text-muted); }
.crumbs .wrap { display: flex; gap: 0.5rem; padding: 0.6rem 0; }

/* ---------------------------------------------------------------- hero */

.hero { padding: 3rem 0 2rem; border-bottom: 1px solid var(--border); }
.hero--tool { padding-bottom: 1.5rem; }
.hero h1 { max-width: 22ch; }
.hero__lead { color: var(--text-muted); font-size: 1.08rem; max-width: 62ch; }
.hero__badges { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }
.hero-badge {
  padding: 0.35rem 0.8rem; border-radius: 999px; font-size: 0.83rem; font-weight: 600;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-muted);
}
.hero-badge--1 { border-color: rgba(34, 211, 238, 0.4); color: var(--accent); }
.hero-badge--2 { border-color: rgba(74, 222, 128, 0.35); color: var(--pos); }

/* ---------------------------------------------------------------- sections */

.section { padding: 3rem 0; }
.section--alt { background: var(--surface); border-block: 1px solid var(--border); }
.section__lead { color: var(--text-muted); max-width: 70ch; margin-bottom: 1.75rem; }
.note { color: var(--text-muted); font-size: 0.9rem; }

.prose h2 { margin-top: 2.25rem; }
.prose h3 { margin-top: 1.75rem; color: var(--accent); }
.prose p { color: #cbd8e6; }

/* ---------------------------------------------------------------- tool cards */

.tool-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.tool-card {
  display: block; padding: 1.25rem; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-2); color: var(--text); text-decoration: none; transition: border-color .15s, transform .15s;
}
.tool-card:hover { border-color: var(--accent); transform: translateY(-2px); color: var(--text); }
.tool-card h3 { margin-bottom: 0.35rem; color: var(--accent); font-size: 1.05rem; }
.tool-card p { margin: 0; color: var(--text-muted); font-size: 0.92rem; }

.topic-grid { display: grid; gap: 1.5rem 2rem; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.topic h3 { color: var(--text); }
.topic p { color: var(--text-muted); margin: 0; }

/* ---------------------------------------------------------------- steps + lists */

.steps { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.step { border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem; background: var(--surface-2); }
.step-number {
  display: inline-grid; place-items: center; width: 1.75rem; height: 1.75rem; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 0.9rem; margin-bottom: 0.5rem;
}
.step h3 { font-size: 1rem; }
.step p { color: var(--text-muted); font-size: 0.93rem; margin: 0; }

.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.7rem; }
.checklist li { position: relative; padding-left: 1.6rem; color: #cbd8e6; }
.checklist li::before {
  content: ""; position: absolute; left: 0; top: 0.6em; width: 0.55rem; height: 0.55rem;
  border-radius: 2px; background: var(--accent);
}

/* ---------------------------------------------------------------- calculator */

.calc-shell { padding: 2rem 0 3rem; }
.calc-layout { display: grid; gap: 1.5rem; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); align-items: start; }
@media (max-width: 900px) { .calc-layout { grid-template-columns: 1fr; } }

/* Grid children default to min-width:auto, which lets a wide table push the
   whole column past the viewport instead of scrolling inside .table-scroll.
   min-width:0 is what makes the inner overflow container actually work. */
.calc-layout > * { min-width: 0; }

.calc-inputs { display: grid; gap: 1rem; min-width: 0; }
.field-group {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem 1.1rem;
  background: var(--surface); margin: 0;
}
.field-group--assumption { border-color: rgba(245, 176, 76, 0.35); background: var(--amber-soft); }
.field-group--optional { border-style: dashed; }
.field-group legend { font-weight: 650; padding: 0 0.4rem; font-size: 0.95rem; }
.field-group--assumption legend { color: var(--amber); }
.field-group__note { color: var(--text-muted); font-size: 0.85rem; margin: 0 0 0.9rem; }

.field { margin-bottom: 0.9rem; }
.field:last-child { margin-bottom: 0; }
.field label { display: block; font-size: 0.9rem; font-weight: 600; margin-bottom: 0.3rem; }
.field__hint { color: var(--text-muted); font-size: 0.82rem; margin: 0.3rem 0 0; }

input[type="number"], input[type="email"], input[type="text"], select, textarea {
  width: 100%; padding: 0.6rem 0.7rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); font: inherit; font-variant-numeric: tabular-nums;
}
input[type="number"] { font-family: var(--mono); }
textarea { font-family: inherit; resize: vertical; }

.input-affix { display: flex; align-items: stretch; }
.input-affix .affix {
  display: grid; place-items: center; padding: 0 0.65rem; border: 1px solid var(--border);
  border-right: 0; border-radius: 8px 0 0 8px; background: var(--surface-2); color: var(--text-muted); font-family: var(--mono);
}
.input-affix input { border-radius: 0 8px 8px 0; }
.input-affix--end .affix { border: 1px solid var(--border); border-left: 0; border-radius: 0 8px 8px 0; order: 2; }
.input-affix--end input { border-radius: 8px 0 0 8px; }

.radio-row { display: flex; flex-wrap: wrap; gap: 0.85rem; margin-top: 0.5rem; }
.radio-row label { display: inline-flex; align-items: center; gap: 0.35rem; font-weight: 500; font-size: 0.88rem; margin: 0; }
.switch { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 500 !important; }

.calc-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }

.btn {
  padding: 0.6rem 1.1rem; border-radius: 9px; font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
}
.btn:hover { border-color: var(--accent); }
.btn--primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn--primary:hover { background: #67e8f9; }
.linkish { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 0; text-decoration: underline; }
.icon-btn { background: none; border: 0; color: var(--text-muted); font-size: 1.5rem; line-height: 1; cursor: pointer; padding: 0 0.25rem; }

/* front page quick calculator */

/* Front-page quick calc is a band in its own right, not a hero appendix:
   it gets the same 3rem rhythm as .section and the alt surface so the
   odd/even banding down the page stays intact. */
.calc-shell--quick {
  padding: 3rem 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
/* On the alt surface the results card would sit at the same value as its
   own background, so lift it one step. */
.calc-shell--quick .calc-results { background: var(--surface-2); }
.quick-layout {
  display: grid; gap: 1.5rem; align-items: start;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}
.quick-layout > * { min-width: 0; }
@media (max-width: 900px) { .quick-layout { grid-template-columns: 1fr; } }

.quick__h2 { margin-bottom: 0.25rem; }
.quick__lead { color: var(--text-muted); margin-bottom: 1.25rem; }
.quick-fields { display: grid; gap: 0.9rem 1rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

/* Seven compact year inputs. Narrower than a normal field because each holds
   a single small number and the set has to read as one series. */
.year-grid { display: grid; gap: 0.6rem 0.7rem; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); margin-bottom: 1rem; }
.year-grid .field { margin-bottom: 0; }
.year-grid label { font-size: 0.78rem; font-weight: 500; color: var(--text-muted); }
.year-grid input { padding: 0.45rem 0.5rem; font-size: 0.9rem; }
.pseudo-label { display: block; font-size: 0.9rem; font-weight: 600; margin-bottom: 0.3rem; }

.upsell { border-top: 1px solid var(--border); margin-top: 1rem; padding-top: 1rem; }
.upsell p { color: var(--text-muted); font-size: 0.9rem; }
.upsell .btn { display: inline-block; text-decoration: none; text-align: center; }

/* results */

.calc-results { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 1.25rem; min-width: 0; }
.result-headline { border-bottom: 1px solid var(--border); padding-bottom: 1rem; margin-bottom: 1rem; }
.result-headline__label { color: var(--text-muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; margin: 0; }
.result-headline__value { font-family: var(--mono); font-size: clamp(1.9rem, 5vw, 2.75rem); font-weight: 700; color: var(--accent); margin: 0.15rem 0; font-variant-numeric: tabular-nums; }
.result-headline__sub { color: var(--text-muted); font-size: 0.95rem; margin: 0; }
.result-headline__sub strong { color: var(--text); font-family: var(--mono); }

.result-grid { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin: 0 0 1rem; }
.result-grid div { background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 0.6rem 0.7rem; }
.result-grid dt { color: var(--text-muted); font-size: 0.78rem; margin-bottom: 0.15rem; }
.result-grid dd { margin: 0; font-family: var(--mono); font-weight: 650; font-variant-numeric: tabular-nums; }

.result-note { color: var(--amber); font-size: 0.9rem; font-weight: 600; }
/* Cycle-position readout. Colour carries emphasis, never meaning on its own —
   the sentence states the finding in full for anyone who cannot see the hue. */
.result-note--peak { color: var(--neg); }
.result-note--trough { color: var(--amber); }
.result-note--mid { color: var(--text-muted); font-weight: 500; }

.working { border-top: 1px solid var(--border); padding-top: 1rem; margin-top: 0.5rem; }
.working__h { font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.working__note { color: var(--text-muted); font-size: 0.85rem; margin: 0.4rem 0 0; }
.formula {
  font-family: var(--mono); font-size: 0.86rem; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.7rem 0.8rem; overflow-x: auto; margin: 0; color: #cbd8e6;
}
.formula--static { font-size: 0.95rem; }
.freq-compare { border-top: 1px solid var(--border); padding-top: 1rem; margin-top: 1rem; }

/* tables */

.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.mini-table { margin-top: 0.6rem; font-size: 0.88rem; }
/* The sensitivity grid is 6 columns; below this it becomes unreadable, so let
   it scroll inside .table-scroll rather than squash. Scoped to that grid so
   the 3-column frequency table is free to fit narrow screens without scroll. */
.mini-table--grid { min-width: 430px; }
.data-table { font-size: 0.88rem; min-width: 780px; }
th, td { padding: 0.5rem 0.7rem; text-align: right; border-bottom: 1px solid var(--border); font-family: var(--mono); }
thead th { background: var(--surface-2); color: var(--text-muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; font-family: var(--sans); position: sticky; top: 0; }
tbody th[scope="row"] { text-align: left; color: var(--text-muted); font-weight: 600; }
tbody tr:last-child td, tbody tr:last-child th { border-bottom: 0; }
td.pos, .pos { color: var(--pos); }
td.neg, .neg { color: var(--neg); }
td.muted, .muted { color: var(--text-muted); }

/* ---------------------------------------------------------------- FAQ */

.faq-tabs { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1.25rem; }
.faq-tab {
  padding: 0.45rem 0.9rem; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-muted); font: inherit; font-size: 0.88rem; font-weight: 600; cursor: pointer;
}
.faq-tab[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.faq-panel > h3 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.faq-item { border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); margin-bottom: 0.55rem; }
.faq-item summary { cursor: pointer; padding: 0.75rem 1rem; list-style: none; display: flex; align-items: center; gap: 0.5rem; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; margin-left: auto; color: var(--accent); font-family: var(--mono); font-size: 1.15rem; }
.faq-item[open] summary::after { content: "\2212"; }
.faq-item summary h4 { margin: 0; font-size: 0.98rem; font-weight: 600; }
.faq-item p { margin: 0; padding: 0 1rem 0.9rem; color: var(--text-muted); }

/* No JS: every panel stays visible, so all answers remain readable. */
.js .faq-panel[hidden] { display: none; }

/* ---------------------------------------------------------------- footer */

.site-foot { border-top: 1px solid var(--border); padding: 2rem 0; margin-top: 1rem; }
.site-foot__inner { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between; }
.site-foot__copy { color: var(--text-muted); font-size: 0.88rem; margin: 0; }
.site-foot__links { display: flex; flex-wrap: wrap; gap: 1.1rem; font-size: 0.88rem; }

/* ---------------------------------------------------------------- contact */

.contact-dialog {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  color: var(--text); padding: 0; width: min(100% - 2rem, 520px); max-height: 90vh;
}
.contact-dialog::backdrop { background: rgba(3, 7, 12, 0.72); }
.contact-form { padding: 1.25rem; }
.contact-form__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.contact-form__head h2 { margin: 0; font-size: 1.2rem; }
.contact-form__lead, .contact-form__hint { color: var(--text-muted); font-size: 0.88rem; }
.contact-form label { display: block; font-size: 0.88rem; font-weight: 600; margin: 0.85rem 0 0.3rem; }
.contact-form__status { min-height: 1.3rem; font-size: 0.9rem; margin: 0.75rem 0 0; }
.contact-form__status.is-error { color: var(--neg); }
.contact-form__status.is-ok { color: var(--pos); }
.contact-form__actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 1rem; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------------------------------------------------------------- motion */

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  .tool-card:hover { transform: none; }
}
