/* ============================================================
   Max Forex — warm earth editorial, terminal chrome
   ============================================================ */

:root {
  --bg: #f5efe4;
  --bg-raise: #fbf7ef;
  --bg-sink: #ece3d4;
  --ink: #2b1e14;
  --ink-soft: #5a4a3c;
  --ink-faint: #7d6b5b;
  --accent: #c25a37;
  --accent-ink: #8f3d21;
  --secondary: #6a7a4a;
  --line: #d9cdb9;
  --line-strong: #c3b39a;
  --shadow: 0 1px 0 rgba(43, 30, 20, .05), 0 14px 34px -22px rgba(43, 30, 20, .35);
  --radius: 4px;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --serif: 'Fraunces', 'Cormorant Garamond', Georgia, serif;
  --sans: 'DM Sans', 'Inter', system-ui, -apple-system, sans-serif;
  --grain-opacity: .05;
  --on-accent: #ffffff;
  --wrap: 76rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1410;
    --bg-raise: #221a15;
    --bg-sink: #14100c;
    --ink: #f0e7da;
    --ink-soft: #cbbcaa;
    --ink-faint: #a2917f;
    --accent: #e07a52;
    --accent-ink: #f0a184;
    --secondary: #9aab74;
    --line: #3a2e25;
    --line-strong: #4d3d31;
    --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 18px 40px -24px rgba(0, 0, 0, .8);
    --grain-opacity: .07;
    --on-accent: #1a1410;
  }
}

:root[data-theme="dark"] {
  --bg: #1a1410;
  --bg-raise: #221a15;
  --bg-sink: #14100c;
  --ink: #f0e7da;
  --ink-soft: #cbbcaa;
  --ink-faint: #a2917f;
  --accent: #e07a52;
  --accent-ink: #f0a184;
  --secondary: #9aab74;
  --line: #3a2e25;
  --line-strong: #4d3d31;
  --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 18px 40px -24px rgba(0, 0, 0, .8);
  --grain-opacity: .07;
  --on-accent: #1a1410;
}

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

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

