/* Dark palette. Blue = proposed / interactive. Mint = allowed / confirmed. */
:root {
  --bg: #070A11;
  --surface: #0E1420;
  --text: #E8EDF6;
  --muted: #8C97AB;
  --line: rgba(255, 255, 255, 0.14);
  --blue: #5B8CFF;
  --mint: #36E0B1;

  --sans: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;

  --gutter: clamp(20px, 6vw, 96px);
  --rail: 76px;
}

* { box-sizing: border-box; }
/* Page-wide smooth scrolling is deliberately NOT set here: it makes the scroll library measure sections mid-scroll
   after a resize. In-page links get smooth scrolling from main.js instead. */
html { color-scheme: dark; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; text-underline-offset: 4px; }
a:focus-visible, button:focus-visible {
  outline: 3px solid var(--mint);
  outline-offset: 4px;
  border-radius: 3px;
}

.skip { position: absolute; left: -999px; top: 10px; z-index: 20; background: var(--mint); color: #001a12; padding: 8px 12px; font-family: var(--sans); }
.skip:focus { left: 10px; }

/* ---- backdrop and stage ---- */
.glow {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(60vw 50vh at 85% 8%, rgba(91, 140, 255, 0.20), transparent 70%),
    radial-gradient(50vw 50vh at 8% 95%, rgba(54, 224, 177, 0.12), transparent 70%);
}
#stage { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; }
.orb {
  position: fixed; left: 0; top: 0; z-index: 4; width: 26px; height: 26px; margin: -13px 0 0 -13px;
  border-radius: 50%; pointer-events: none; opacity: 0;
  background: radial-gradient(circle, rgba(54, 224, 177, 0.95), rgba(91, 140, 255, 0.35) 60%, transparent 72%);
  filter: blur(1px);
  transition: opacity .3s;
}
.orb.on { opacity: .9; }

/* ---- fixed chrome ---- */
.top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 6;
  display: flex; justify-content: space-between; align-items: center;
  padding: 22px var(--gutter) 34px;
  font-family: var(--sans);
  background: linear-gradient(180deg, rgba(7, 10, 17, 0.92) 40%, rgba(7, 10, 17, 0));
}
.mark { display: inline-flex; line-height: 0; text-decoration: none; border-radius: 10px; }
.mark svg { display: block; border-radius: 10px; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12); transition: transform .25s; }
.mark:hover svg { transform: translateY(-1px) scale(1.04); }
@media (prefers-reduced-motion: reduce) { .mark svg { transition: none; } }
.top nav { display: flex; gap: clamp(16px, 3vw, 40px); font-size: 0.98rem; font-weight: 500; }
.top nav a { text-decoration: none; color: var(--text); opacity: .8; }
.top nav a:hover { opacity: 1; color: var(--mint); }

.rail {
  position: fixed; left: 0; bottom: 0; top: 0; width: var(--rail); z-index: 6;
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 28px;
}
.rail a { color: var(--text); opacity: .75; display: grid; place-items: center; }
.rail a:hover { opacity: 1; color: var(--mint); }

.resume {
  position: fixed; right: var(--gutter); bottom: 28px; z-index: 6;
  font-family: var(--sans); font-weight: 600; letter-spacing: .12em; font-size: .9rem;
  text-decoration: none; color: var(--muted);
  padding: 8px 12px; border-bottom: 1px solid var(--line); background: rgba(7, 10, 17, 0.78); backdrop-filter: blur(4px);
}
.resume:hover { color: var(--text); border-color: var(--mint); }

main { position: relative; z-index: 2; }
main > section { padding-inline: var(--gutter); }
@media (min-width: 900px) { main > section { padding-left: calc(var(--rail) + var(--gutter) * 0.5); } }

