/* Two inks on paper: ultramarine for everything, pink only for what you're touching. */
:root {
  --paper: #F3F5FA;
  --ink: #1638C9;
  --ink-soft: #4D5FA8;
  --field: #1638C9;        /* the hero */
  --on-field: #F3F5FA;
  --signal: #E0115F;       /* selected slice, focus, cursor */
  --on-signal: #FFFFFF;
  --rule: rgba(22, 56, 201, 0.18);

  --wide: 125%;            /* Archivo width axis */
  --gutter: clamp(16px, 4vw, 48px);
  --measure: 66ch;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);     /* long, soft landing */
  --ease-flow: cubic-bezier(0.65, 0, 0.35, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0B1240;
    --ink: #DCE3FF;
    --ink-soft: #9AA6DD;
    --signal: #FF4F8B;
    --on-signal: #0B1240;
    --rule: rgba(220, 227, 255, 0.18);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
/* Lenis (smooth scrolling) takes over scrolling when it's running */
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-stopped { overflow: hidden; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Archivo", system-ui, sans-serif;
  font-size: 18px;
  line-height: 1.55;
  font-stretch: 100%;
  overflow-x: clip;
}
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.18em; transition: text-decoration-color 0.3s; }
a:hover { text-decoration-color: var(--signal); text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--signal); outline-offset: 3px; border-radius: 2px; }
::selection { background: var(--signal); color: var(--on-signal); }

.skip {
  position: absolute; left: var(--gutter); top: -100px; z-index: 60;
  background: var(--signal); color: var(--on-signal); padding: 8px 14px; text-decoration: none;
}
.skip:focus { top: 12px; }