body {
  margin: 0;
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.7;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img, svg { max-width: 100%; }

a { color: var(--accent-ink); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { color: var(--accent); }

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

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 99;
  background: var(--accent); color: var(--on-accent); padding: .6rem 1rem; border-radius: 0 0 var(--radius) 0;
}
.skip:focus { left: 0; }

/* ---------- animated noise field ---------- */
.noise-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

.grain {
  position: fixed;
  inset: -10%;
  z-index: 0;
  pointer-events: none;
  opacity: var(--grain-opacity);
  filter: url(#grain);
  background: var(--ink);
  mix-blend-mode: multiply;
}
:root[data-theme="dark"] .grain { mix-blend-mode: screen; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .grain { mix-blend-mode: screen; }
}

/* ---------- shell / terminal chrome ---------- */
.shell {
  position: relative;
  z-index: 1;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 1.25rem clamp(1rem, 4vw, 2.5rem) 3rem;
}

.chrome {
  position: sticky;
  top: 0;
  z-index: 20;
  margin-bottom: clamp(2rem, 6vw, 4rem);
  background: color-mix(in srgb, var(--bg-raise) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.titlebar {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .55rem .85rem;
  border-bottom: 1px solid var(--line);
  background: var(--bg-sink);
}

.dots { display: inline-flex; gap: .4rem; flex: 0 0 auto; }
.dots i { width: .62rem; height: .62rem; border-radius: 50%; display: block; }
.d1 { background: var(--accent); }
.d2 { background: var(--secondary); }
.d3 { background: var(--line-strong); }

.titlebar-label {
  font-family: var(--mono);
  font-size: .74rem;
  letter-spacing: .02em;
  color: var(--ink-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
}

.theme-toggle {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  min-height: 44px;
  padding: .35rem .7rem;
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  cursor: pointer;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.tt-icon { font-size: .85rem; line-height: 1; }

.tabs {
  display: flex;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: .5rem 1rem;
  font-family: var(--mono);
  font-size: .78rem;
  letter-spacing: .02em;
  color: var(--ink-faint);
  text-decoration: none;
  border-right: 1px solid var(--line);
  border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--ink); background: var(--bg-sink); }
.tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- prompt lines ---------- */
.prompt, .footer-line, .contact-aside p {
  font-family: var(--mono);
  font-size: .8rem;
  letter-spacing: .01em;
  color: var(--ink-faint);
  margin: 0 0 1rem;
}
.sigil { color: var(--accent); margin-right: .5ch; }

/* ---------- hero ---------- */
.hero { padding-bottom: clamp(3rem, 9vw, 6rem); }

.hero-h1 {
  position: relative;
  margin: 0 0 1.5rem;
  font-family: var(--serif);
  font-size: clamp(2.4rem, 8.5vw, 5.6rem);
  line-height: 1.02;
  letter-spacing: -.02em;
  font-variation-settings: 'wght' 300, 'opsz' 120;
  font-weight: 300;
  max-width: 20ch;
  text-wrap: balance;
  animation: weigh linear both;
  animation-timeline: scroll(root);
  animation-range: 0 30vh;
}

@keyframes weigh {
  from { font-variation-settings: 'wght' 200, 'opsz' 120; }
  to   { font-variation-settings: 'wght' 880, 'opsz' 120; }
}

.hero-h1 .default,
.hero-h1 .alt {
  display: block;
  transition: opacity .45s ease;
}
.hero-h1 .alt {
  position: absolute;
  inset: 0;
  opacity: 0;
  color: var(--accent);
  font-style: italic;
  pointer-events: none;
}
.hero-h1:hover .default,
.hero-h1:focus-within .default { opacity: 0; }
.hero-h1:hover .alt,
.hero-h1:focus-within .alt { opacity: 1; }

.hero-sub {
  max-width: 62ch;
  font-size: 1.1rem;
  color: var(--ink-soft);
  margin: 0 0 2.5rem;
}

.hero-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 1px;
  margin: 0 0 2.5rem;
  padding: 0;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.hero-facts > div {
  background: var(--bg-raise);
  padding: .9rem 1rem;
}
.hero-facts dt {
  font-family: var(--mono);
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--ink-faint);
  margin-bottom: .3rem;
}
.hero-facts dd {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.02rem;
  font-variation-settings: 'wght' 500;
}

.scroll-cue { margin: 0; }
.caret {
  display: inline-block;
  width: .55ch;
  height: 1em;
  margin-left: .35ch;
  background: var(--accent);
  vertical-align: -.15em;
  animation: blink 1.15s steps(1, end) infinite;
}
@keyframes blink { 0%, 49% { opacity: 1 } 50%, 100% { opacity: 0 } }

/* ---------- sections ---------- */
.block {
  padding: clamp(2.5rem, 7vw, 4.5rem) 0;
  border-top: 1px solid var(--line);
}

.block h2 {
  font-family: var(--serif);
  font-size: clamp(1.7rem, 4.2vw, 2.7rem);
  line-height: 1.12;
  letter-spacing: -.015em;
  font-variation-settings: 'wght' 460;
  font-weight: 460;
  margin: 0 0 1.25rem;
  max-width: 24ch;
  text-wrap: balance;
}

.prose { max-width: 68ch; }
.prose p { margin: 0 0 1.15rem; color: var(--ink-soft); }
.prose p:last-child { margin-bottom: 0; }

.lede {
  max-width: 62ch;
  color: var(--ink-soft);
  margin: 0 0 2rem;
}

/* ---------- cards ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15.5rem, 1fr));
  gap: 1rem;
  margin-top: 2.5rem;
}
.cards--wide { grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); }

.card {
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.35rem 1.35rem 1.5rem;
  box-shadow: var(--shadow);
}
.card h3 {
  font-family: var(--serif);
  font-size: 1.16rem;
  font-variation-settings: 'wght' 560;
  font-weight: 560;
  margin: 0 0 .6rem;
  line-height: 1.25;
}
.card p { margin: 0; color: var(--ink-soft); font-size: .98rem; }
.card-meta {
  font-family: var(--mono);
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--secondary);
  margin: 0 0 .7rem !important;
}

/* ---------- sessions table ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-raise);
  box-shadow: var(--shadow);
}
.sessions-table {
  width: 100%;
  min-width: 34rem;
  border-collapse: collapse;
  font-size: .96rem;
}
.sessions-table th,
.sessions-table td {
  text-align: left;
  padding: .85rem 1.1rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.sessions-table thead th {
  font-family: var(--mono);
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--ink-faint);
  background: var(--bg-sink);
  font-weight: 400;
}
.sessions-table tbody th {
  font-family: var(--serif);
  font-variation-settings: 'wght' 540;
  font-weight: 540;
  white-space: nowrap;
}
.sessions-table tbody td:nth-child(2) {
  font-family: var(--mono);
  font-size: .82rem;
  color: var(--accent-ink);
  white-space: nowrap;
}
.sessions-table tbody td { color: var(--ink-soft); }
.sessions-table tbody tr:last-child th,
.sessions-table tbody tr:last-child td { border-bottom: 0; }

/* ---------- stats ---------- */
.stats {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.stats li {
  background: var(--bg-raise);
  padding: 1.3rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: .35rem;
}
.stat-num {
  font-family: var(--serif);
  font-size: clamp(1.6rem, 3.6vw, 2.2rem);
  font-variation-settings: 'wght' 620;
  line-height: 1;
  color: var(--accent);
}
.stat-label {
  font-family: var(--mono);
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--ink-faint);
  line-height: 1.5;
}

.fine {
  margin: 1.5rem 0 0;
  max-width: 62ch;
  font-size: .88rem;
  color: var(--ink-faint);
  border-left: 2px solid var(--line-strong);
  padding-left: 1rem;
}

/* ---------- learn-the-basics ---------- */
.sub-head {
  font-family: var(--mono);
  font-size: .82rem;
  font-weight: 400;
  letter-spacing: .02em;
  color: var(--ink-faint);
  margin: 2.75rem 0 1.25rem;
  padding-bottom: .6rem;
  border-bottom: 1px solid var(--line);
}

.glossary {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.glossary > div {
  background: var(--bg-raise);
  padding: 1.15rem 1.25rem 1.3rem;
}
.glossary dt {
  font-family: var(--serif);
  font-size: 1.1rem;
  font-variation-settings: 'wght' 580;
  font-weight: 580;
  color: var(--accent-ink);
  margin-bottom: .45rem;
}
.glossary dd {
  margin: 0;
  font-size: .95rem;
  color: var(--ink-soft);
  line-height: 1.65;
}

.mistakes {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: mistake;
  max-width: 68ch;
}
.mistakes li {
  counter-increment: mistake;
  position: relative;
  padding: 0 0 1.15rem 3rem;
  color: var(--ink-soft);
}
.mistakes li::before {
  content: counter(mistake, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: .1rem;
  font-family: var(--mono);
  font-size: .78rem;
  color: var(--accent);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: .2rem .45rem;
  line-height: 1;
}
.mistakes li:last-child { padding-bottom: 0; }
.mistakes strong {
  display: block;
  font-family: var(--serif);
  font-size: 1.06rem;
  font-variation-settings: 'wght' 560;
  font-weight: 560;
  color: var(--ink);
  margin-bottom: .25rem;
}

.callout {
  margin-top: 2.75rem;
  max-width: 62ch;
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-left: 3px solid var(--secondary);
  border-radius: var(--radius);
  padding: 1.35rem 1.5rem;
  box-shadow: var(--shadow);
}
.callout-line {
  font-family: var(--mono);
  font-size: .8rem;
  color: var(--ink-faint);
  margin: 0 0 .7rem;
}
.callout p:last-child { margin: 0; color: var(--ink-soft); }

/* ---------- registration ---------- */
.register-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: start;
}
.register-form { max-width: none; margin-bottom: 0; }

.register-aside {
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem 1.5rem 1.6rem;
  box-shadow: var(--shadow);
}
.register-aside h3 {
  font-family: var(--serif);
  font-size: 1.2rem;
  font-variation-settings: 'wght' 560;
  font-weight: 560;
  margin: 0 0 1rem;
}
.steps {
  margin: 0 0 1.5rem;
  padding: 0;
  list-style: none;
  counter-reset: step;
}
.steps li {
  counter-increment: step;
  position: relative;
  padding-left: 1.9rem;
  margin-bottom: .85rem;
  font-size: .94rem;
  color: var(--ink-soft);
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: .15rem;
  width: 1.25rem;
  height: 1.25rem;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: .68rem;
  color: var(--on-accent);
  background: var(--accent);
  border-radius: 50%;
}
.steps li:last-child { margin-bottom: 0; }

.register-facts {
  margin: 0 0 1.25rem;
  padding: 0;
  border-top: 1px solid var(--line);
}
.register-facts > div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: .6rem 0;
  border-bottom: 1px solid var(--line);
}
.register-facts dt {
  font-family: var(--mono);
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--ink-faint);
  padding-top: .15rem;
}
.register-facts dd {
  margin: 0;
  text-align: right;
  font-size: .92rem;
  color: var(--ink);
}
.register-aside .fine { margin-top: 0; font-size: .84rem; }

/* ---------- contact form ---------- */
.contact-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.1rem;
  max-width: 46rem;
  margin-bottom: 2.5rem;
}
.field { display: flex; flex-direction: column; gap: .4rem; }
.field:nth-of-type(3),
.field:nth-of-type(4) { grid-column: 1 / -1; }

.field label {
  font-family: var(--mono);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-faint);
}
.field input,
.field select,
.field textarea {
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: var(--bg-raise);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: .7rem .8rem;
  min-height: 44px;
  width: 100%;
}
.field textarea { resize: vertical; min-height: 8rem; }
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
  outline-offset: 1px;
}

