/* ============================================================
   AQA Course Welcome — editorial one-pager
   Base Gallery feel: warm paper, deep ink, single accent.
   ============================================================ */

:root {
  /* palette */
  --paper:       #F6F3EC;
  --paper-soft:  #FFFEFB;
  --ink:         #16151A;
  --ink-soft:    #54505A;
  --ink-faint:   #918B7C;
  --rule:        #E1DBCE;
  --rule-soft:   #ECE6D6;
  --accent:      #2D5BFF;
  --accent-soft: #EAF0FF;
  --ghost:       #D9D2C2;

  /* typography — EN (default) */
  --font-display: "Bricolage Grotesque", system-ui, sans-serif;
  --font-serif:   "Newsreader", "Iowan Old Style", Georgia, serif;
  --font-body:    "Inter", system-ui, sans-serif;
  --font-mono:    "Martian Mono", ui-monospace, "SF Mono", monospace;

  /* layout */
  --max-content: 720px;
  --rail-width:  260px;
  --gutter:      80px;
  --page-pad:    32px;
}

html[lang="ru"] {
  --font-display: "Manrope", system-ui, sans-serif;
  --font-serif:   "Inter", system-ui, sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, monospace;
}

html[lang="ka"] {
  --font-display: "Noto Sans Georgian", system-ui, sans-serif;
  --font-serif:   "Noto Serif Georgian", "Iowan Old Style", Georgia, serif;
  --font-body:    "Noto Sans Georgian", system-ui, sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  position: relative;
  min-height: 100vh;
  overflow-x: hidden;
}

::selection {
  background: var(--accent);
  color: var(--paper);
}

/* ---- grain / paper texture ------------------------------- */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.06;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 240 240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.95' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1.6 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 240px 240px;
}

/* ---- reading progress (top hairline) --------------------- */
.progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  z-index: 100;
  pointer-events: none;
}
.progress-bar {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 60ms linear;
  will-change: transform;
}

/* ---- topbar ---------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(246, 243, 236, 0.82);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--rule);
}
.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--page-pad);
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--ink);
  text-decoration: none;
  min-width: 0;
}
.brand-mark {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  padding: 5px 9px 4px;
  border: 1px solid var(--ink);
  color: var(--ink);
  border-radius: 2px;
  line-height: 1;
}
.brand-meta {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- lang switch ----------------------------------------- */
.lang-switch {
  display: inline-flex;
  border: 1px solid var(--rule);
  background: var(--paper-soft);
  padding: 3px;
  border-radius: 999px;
  gap: 1px;
  flex-shrink: 0;
}
.lang-opt {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  padding: 6px 12px;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  border-radius: 999px;
  line-height: 1;
  transition: color 180ms ease, background 220ms ease;
}
.lang-opt:hover { color: var(--ink); }
.lang-opt.is-active {
  background: var(--ink);
  color: var(--paper);
}

/* ---- hero ------------------------------------------------ */
.hero {
  max-width: 1080px;
  margin: 120px auto 80px;
  padding: 0 var(--page-pad);
  position: relative;
  z-index: 2;
}
.hero-kicker {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 36px;
  display: inline-flex;
  align-items: center;
  gap: 12px;
}
.hero-kicker::before {
  content: "";
  display: inline-block;
  width: 24px;
  height: 1px;
  background: var(--ink-soft);
}
.hero-title {
  font-family: var(--font-display);
  font-size: clamp(48px, 9vw, 104px);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 0.96;
  color: var(--ink);
  margin: 0 0 36px;
  max-width: 14ch;
}
.hero-lede {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(20px, 2.4vw, 28px);
  line-height: 1.4;
  color: var(--ink);
  margin: 0 0 40px;
  max-width: 620px;
}
.hero-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0;
}

/* ---- layout grid ----------------------------------------- */
.layout {
  max-width: 1200px;
  margin: 64px auto 120px;
  padding: 0 var(--page-pad);
  display: grid;
  grid-template-columns: var(--rail-width) 1fr;
  gap: var(--gutter);
  align-items: start;
  position: relative;
  z-index: 2;
}

/* ---- rail / TOC ------------------------------------------ */
.rail {
  position: sticky;
  top: 96px;
  align-self: start;
}

.toc-toggle { display: none; }