/* ---------- Scroll progress (created by effects.js) and cursor ---------- */
.progress {
  position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 50;
  background: var(--signal); transform-origin: 0 50%; transform: scaleX(0);
  pointer-events: none;
}
/* Bold, rounded arrow: ultramarine everywhere, pink over anything you can click. Native cursor, so no lag. */
html { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cpath d='M6 3.5 L6 25 L11.6 19.8 L15.2 27.6 L19.4 25.8 L15.9 18.2 L23.2 18.2 Z' fill='white' stroke='white' stroke-width='5.5' stroke-linejoin='round'/%3E%3Cpath d='M6 3.5 L6 25 L11.6 19.8 L15.2 27.6 L19.4 25.8 L15.9 18.2 L23.2 18.2 Z' fill='%231638C9' stroke='%231638C9' stroke-width='2.2' stroke-linejoin='round'/%3E%3C/svg%3E") 6 4, auto; }
a, button, .copy, [data-magnetic] { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cpath d='M6 3.5 L6 25 L11.6 19.8 L15.2 27.6 L19.4 25.8 L15.9 18.2 L23.2 18.2 Z' fill='white' stroke='white' stroke-width='5.5' stroke-linejoin='round'/%3E%3Cpath d='M6 3.5 L6 25 L11.6 19.8 L15.2 27.6 L19.4 25.8 L15.9 18.2 L23.2 18.2 Z' fill='%23E0115F' stroke='%23E0115F' stroke-width='2.2' stroke-linejoin='round'/%3E%3C/svg%3E") 6 4, pointer; }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  isolation: isolate;
  min-height: 100svh;
  background: var(--field);
  color: var(--on-field);
  padding: var(--gutter);
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: clamp(24px, 4vh, 48px);
  overflow: hidden;
}
.flow { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.logo {
  display: grid; place-items: center; width: 48px; height: 48px; flex: none;
  border: 1.5px solid color-mix(in srgb, var(--on-field) 55%, transparent); border-radius: 14px;
  font-stretch: var(--wide); font-weight: 800; font-size: 17px; letter-spacing: -0.02em; text-decoration: none;
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}
.logo:hover { background: var(--on-field); color: var(--field); border-color: var(--on-field); }
.site-nav { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px 22px; font-size: 16px; }
.site-nav a { text-decoration: none; padding: 12px 0; position: relative; }
.menu-toggle {
  position: relative; z-index: 2; display: none; align-items: center; gap: 10px; min-height: 48px; padding: 0 18px;
  font: inherit; font-size: 16px; font-weight: 700; color: var(--on-field); background: transparent;
  border: 1.5px solid color-mix(in srgb, var(--on-field) 55%, transparent); border-radius: 999px;
}
.menu-icon { position: relative; width: 18px; height: 2px; background: currentColor; }
.menu-icon::before, .menu-icon::after { content: ""; position: absolute; left: 0; width: 18px; height: 2px; background: currentColor; transition: transform 0.3s var(--ease-out); }
.menu-icon::before { top: -6px; }
.menu-icon::after { top: 6px; }
.menu-open .menu-icon { background: transparent; }
.menu-open .menu-icon::before { transform: translateY(6px) rotate(45deg); }
.menu-open .menu-icon::after { transform: translateY(-6px) rotate(-45deg); }
.site-nav a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 2px; height: 2px; background: currentColor;
  transform: scaleX(0); transform-origin: 100% 50%; transition: transform 0.3s var(--ease-out);
}
.site-nav a:hover::after { transform: scaleX(1); transform-origin: 0 50%; }

.name {
  align-self: end;
  margin: 0;
  font-stretch: var(--wide);
  font-weight: 800;
  /* "Usukhbayar" is about 7.05em wide at this width axis, so 12.5vw always fits the screen */
  font-size: clamp(36px, 12.5vw, 184px);
  line-height: 0.9;
  letter-spacing: -0.035em;
}
/* letters rise out of their line on load (split by effects.js) */
.name .line { display: block; overflow: clip; padding-bottom: 0.12em; margin-bottom: -0.12em; }
.name .ch { display: inline-block; transform: translateY(105%); animation: rise 0.7s var(--ease-out) forwards; animation-delay: calc(var(--i) * 18ms + 0.05s); }
@keyframes rise { to { transform: none; } }

.intro { margin: 0; max-width: 34ch; font-size: clamp(20px, 2.1vw, 28px); line-height: 1.35; }

.hero-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.hero-cta, .hero-ghost {
  display: inline-flex; align-items: center; min-height: 48px; padding: 0 22px; border-radius: 999px;
  font-size: 16px; font-weight: 700; text-decoration: none;
  transition: translate 0.35s var(--ease-out), background-color 0.2s, color 0.2s, border-color 0.2s;
}
.hero-cta { background: var(--on-field); color: var(--field); overflow-wrap: anywhere; }
.hero-cta:hover { background: var(--signal); color: var(--on-signal); }   /* white on #E0115F, navy on the lighter dark-mode pink */
.hero-ghost { border: 1.5px solid color-mix(in srgb, var(--on-field) 55%, transparent); color: var(--on-field); }
.hero-ghost:hover { border-color: var(--on-field); background: var(--on-field); color: var(--field); }
.hero :focus-visible { outline-color: var(--on-field); }

/* ---------- Ticker ---------- */
.ticker { overflow: hidden; background: var(--paper); border-bottom: 1px solid var(--rule); }
.ticker-track {
  display: flex; width: max-content; margin: 0; padding: 18px 0; list-style: none;
  font-stretch: var(--wide); font-weight: 800; font-size: clamp(22px, 3vw, 40px); letter-spacing: -0.02em;
  animation: ticker 26s linear infinite;
}
.ticker-track li { display: flex; align-items: center; padding: 0 0.6em; white-space: nowrap; }
.ticker-track li::after {   /* a small ring between items */
  content: ""; width: 0.42em; height: 0.42em; margin-left: 1.2em; border-radius: 50%;
  border: 0.09em solid var(--signal); flex: none;
}
@keyframes ticker { to { transform: translateX(-50%); } }

/* ---------- Scroll reveals (effects.js adds .is-in) ---------- */
.js [data-reveal] {
  opacity: 0; transform: translateY(18px);
  transition: opacity 0.45s var(--ease-out), transform 0.55s var(--ease-out);
  transition-delay: var(--d, 0s);
}
.js [data-reveal].is-in { opacity: 1; transform: none; }
.js [data-reveal="mask"] { opacity: 1; transform: none; display: block; overflow: clip; padding-bottom: 0.1em; }
.js [data-reveal="mask"] > span { display: inline-block; transform: translateY(110%); transition: transform 0.6s var(--ease-out); }
.js [data-reveal="mask"].is-in > span { transform: none; }
.js [data-reveal="image"] { opacity: 1; transform: none; clip-path: inset(10% 4% 0 4% round 12px); transition: clip-path 0.6s var(--ease-out); }
.js [data-reveal="image"] img { scale: 1.06; transition: scale 0.8s var(--ease-out); }
.js [data-reveal="image"].is-in { clip-path: inset(0 0 0 0 round 12px); }
.js [data-reveal="image"].is-in img { scale: 1; }

/* ---------- Sections ---------- */
main { padding: 0 var(--gutter); }
.section {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 9fr);
  gap: 24px clamp(24px, 4vw, 64px);
  padding: clamp(72px, 11vw, 144px) 0;
  border-top: 1px solid var(--rule);
}
.section:first-child { border-top: 0; }
.section > h2 {
  margin: 0;
  font-stretch: var(--wide);
  font-weight: 800;
  font-size: clamp(22px, 2vw, 28px);
  line-height: 1.1;
  letter-spacing: -0.01em;
  align-self: start;
  position: sticky; top: 28px;
}
.section-body { min-width: 0; }
p { margin: 0 0 1em; max-width: var(--measure); }
/* no lonely last words, no lopsided headings */
p, dd, li { text-wrap: pretty; }
h2, h3 { text-wrap: balance; }
.big { font-size: clamp(24px, 2.6vw, 34px); line-height: 1.3; letter-spacing: -0.01em; max-width: 30ch; }
.prose p:not(.big) { color: var(--ink-soft); }