/* ---- hero ---- */
.hero { position: relative; min-height: 100svh; }
.hello {
  position: absolute; left: inherit; margin: 0; top: 28svh;
  font-family: var(--sans); font-size: clamp(1.1rem, 2vw, 1.6rem); color: var(--blue); font-weight: 500;
}
.name {
  position: absolute; margin: 0; top: 32svh;
  font-family: var(--sans); font-weight: 800;
  font-size: clamp(2.8rem, 8.2vw, 7.4rem);
  line-height: 0.92; letter-spacing: -0.035em;
}
.name .line { display: block; overflow: hidden; padding-bottom: .06em; }
.name .ch { display: inline-block; }

.roles {
  position: absolute; right: 0; top: 44svh; width: min(52vw, 760px);
  display: flex; flex-direction: column; align-items: flex-end; gap: .1em;
  overflow: hidden; padding-right: var(--gutter);
}
.role { font-family: var(--sans); font-weight: 800; font-size: clamp(1.4rem, 3.6vw, 3rem); letter-spacing: -0.02em; white-space: nowrap; line-height: 1.08; }
.role-a { color: var(--mint); }
.role-b { color: transparent; -webkit-text-stroke: 1.2px rgba(232, 237, 246, 0.8); }

.tagline {
  position: absolute; left: inherit; bottom: 9svh; margin: 0;
  font-family: var(--sans); font-size: clamp(1.05rem, 1.7vw, 1.4rem); color: var(--text); font-weight: 500;
}
.scrollhint { position: absolute; left: 50%; bottom: 3svh; margin: 0; transform: translateX(-50%); font-family: var(--sans); font-size: .8rem; color: var(--muted); letter-spacing: .16em; }
.scrollhint::after { content: ""; display: block; width: 1px; height: 28px; margin: 8px auto 0; background: linear-gradient(var(--mint), transparent); }

/* ---- shared section type ---- */
.mega {
  margin: 0; font-family: var(--sans); font-weight: 800;
  font-size: clamp(3rem, 10vw, 9rem); line-height: .9; letter-spacing: -0.04em;
}
.mega.mid { font-size: clamp(2.4rem, 7vw, 5.6rem); margin-bottom: 36px; }
.note { max-width: 36em; color: var(--muted); margin: 0 0 28px; }

/* ---- work ---- */
.work { position: relative; padding-block: 16svh 14svh; }
.work-head { margin: 0; }
.work-lede { max-width: 26em; margin: 26px 0 0; color: var(--muted); }
.cards { display: flex; flex-direction: column; gap: 22px; margin-top: 56px; }
@media (min-width: 900px) {
  .work { display: grid; grid-template-columns: 1fr minmax(0, 0.95fr); column-gap: clamp(32px, 5vw, 80px); align-items: start; }
  .work .mega, .work-lede { grid-column: 1; }
  .cards { grid-column: 2; grid-row: 1 / span 3; margin-top: 8px; }
}

.card { position: relative; border: 1px dashed var(--line); background: rgba(14, 20, 32, 0.72); backdrop-filter: blur(6px); }
.card::before, .card::after {
  content: ""; position: absolute; width: 16px; height: 16px; border: 2px solid var(--text); pointer-events: none; transition: border-color .25s;
}
.card::before { left: -1px; top: -1px; border-right: 0; border-bottom: 0; }
.card::after  { right: -1px; bottom: -1px; border-left: 0; border-top: 0; }
.card:hover::before, .card:hover::after, .card:focus-within::before, .card:focus-within::after { border-color: var(--mint); }

.card-head {
  display: grid; grid-template-columns: 1fr auto; column-gap: 16px; align-items: center;
  width: 100%; text-align: left; padding: 24px 26px;
  background: none; border: 0; color: inherit; font: inherit; cursor: pointer;
}
.card-title { font-family: var(--sans); font-weight: 800; font-size: clamp(1.25rem, 2.2vw, 1.75rem); letter-spacing: -0.02em; line-height: 1.15; }
.card-sub { grid-column: 1; font-family: var(--sans); font-size: .95rem; color: var(--muted); }
.chev {
  grid-column: 2; grid-row: 1 / span 2; width: 34px; height: 34px; border: 1px solid var(--text); position: relative; transition: transform .3s, border-color .3s;
}
.chev::after {
  content: ""; position: absolute; left: 50%; top: 42%; width: 9px; height: 9px;
  border-right: 2px solid var(--text); border-bottom: 2px solid var(--text);
  transform: translate(-50%, -50%) rotate(45deg);
}
.card-head[aria-expanded="true"] .chev { transform: rotate(180deg); border-color: var(--mint); }
.card-body { padding: 0 26px 26px; }
.card-body p { margin: 0 0 18px; max-width: 34em; }
.fig { margin: 0; }
.fig svg { width: 100%; height: auto; display: block; box-sizing: border-box; padding: 14px; background: rgba(7, 10, 17, 0.8); border: 1px solid var(--line); }