.toc-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 18px;
  padding-left: 14px;
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--rule);
}

.toc-item {
  border-bottom: 1px solid var(--rule);
}

.toc-link {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 0 14px 14px;
  color: var(--ink-soft);
  text-decoration: none;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.4;
  position: relative;
  transition: color 200ms ease, padding-left 220ms cubic-bezier(0.2,0.7,0.2,1);
}
.toc-link:hover {
  color: var(--ink);
}
.toc-link::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 0;
  background: var(--accent);
  transition: height 240ms cubic-bezier(0.2,0.7,0.2,1);
}
.toc-item.is-active .toc-link {
  color: var(--ink);
}
.toc-item.is-active .toc-link::before { height: 22px; }
.toc-num {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  flex-shrink: 0;
  padding-top: 3px;
  transition: color 200ms ease;
}
.toc-item.is-active .toc-num { color: var(--accent); }
.toc-text {
  flex: 1;
  font-weight: 500;
}

/* ---- content / sections ---------------------------------- */
.content {
  max-width: var(--max-content);
  min-width: 0;
}

.section {
  padding: 72px 0;
  border-top: 1px solid var(--rule);
  scroll-margin-top: 96px;
}
.section:first-child {
  padding-top: 16px;
  border-top: 0;
}

.section-head {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 28px;
  align-items: end;
  margin-bottom: 40px;
  padding-bottom: 24px;
  border-bottom: 1px dotted var(--rule);
}

.section-num {
  font-family: var(--font-display);
  font-size: clamp(64px, 8.5vw, 108px);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 0.78;
  color: var(--ghost);
  text-decoration: none;
  display: inline-block;
  cursor: pointer;
  transition: color 220ms ease, transform 220ms ease;
  position: relative;
}
.section-num:hover {
  color: var(--accent);
}
.section-num:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 2px;
}

.section-title {
  font-family: var(--font-display);
  font-size: clamp(28px, 3.4vw, 40px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.08;
  color: var(--ink);
  margin: 0 0 4px;
}

.section-body {
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.7;
  color: var(--ink);
}
.section-body p {
  margin: 0 0 22px;
}
.section-body p:last-child { margin-bottom: 0; }
.section-body strong { font-weight: 600; color: var(--ink); }
.section-body em { font-style: italic; }

.section-body code,
.section-body .code {
  font-family: var(--font-mono);
  font-size: 0.84em;
  background: var(--paper-soft);
  border: 1px solid var(--rule);
  padding: 1px 6px 0;
  border-radius: 3px;
  color: var(--ink);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.section-body h3,
.section-body .sub {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin: 36px 0 16px;
  color: var(--ink);
}

.section-body ul {
  list-style: none;
  margin: 0 0 24px;
  padding: 0;
}
.section-body ul > li {
  position: relative;
  padding-left: 22px;
  margin: 0 0 12px;
}
.section-body ul > li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.7em;
  width: 8px;
  height: 1px;
  background: var(--ink-faint);
}
.section-body ul > li:last-child { margin-bottom: 0; }

.section-body ol {
  list-style: none;
  margin: 0 0 24px;
  padding: 0;
  counter-reset: olist;
}
.section-body ol > li {
  counter-increment: olist;
  position: relative;
  padding-left: 38px;
  margin: 0 0 22px;
  min-height: 1.6em;
}
.section-body ol > li::before {
  content: counter(olist, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 2px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--accent);
  width: 26px;
}
.section-body ol > li:last-child { margin-bottom: 0; }

.section-body a {
  color: var(--ink);
  text-decoration-line: underline;
  text-decoration-color: var(--ghost);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  transition: text-decoration-color 200ms ease, color 200ms ease;
}
.section-body a:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

/* ---- callout (Golden Rule section) ----------------------- */
.callout {
  background: var(--paper-soft);
  border-left: 3px solid var(--accent);
  padding: 32px 36px;
  margin: 32px 0;
  position: relative;
}
.callout::after {
  content: "";
  position: absolute;
  top: 16px;
  right: 18px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}
.callout-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 14px;
}
.callout-quote {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(20px, 2.2vw, 26px);
  line-height: 1.42;
  color: var(--ink);
  margin: 0;
}
.callout-quote em {
  font-style: italic;
  font-weight: 500;
  color: var(--accent);
}