.submit {
  grid-column: 1 / -1;
  justify-self: start;
  font-family: var(--mono);
  font-size: .82rem;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--on-accent);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: .8rem 1.6rem;
  min-height: 44px;
  cursor: pointer;
}
.submit:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.submit:disabled { opacity: .6; cursor: progress; }

.form-status {
  grid-column: 1 / -1;
  margin: 0;
  font-family: var(--mono);
  font-size: .82rem;
  color: var(--secondary);
}
.form-status.is-error { color: var(--accent-ink); }

.contact-aside p { margin: 0 0 .4rem; }

/* ---------- footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  padding-top: 2rem;
  margin-top: 1rem;
}
.footer-note {
  max-width: 60ch;
  font-size: .9rem;
  color: var(--ink-soft);
  margin: 0 0 1.25rem;
}
.attribution { margin: 0; font-size: .82rem; }
.attribution a { color: var(--ink-faint); }
.attribution a:hover { color: var(--accent); }
.muted { color: var(--ink-faint); }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .register-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .contact-form { grid-template-columns: 1fr; }
  .glossary { grid-template-columns: 1fr; }
  .register-facts > div { flex-direction: column; gap: .15rem; }
  .register-facts dd { text-align: left; }
  .hero-h1 { max-width: none; }
  .hero-h1 .alt { position: static; inset: auto; }
  .hero-h1:hover .default { opacity: 1; }
  .hero-h1:hover .alt { opacity: 0; }
  .titlebar-label { font-size: .68rem; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .hero-h1 { animation: none; font-variation-settings: 'wght' 420, 'opsz' 120; }
  .caret { animation: none; }
  .hero-h1 .default,
  .hero-h1 .alt { transition: none; }
  .grain { opacity: calc(var(--grain-opacity) * .6); }
  #grain-turb animate { display: none; }
}

/* ---------- scroll-driven fallback ---------- */
@supports not (animation-timeline: scroll()) {
  .hero-h1 { font-variation-settings: 'wght' 420, 'opsz' 120; }
}