/* diagram vocabulary on dark */
svg .ax   { stroke: var(--muted); stroke-width: 1.5; }
svg .box  { fill: var(--surface); stroke: #5C6B85; stroke-width: 1.5; }
svg .gate { fill: rgba(54, 224, 177, 0.10); stroke: var(--mint); stroke-width: 2; }
svg .try  { fill: rgba(91, 140, 255, 0.12); stroke: var(--blue); stroke-width: 1.5; stroke-dasharray: 4 3; }
svg .ok   { fill: var(--mint); stroke: var(--mint); }
svg .lbl  { font: 600 12px var(--sans); fill: var(--text); }
svg .lbl.dk { fill: #00201A; }
svg .cap  { font: 400 12px var(--sans); fill: var(--muted); }
svg .arr  { stroke: #C9D3E6; stroke-width: 1.6; fill: none; marker-end: url(#ah); }
svg .dash { stroke: var(--blue); stroke-width: 1.5; stroke-dasharray: 4 3; fill: none; }
svg .br   { stroke: var(--blue); stroke-width: 1.5; fill: none; }
svg .ok-line { stroke: var(--mint); }

/* ---- story ---- */
.story, .education, .writing, .contact { padding-block: 14svh 8svh; }
.story-grid { display: grid; grid-template-columns: 1fr; gap: 48px; }
@media (min-width: 900px) { .story-grid { grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); gap: clamp(36px, 6vw, 96px); align-items: start; } }
.prose p { max-width: 36em; margin: 0 0 1.1em; }

.tl { position: relative; padding-left: 48px; font-family: var(--sans); }
.track { position: absolute; left: 12px; top: 8px; bottom: 8px; width: 2px; background: var(--line); }
.fill { position: absolute; inset: 0; transform-origin: top; transform: scaleY(0); background: linear-gradient(var(--blue), var(--mint)); box-shadow: 0 0 14px rgba(54, 224, 177, 0.7); }
.dot {
  position: absolute; left: 50%; top: 0; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%;
  background: var(--mint); box-shadow: 0 0 22px 4px rgba(54, 224, 177, 0.65);
}
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding-bottom: 44px; }
.timeline li:last-child { padding-bottom: 0; }
.year {
  display: block; font-weight: 800; font-size: clamp(1.8rem, 3.4vw, 2.6rem); letter-spacing: -0.03em; line-height: 1;
  color: var(--text);
}
.timeline li:last-child .year { color: var(--mint); }
.what { display: block; margin-top: 6px; color: var(--muted); font-size: 1rem; line-height: 1.5; max-width: 26em; }
.ai-note { display: block; margin-top: 10px; max-width: 26em; font-size: .92rem; line-height: 1.45; color: var(--muted); border-left: 2px solid var(--line); padding-left: 12px; transition: color .3s, border-color .3s; }
.ai-note b { font-weight: 700; color: var(--text); }
.timeline li.on .ai-note { border-color: var(--mint); color: var(--text); }
.timeline li.on .ai-note b { color: var(--mint); }
@media (min-width: 900px) { .tl { padding-left: clamp(116px, 12vw, 180px); } }

/* ---- writing, contact ---- */
.posts, .contact-list { list-style: none; margin: 0; padding: 0; font-family: var(--sans); }
.posts li { padding: 18px 0; border-top: 1px solid var(--line); max-width: 46em; font-size: 1.1rem; font-weight: 500; }
.posts li:last-child { border-bottom: 1px solid var(--line); }
.posts a { text-decoration: none; }
.posts a:hover { color: var(--mint); }
.contact { padding-bottom: 14svh; }
.contact-list li { padding: 6px 0; font-size: 1.1rem; font-weight: 500; }
.contact-list .big { font-size: clamp(1.4rem, 3.6vw, 2.6rem); font-weight: 800; letter-spacing: -0.02em; }
.contact-list a { text-decoration: none; border-bottom: 1px solid var(--line); }
.contact-list a:hover { color: var(--mint); border-color: var(--mint); }

.foot {
  position: relative; z-index: 2; padding: 32px var(--gutter) 64px; font-family: var(--sans); font-size: .9rem; color: var(--muted);
}
/* The divider stops before the robot's side of the page so the robot never overlaps it. */
.foot::before {
  content: ""; position: absolute; top: 0; left: var(--gutter); width: min(52vw, 560px); border-top: 1px solid var(--line);
}
@media (min-width: 900px) { .foot::before { left: calc(var(--rail) + var(--gutter) * 0.5); } }
@media (max-width: 899px) { .foot::before { width: calc(100% - var(--gutter) * 2); } }
@media (min-width: 900px) { .foot { padding-left: calc(var(--rail) + var(--gutter) * 0.5); } }
.foot p { margin: 0 0 4px; }

/* ---- narrow screens ---- */
@media (max-width: 899px) {
  .rail { display: none; }
  .hello { top: 17svh; }
  .name { top: 21svh; font-size: clamp(2.6rem, 14vw, 4.4rem); }
  .roles { top: 40svh; right: 0; width: 100%; padding-right: var(--gutter); }
  .role { font-size: clamp(1.1rem, 6vw, 1.8rem); }
  .tagline { bottom: auto; top: 52svh; }
  .resume { bottom: 18px; }
}

@media (max-width: 520px) {
  .top { gap: 10px; flex-wrap: nowrap; }
  .mark svg { width: 34px; height: 34px; }
  .top nav { flex: 1; justify-content: flex-end; gap: 12px; font-size: .84rem; }
}
@media (max-width: 360px) {
  .top nav { gap: 9px; font-size: .78rem; }
}

@media (prefers-reduced-motion: reduce) {
  .orb { display: none; }
  .chev, .card::before, .card::after { transition: none; }
}

/* ---- education ---- */
.edu-list { list-style: none; margin: 0; padding: 0; font-family: var(--sans); max-width: 60em; }
.edu-list li {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px 24px;
  padding: 20px 0; border-top: 1px solid var(--line);
}
.edu-list li:last-child { border-bottom: 1px solid var(--line); }
.edu-what { font-weight: 800; font-size: clamp(1.15rem, 2vw, 1.5rem); letter-spacing: -0.02em; }
.edu-where { color: var(--muted); font-size: 1rem; line-height: 1.5; }
.edu-when { color: var(--mint); font-size: .95rem; font-weight: 600; }
@media (min-width: 900px) {
  .edu-list li { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.3fr) 110px; align-items: baseline; }
  .edu-when { text-align: right; }
}