/* ---- footer ---------------------------------------------- */
.foot {
  margin-top: 120px;
  padding-top: 0;
}

.foot-signoff {
  font-family: var(--font-display);
  font-size: clamp(40px, 6vw, 72px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.0;
  color: var(--ink);
  margin: 0 0 36px;
}

.foot-chat {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 18px;
  line-height: 1.5;
  color: var(--ink-soft);
  margin: 0 0 72px;
  max-width: 540px;
}
.foot-chat strong {
  font-style: normal;
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--ink);
  font-size: 16px;
  letter-spacing: -0.005em;
}

.foot-divider {
  height: 1px;
  background: var(--rule);
  margin: 0 0 32px;
  max-width: 80px;
}

.foot-signature {
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  margin: 0;
  flex-wrap: wrap;
}
.foot-sig-eyebrow {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-right: 6px;
}
.foot-sig-name { color: var(--ink); font-weight: 500; }
.foot-sig-sep { color: var(--ink-faint); }
.foot-sig-mail {
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 1px;
  transition: color 200ms ease, border-color 200ms ease;
}
.foot-sig-mail:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ---- toast ----------------------------------------------- */
.toast {
  position: fixed;
  bottom: 36px;
  left: 50%;
  transform: translate(-50%, 18px);
  padding: 11px 20px 10px;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 999px;
  opacity: 0;
  transition: opacity 220ms ease, transform 220ms cubic-bezier(0.2,0.7,0.2,1);
  pointer-events: none;
  z-index: 200;
  box-shadow: 0 10px 30px -8px rgba(22, 21, 26, 0.18);
}
.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---- entrance animations --------------------------------- */
.hero > * {
  opacity: 0;
  transform: translateY(14px);
  animation: rise 720ms cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
}
.hero .hero-kicker { animation-delay: 80ms; }
.hero .hero-title  { animation-delay: 180ms; }
.hero .hero-lede   { animation-delay: 320ms; }
.hero .hero-meta   { animation-delay: 460ms; }

@keyframes rise {
  to { opacity: 1; transform: translateY(0); }
}

/* ---- mobile ---------------------------------------------- */
@media (max-width: 920px) {
  :root {
    --rail-width: auto;
    --gutter: 0;
    --page-pad: 22px;
  }

  .topbar-inner { height: 56px; gap: 12px; }
  .brand-meta { display: none; }

  .hero { margin: 72px auto 56px; }
  .hero-title { letter-spacing: -0.03em; }
  .hero-lede  { font-size: 19px; }

  .layout {
    grid-template-columns: 1fr;
    gap: 24px;
    margin-top: 40px;
    margin-bottom: 64px;
  }

  .rail { position: static; top: auto; }
  .toc-eyebrow { display: none; }

  .toc-toggle {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    background: var(--paper-soft);
    border: 1px solid var(--rule);
    border-radius: 4px;
    color: var(--ink);
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
  }
  .toc-toggle .toc-label { color: var(--ink); }
  .toc-toggle .toc-chev {
    color: var(--ink-soft);
    transition: transform 220ms cubic-bezier(0.2,0.7,0.2,1);
  }
  .toc-toggle[aria-expanded="true"] .toc-chev { transform: rotate(180deg); }

  .toc-nav {
    display: none;
    margin-top: 6px;
    border: 1px solid var(--rule);
    border-radius: 4px;
    overflow: hidden;
    background: var(--paper-soft);
  }
  .toc-nav.is-open { display: block; }
  .toc-list { border-top: 0; }
  .toc-link { padding: 12px 18px; }

  .section { padding: 56px 0; scroll-margin-top: 80px; }
  .section-head { grid-template-columns: 1fr; gap: 4px; margin-bottom: 28px; padding-bottom: 18px; }
  .section-num { font-size: 56px; line-height: 0.9; }
  .section-title { font-size: 26px; }

  .callout { padding: 24px 24px; margin: 24px 0; }

  .foot { margin-top: 80px; }
  .foot-signoff { font-size: 36px; }
  .foot-chat { font-size: 16px; margin-bottom: 48px; }
}

/* ---- reduced motion -------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .hero > * { opacity: 1; transform: none; }
}