/* Projects */
.project + .project { margin-top: clamp(96px, 12vw, 160px); }
.project h3 {
  margin: 0;
  font-stretch: var(--wide);
  font-weight: 800;
  font-size: clamp(44px, 7vw, 108px);
  line-height: 0.95;
  letter-spacing: -0.035em;
}
.lede { margin: 12px 0 30px; font-size: clamp(20px, 2vw, 26px); color: var(--ink-soft); }
.shot { margin: 0 0 30px; border-radius: 12px; overflow: hidden; background: rgba(22, 56, 201, 0.06); }
.shot img { width: 100%; }
.shot:hover img { scale: 1.03; transition: scale 0.5s var(--ease-out); }
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 22px; padding: 0; list-style: none; }
.tags li { font-size: 14px; font-weight: 600; padding: 5px 12px; border: 1px solid var(--rule); border-radius: 999px; }
.links { display: flex; flex-wrap: wrap; gap: 12px; }
.links a, .copy {
  display: inline-flex; align-items: center; gap: 8px;
  font: inherit; font-size: 16px; font-weight: 700; text-decoration: none;
  padding: 12px 20px; border-radius: 999px;
  border: 1.5px solid var(--ink); color: var(--ink); background: transparent;
  transition: translate 0.35s var(--ease-out), background-color 0.2s var(--ease-out), color 0.2s var(--ease-out), border-color 0.2s;
}
.links a:hover, .copy:hover { background: var(--ink); color: var(--paper); }
[data-magnetic] { transition: translate 0.35s var(--ease-out), background-color 0.2s var(--ease-out), color 0.2s var(--ease-out), border-color 0.2s; }

.more { margin-top: clamp(96px, 12vw, 160px); }
.more h3, .toolbox h3 { margin: 0 0 20px; font-stretch: var(--wide); font-weight: 800; font-size: 28px; letter-spacing: -0.01em; }
.more dl { margin: 0; max-width: var(--measure); }
.more dt { font-weight: 700; font-size: 20px; }
.more dd { margin: 4px 0 26px; color: var(--ink-soft); }