/* ---- contact + chat ---- */
.sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.contact-links { margin: 0 0 28px; font-family: var(--sans); font-size: 1.1rem; font-weight: 500; }
.contact-links a { text-decoration: none; border-bottom: 1px solid var(--line); }
.contact-links a:hover { color: var(--mint); border-color: var(--mint); }

.chat { position: relative; max-width: 560px; border: 1px dashed var(--line); background: rgba(14, 20, 32, 0.78); backdrop-filter: blur(6px); padding: 22px; font-family: var(--sans); }
.chat::before, .chat::after { content: ""; position: absolute; width: 16px; height: 16px; border: 2px solid var(--text); pointer-events: none; }
.chat::before { left: -1px; top: -1px; border-right: 0; border-bottom: 0; }
.chat::after  { right: -1px; bottom: -1px; border-left: 0; border-top: 0; }
.chat:focus-within::before, .chat:focus-within::after { border-color: var(--mint); }
.chat-title { margin: 0 0 4px; font-size: 1.25rem; font-weight: 800; letter-spacing: -0.02em; }
.chat-sub { margin: 0 0 14px; color: var(--muted); font-size: .88rem; line-height: 1.45; }
.chat-log { display: flex; flex-direction: column; gap: 10px; max-height: 340px; overflow-y: auto; padding: 14px 2px 10px; scroll-behavior: smooth; -webkit-mask-image: linear-gradient(transparent 0, #000 14px); mask-image: linear-gradient(transparent 0, #000 14px); }
.msg { max-width: 92%; padding: 10px 13px; font-size: .97rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.bot { align-self: flex-start; background: rgba(7, 10, 17, 0.7); border: 1px solid var(--line); color: var(--text); }
.msg.you { align-self: flex-end; background: var(--text); color: var(--bg); font-weight: 500; }
.msg.err { border-color: #E0786A; }
.msg.typing { color: var(--muted); }
.msg.typing i { display: inline-block; width: 6px; height: 6px; margin-right: 4px; border-radius: 50%; background: var(--mint); animation: blink 1.1s infinite; }
.msg.typing i:nth-child(2) { animation-delay: .15s; }
.msg.typing i:nth-child(3) { animation-delay: .3s; margin-right: 0; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.chat-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 12px; }
.chip {
  font: inherit; font-size: .85rem; font-weight: 500; cursor: pointer; color: var(--text);
  background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px;
}
.chip:hover { border-color: var(--mint); color: var(--mint); }
.chip[disabled] { opacity: .45; cursor: default; border-color: var(--line); color: var(--muted); }

.chat-form { display: flex; gap: 8px; }
.chat-form input {
  flex: 1; min-width: 0; font: inherit; font-size: 1rem; color: var(--text);
  background: rgba(7, 10, 17, 0.8); border: 1px solid var(--line); padding: 11px 12px; border-radius: 0;
}
.chat-form input::placeholder { color: var(--muted); }
.chat-form input:focus-visible { outline: 3px solid var(--mint); outline-offset: 2px; }
.chat-send {
  font: inherit; font-weight: 700; cursor: pointer; color: #00201A; background: var(--mint);
  border: 0; padding: 11px 18px;
}
.chat-send:hover { background: #5CF0C6; }
.chat-send[disabled], .chat-form input[disabled] { opacity: .5; cursor: default; }
.chat-note { margin: 10px 0 0; color: var(--muted); font-size: .8rem; }

/* the robot's greeting, anchored over its head while the contact section is in view */
.bubble {
  position: fixed; left: 0; top: 0; z-index: 4; pointer-events: none;
  opacity: 0; transition: opacity .35s; font-family: var(--sans);
  background: var(--surface); border: 1px solid var(--mint); padding: 10px 14px; max-width: 220px;
}
.bubble p { margin: 0; font-size: .95rem; font-weight: 600; line-height: 1.35; color: var(--text); }
.bubble::after {
  content: ""; position: absolute; left: 50%; bottom: -7px; width: 12px; height: 12px; margin-left: -6px;
  background: var(--surface); border-right: 1px solid var(--mint); border-bottom: 1px solid var(--mint); transform: rotate(45deg);
}
.bubble.on { opacity: 1; }
@media (max-width: 899px) { .scrollhint { display: none; } }
@media (max-width: 599px) { .bubble { display: none; } .chat { max-width: none; } }
@media (min-width: 600px) and (max-width: 899px) { .chat { max-width: 500px; } }
@media (prefers-reduced-motion: reduce) { .msg.typing i { animation: none; opacity: .8; } .bubble { transition: none; } }

/* ---- calm variant (?calm): same design, minimal glow ---- */
.calm .glow { background: radial-gradient(70vw 50vh at 85% 0%, rgba(91, 140, 255, 0.07), transparent 75%); }
.calm .orb { display: none; }
.calm .fill { box-shadow: none; background: var(--mint); width: 2px; }
.calm .dot { box-shadow: 0 0 0 4px rgba(54, 224, 177, 0.18); }
.calm .chat-send:hover { background: var(--mint); }