/* Education and experience: newest first */
.timeline { list-style: none; margin: 0; padding: 0; max-width: var(--measure); position: relative; }
.timeline li { display: grid; grid-template-columns: 9.5em 1fr; gap: 0 24px; padding: 0 0 30px; }
.timeline .when { grid-row: span 2; margin: 0; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.timeline h3 { margin: 0; font-size: 20px; line-height: 1.3; }
.timeline li p:not(.when) { margin: 2px 0 0; color: var(--ink-soft); }

.toolbox { margin-top: 56px; }
.toolbox dl { display: grid; grid-template-columns: 9.5em 1fr; gap: 10px 24px; margin: 0; max-width: var(--measure); }
.toolbox dt { color: var(--ink-soft); }
.toolbox dd { margin: 0; }

/* Contact */
.contact-lead { font-size: clamp(20px, 2vw, 26px); color: var(--ink-soft); margin-bottom: 10px; }
.email {
  display: block; width: fit-content; max-width: 100%;
  font-stretch: var(--wide); font-weight: 800;
  /* the address is about 19.4em wide here: 3.2vw keeps it on one line beside the section title;
     on phones it wraps at the <wbr> before "@" */
  font-size: clamp(20px, 3.2vw, 56px); line-height: 1.1; letter-spacing: -0.03em;
  text-decoration: none;
}
.email > span { background: linear-gradient(var(--signal), var(--signal)) 0 100% / 0 0.08em no-repeat; transition: background-size 0.35s var(--ease-out); }
.email:hover > span { background-size: 100% 0.08em; }
.copy-row { display: flex; align-items: center; gap: 16px; margin: 26px 0 48px; }
.copy[hidden] { display: none; }
.copy-status { font-size: 15px; color: var(--ink-soft); }
.copy-status[data-state="ok"] { color: var(--ink); font-weight: 600; }
.copy-status[data-state="ok"]::before { content: "✓ "; }
.copy-status[data-state="error"] { color: var(--signal); font-weight: 600; }
.socials { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; max-width: 820px; }
.socials a {
  display: grid; gap: 2px; padding: 18px 20px; text-decoration: none;
  border: 1px solid var(--rule); border-radius: 14px;
}
.socials a:hover { border-color: var(--ink); }
.social-name { font-stretch: var(--wide); font-weight: 800; font-size: 20px; }
.social-handle { font-size: 15px; color: var(--ink-soft); overflow-wrap: anywhere; }

.footer {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px;
  padding: 32px var(--gutter) 48px; border-top: 1px solid var(--rule); font-size: 15px; color: var(--ink-soft);
}
.footer p { margin: 0; }
.footer-links { display: flex; flex-wrap: wrap; gap: 0 20px; flex-basis: 100%; }
.footer a { display: inline-block; padding: 8px 0; }

/* ---------- Phones ---------- */
@media (max-width: 760px) {
  body { font-size: 17px; }
  .footer { flex-direction: column; }
  .footer a { padding: 11px 0; }   /* 44px tap targets */
  .copy-row { flex-wrap: wrap; }
  /* the menu button replaces the inline links once effects.js runs; without JS the links stay inline */
  .fx .site-nav {
    position: fixed; inset: 0; z-index: 1; flex-direction: column; justify-content: center; gap: 4px;
    padding: 96px var(--gutter) var(--gutter); background: var(--field);
    font-stretch: var(--wide); font-weight: 800; font-size: clamp(32px, 10vw, 48px); letter-spacing: -0.02em;
    opacity: 0; visibility: hidden; transition: opacity 0.3s var(--ease-out), visibility 0s 0.3s;
  }
  .fx .site-nav a { padding: 8px 0; }
  .fx .menu-toggle { display: inline-flex; }
  .menu-open .site-nav { opacity: 1; visibility: visible; transition: opacity 0.3s var(--ease-out); }
  .menu-open { overflow: hidden; }
  .menu-open .hero { z-index: 45; }    /* above the revealed sections, below the progress bar */
  .menu-open .logo { position: relative; z-index: 2; }
  .site-nav { justify-content: flex-start; gap: 4px 18px; }
  .section { grid-template-columns: 1fr; }
  .section > h2 { position: static; }
  .timeline li, .toolbox dl { grid-template-columns: 1fr; }
  .timeline .when { grid-row: auto; }
  .toolbox dd { margin-bottom: 8px; }
}

/* ---------- Less motion when people ask for it ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .name .ch { transform: none; }
  .js [data-reveal], .js [data-reveal="mask"] > span { opacity: 1; transform: none; }
  .js [data-reveal="image"] { clip-path: none; }
  .js [data-reveal="image"] img { scale: 1; }
}

/* ---------- Print: a clean one-ink CV ---------- */
@media print {
  :root { --paper: #fff; --ink: #000; --ink-soft: #333; --field: #fff; --on-field: #000; --rule: #ccc; }
  .hero { min-height: 0; padding: 0 0 12pt; }
  main, .footer { padding-left: 0; padding-right: 0; }
  .flow, .topbar, .footer-links, .hero-foot, .ticker, .skip, .shot, .copy-row, .progress { display: none !important; }
  .name { font-size: 40pt; }
  .name .ch, .js [data-reveal], .js [data-reveal="mask"] > span { opacity: 1 !important; transform: none !important; }
  .section { grid-template-columns: 1fr; gap: 8pt; padding: 18pt 0; }
  .section > h2 { position: static; }
  .project, .more dd, .timeline li { break-inside: avoid; }
  .project + .project, .more { margin-top: 18pt; }
  .project h3 { font-size: 22pt; }
  .email { font-size: 18pt; }
  a { text-decoration: none; }
  .links a { border: 0; padding: 0; }
  .links a::after { content: " (" attr(href) ")"; font-weight: 400; font-size: 9pt; }
}
