/* ==========================================================================
   Personal site styles
   1 tokens · 2 base · 3 views · 4 shared pieces · 5 home · 6 work · 7 about
   8 small screens · 9 reduced motion
   ========================================================================== */

/* 1 · tokens ------------------------------------------------------------- */
:root {
  --bg: #F7F6F2;
  --ink: #393027;
  --muted: #6E675F;
  --line: rgba(57, 48, 39, 0.2);
  --olivine: #9BAD50;
  --olivine-deep: #8A9C45;
  --columbia: #B6CFE4;
  --paper: #F2F1EC;
  --tile: #FFFFFF;
  --accent: var(--olivine);

  --display: "Schibsted Grotesk", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --headline: Arial, "Helvetica Neue", Helvetica, sans-serif;
  --mono: "Courier Prime", "Courier New", Courier, monospace;
  --hand: "Caveat", "Segoe Print", "Bradley Hand", cursive;

  --pad: clamp(0px, 3vw, 40px);
  --gutter-l: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  color-scheme: light;
}

/* 2 · base --------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--display);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; }
[hidden] { display: none !important; }
[tabindex="-1"]:focus { outline: none; }

.sr {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
/* hidden until a keyboard user tabs to it */
.sr-focusable:not(:focus-visible) {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* 3 · views -------------------------------------------------------------- */
/* The router only sets html[data-view]; everything else follows from CSS. */
.hero, .work, .about { display: none; }
html[data-view="home"] .hero { display: block; }
html[data-view="work"] .work { display: block; }
html[data-view="about"] .about { display: block; }

html[data-view="home"] body { overflow: hidden; }
html[data-view="work"] body,
html[data-view="about"] body { height: auto; overflow: auto; }

/* where the top-right buttons sit: the same inset as the logo on each page */
html[data-view="home"] {
  --q-w: min(100% - var(--gutter-l) - var(--gutter-r), calc(1280px + 2 * var(--pad)));
  --q-pad: var(--pad);
}
html[data-view="work"] { --q-w: min(100%, 1120px); --q-pad: calc(var(--gutter-r) + var(--pad)); }
html[data-view="about"] {
  --q-w: min(100%, calc(1120px + var(--gutter-l) + var(--gutter-r)));
  --q-pad: calc(var(--gutter-r) + var(--pad));
}

/* 4 · shared pieces ------------------------------------------------------ */

/* logo: a seal whose edge turns while you hover it */
.mark {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 46px; height: 46px; border-radius: 50%; text-decoration: none; color: var(--ink);
}
.mark-ring {
  display: block; width: 100%; height: 100%;
  animation: spin 7s linear infinite paused;
  filter: drop-shadow(0 2px 3px rgba(18, 18, 18, 0.14));
  transition: transform .25s ease;
}
.mark-initials {
  position: absolute; inset: 0; display: grid; place-items: center;
  font: 700 15px/1 var(--display); letter-spacing: -0.02em;
  transition: transform .25s ease; pointer-events: none;
}
.mark:hover .mark-ring, .mark:focus-visible .mark-ring { animation-play-state: running; }
.mark:active .mark-ring, .mark:active .mark-initials { transform: scale(0.92); }
.mark:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
@keyframes spin { to { rotate: 360deg; } }

/* buttons: filled olive (primary) and olive outline (secondary) */
.btn {
  display: inline-flex; align-items: center; padding: 9px 16px;
  border: 1.5px solid var(--olivine); border-radius: 999px; background: transparent;
  color: var(--ink); font: 700 12px var(--mono); letter-spacing: 0.1em; text-transform: uppercase;
  text-decoration: none; cursor: pointer; transition: background .2s ease, transform .2s ease;
}
.btn.pill { background: var(--olivine); }
.btn:hover { background: var(--olivine); transform: translateY(-1px); }
.btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; }
.actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.eyebrow {
  margin: 0 0 18px; font: 12px var(--mono); letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--muted);
}
.bar { display: flex; align-items: center; padding-inline: var(--pad); }

/* top-right quick links (LinkedIn, resume) */
.quick {
  position: fixed; z-index: 41; top: calc(23px + var(--safe-top)); left: 0; right: 0;
  pointer-events: none;
}
.quick-inner {
  position: relative; display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  width: var(--q-w); margin-inline: auto; padding-right: var(--q-pad);
}
.quick a {
  pointer-events: auto; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; border-radius: 999px; text-decoration: none;
  transition: transform .2s ease, background .2s ease;
}
.quick a:hover { transform: translateY(-1px); }
.quick a:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.q-in { width: 44px; background: var(--bg); color: var(--ink); border: 1.5px solid var(--olivine); }
.q-in:hover { background: var(--olivine); }
.q-in svg { width: 18px; height: 18px; }
.q-cv {
  padding: 0 18px 0 15px; background: var(--olivine); color: var(--ink);
  font: 700 12px var(--mono); letter-spacing: 0.1em; text-transform: uppercase;
}
.q-cv svg { width: 16px; height: 16px; }

/* bottom navigation: a frosted pill with a highlight that slides to the hovered item */
.nav {
  --nav-bg: rgba(57, 48, 39, 0.5);
  --nav-fg: rgba(247, 246, 242, 0.62);
  --nav-on: #F7F6F2;
  position: fixed; z-index: 40; left: 50%; bottom: calc(18px + var(--safe-bottom));
  transform: translateX(-50%); display: flex; gap: 2px; padding: 6px;
  border-radius: 999px; background: var(--nav-bg);
  -webkit-backdrop-filter: blur(14px) saturate(1.3); backdrop-filter: blur(14px) saturate(1.3);
  box-shadow: 0 10px 30px rgba(57, 48, 39, 0.16);
}
.nav-hi {
  position: absolute; top: 6px; bottom: 6px; left: 0; border-radius: 999px;
  width: var(--hi-w, 0px); transform: translateX(var(--hi-x, 0px));
  background: var(--ink); opacity: 0; pointer-events: none;
  transition: transform .38s cubic-bezier(.3, 1.4, .5, 1), width .38s cubic-bezier(.3, 1.4, .5, 1), opacity .2s ease;
}
.nav.has-hover .nav-hi { opacity: 1; }
.nav a {
  position: relative; z-index: 1; display: block; padding: 13px 22px 15px; border-radius: 999px;
  font: 700 14px var(--display); letter-spacing: 0.03em; text-transform: uppercase;
  color: var(--nav-fg); text-decoration: none; transition: color .2s ease;
}
.nav a:hover, .nav a[aria-current="page"] { color: var(--nav-on); }
.nav a[aria-current="page"]::after {
  content: ""; position: absolute; left: 50%; bottom: 6px; width: 4px; height: 4px; margin-left: -2px;
  border-radius: 50%; background: var(--olivine);
}
.nav a:focus-visible { outline: 2px solid var(--nav-on); outline-offset: -4px; }

/* 5 · home --------------------------------------------------------------- */
.hero { position: relative; height: 100%; height: 100svh; min-height: 560px; }
#stage {
  position: absolute; inset: 0; display: block; width: 100%; height: 100%;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
.overlay {
  position: absolute; inset: 0; pointer-events: none;
  display: grid; grid-template-rows: auto 1fr 52px;
  padding: calc(22px + var(--safe-top)) var(--gutter-r) calc(22px + var(--safe-bottom)) var(--gutter-l);
}
.overlay :is(a, button) { pointer-events: auto; }
.top, .copy-wrap {
  display: flex; align-items: center;
  width: min(100%, calc(1280px + 2 * var(--pad))); margin-inline: auto; padding-inline: var(--pad);
}
.copy { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; width: min(620px, 46vw); }

h1 {
  margin: 0; font-family: var(--headline); font-weight: 700; line-height: 1.06;
  letter-spacing: -0.03em; text-wrap: balance;
}
.copy h1 { font-size: clamp(38px, 4vw, 58px); }
h1 .nb { white-space: nowrap; }
/* every word is stacked in one grid cell, so the widest one reserves the space and nothing reflows while typing */
.rot-wrap { display: inline-grid; color: var(--accent); }
.rot-wrap > * { grid-area: 1 / 1; }
.ghost { visibility: hidden; padding-right: 0.13em; }   /* the extra is the caret's width, so the widest word plus caret never grows the line */
.live { white-space: nowrap; }
.caret {
  display: inline-block; width: 0.07em; height: 0.92em; margin-left: 0.06em;
  vertical-align: -0.1em; background: var(--accent);
}
.caret.idle { animation: caret 1s steps(1) infinite; }
@keyframes caret { 50% { opacity: 0; } }

.lede { margin: 0; color: var(--muted); font-size: clamp(16px, 1.35vw, 19px); line-height: 1.5; max-width: 40ch; text-wrap: pretty; }
.hint {
  display: inline-flex; align-items: center; gap: 8px; justify-self: start; margin-top: 4px;
  font: 12px var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.hint i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink); display: inline-block; animation: blink 2.4s ease-in-out infinite; }
.hint-touch { display: none; }
@media (hover: none) { .hint-pointer { display: none; } .hint-touch { display: inline; } }
@keyframes blink { 50% { opacity: .25; } }
.flip-btn:focus-visible { position: absolute; left: 0; top: calc(100% + 10px); }

/* simple stand-in when the 3D badge can't run */
.badge-fallback {
  display: none; position: absolute; top: 0; width: min(240px, 38vw); pointer-events: none; transform-origin: 50% 0; animation: fb-sway 5s ease-in-out infinite;
  left: calc(68% - min(120px, 19vw));          /* centred where the 3D badge hangs on a wide window */
}
html.no-3d #stage, html.no-3d .hint { display: none; }          /* nothing to drag, so no hint either */
html.no-3d .badge-fallback { display: block; }
.bf-strap { display: block; width: 34px; height: 22vh; margin: 0 auto; background: #66672C; border-radius: 0 0 3px 3px; }
.bf-card {
  display: grid; align-content: space-between; justify-items: center; aspect-ratio: 1024 / 1550;
  padding: 12% 8% 10%; background: #fff; border-radius: 16px; text-align: center;
  box-shadow: 0 22px 40px -18px rgba(18, 18, 18, 0.35); font-family: var(--display); color: #111;
}
.bf-name { font-size: clamp(16px, 2.2vw, 24px); }
.bf-role { font-weight: 700; font-size: clamp(22px, 3.4vw, 36px); line-height: 1.05; }
@keyframes fb-sway { 50% { transform: rotate(2deg); } }

/* 6 · work --------------------------------------------------------------- */
.work {
  min-height: 100vh; min-height: 100svh; max-width: 1120px; margin-inline: auto;
  padding: calc(22px + var(--safe-top)) var(--gutter-r) 150px var(--gutter-l);
}
.work-intro { padding: clamp(48px, 8vw, 96px) var(--pad) 0; }
.work-intro h1, .about h1 { font-size: clamp(36px, 5vw, 64px); line-height: 1.04; }
.work-intro h1 em, .about h1 em { font-style: normal; color: var(--accent); }

/* project cards: white tiles that lift a little when hovered, like the timeline cards do */
.projects {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px;
  margin: clamp(32px, 5vw, 56px) 0 0; padding: 0 var(--pad); list-style: none;
}
.project {
  display: flex; flex-direction: column; padding: 10px 10px 22px;
  background: var(--tile); border: 1px solid transparent; border-radius: 20px;
  box-shadow: 0 1px 0 rgba(18, 18, 18, 0.04);
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}
.project:hover, .project:focus-within {
  transform: translateY(-3px); border-color: rgba(155, 173, 80, 0.55);
  box-shadow: 0 18px 34px -20px rgba(18, 18, 18, 0.3);
}
.project-img { position: relative; aspect-ratio: 16 / 10; overflow: hidden; border-radius: 12px; background: var(--paper); }
.project-img img { display: block; width: 100%; height: 100%; object-fit: cover; }
/* stand-in for a screenshot: a field of dots that fades out downwards, like the back of the badge */
.project-img:not(:has(img))::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle, rgba(57, 48, 39, 0.5) 0 1.3px, transparent 1.7px) 0 0 / 11px 11px;
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, transparent 92%); mask-image: linear-gradient(to bottom, #000 0%, transparent 92%);
}
.project-no { position: absolute; left: 14px; bottom: 12px; font: 700 12px var(--mono); letter-spacing: 0.12em; color: var(--muted); }
.project h2 { margin: 18px 12px 0; font: 700 21px/1.2 var(--headline); letter-spacing: -0.02em; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 12px 0; padding: 0; list-style: none; }
.tags li { padding: 5px 9px; border: 1px solid var(--line); border-radius: 999px; font: 11px/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.project p { flex: 1 0 auto; margin: 14px 12px 0; font-size: 15px; line-height: 1.55; color: var(--muted); }
.project .btn { align-self: flex-start; margin: 18px 12px 0; }

/* 7 · about -------------------------------------------------------------- */
.about {
  width: min(100%, calc(1120px + var(--gutter-l) + var(--gutter-r))); margin-inline: auto;
  padding: calc(22px + var(--safe-top)) var(--gutter-r) 150px var(--gutter-l);
}
.about-intro {
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: clamp(32px, 6vw, 88px); align-items: start;
  padding: clamp(48px, 8vw, 96px) var(--pad) 0;
}
.about-intro h1 { font-size: clamp(34px, 4.4vw, 56px); line-height: 1.06; }
.about-body { display: grid; gap: 16px; margin-top: 28px; max-width: 58ch; }
.about-body p { margin: 0; font-size: 17px; line-height: 1.6; color: var(--muted); }
.about-body p.vow {
  margin-top: 6px; font-family: var(--headline); font-weight: 700; font-size: clamp(20px, 2vw, 24px);
  line-height: 1.45; color: var(--ink); letter-spacing: -0.01em;
}
.about-body p.vow span {
  padding: 0 2px; -webkit-box-decoration-break: clone; box-decoration-break: clone;
  background: linear-gradient(transparent 52%, var(--columbia) 52%, var(--columbia) 92%, transparent 92%);
}
.about .actions { margin-top: 28px; }

/* polaroid hanging from a binder clip; it sways while hovered */
.pola { margin: 0; justify-self: center; width: min(500px, 100%); container-type: inline-size; }
.pola-swing { position: relative; padding-top: 28.2cqw; transform-origin: 50% 6%; transform: rotate(-1.6deg); transition: transform .5s ease; }
.pola-swing.swaying { animation: pola-sway 2.2s ease-in-out infinite; }
@keyframes pola-sway { 0%, 100% { transform: rotate(-1.6deg); } 50% { transform: rotate(1.8deg); } }
.pola-clip { position: absolute; z-index: 2; top: 0; left: 50%; width: 26cqw; height: auto; transform: translateX(-50%); filter: drop-shadow(0 3px 3px rgba(18, 18, 18, 0.28)); }
.pola-card { background: #fff; border-radius: 22px; padding: 4cqw 4cqw 0; box-shadow: 0 1px 0 rgba(18, 18, 18, 0.05), 0 22px 40px -18px rgba(18, 18, 18, 0.35); }
.pola-photo { display: block; width: 100%; height: auto; border-radius: 10px; }
.pola figcaption { padding: 3.2cqw 0 4cqw; font: 500 clamp(22px, 5.6cqw, 30px) / 1.1 var(--hand); color: var(--ink); text-align: center; }

/* journey: a dark panel whose timeline fills in as you scroll */
.journey {
  margin-top: clamp(72px, 10vw, 120px); background: var(--ink); color: var(--paper);
  border-radius: clamp(24px, 3vw, 36px); padding: clamp(48px, 7vw, 80px) clamp(18px, 4vw, 48px) clamp(56px, 7vw, 88px);
}
.journey h2 {
  margin: 0; text-align: center; font-family: var(--headline); font-weight: 700;
  font-size: clamp(32px, 4vw, 48px); line-height: 1.06; letter-spacing: -0.03em; color: var(--paper); text-wrap: balance;
}
.lede-sm { margin: 12px auto 0; text-align: center; font: 12px var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: rgba(242, 241, 236, 0.5); }
.tl { position: relative; margin-top: clamp(40px, 6vw, 64px); margin-bottom: 16px; }   /* the 16px the original gets from its list's default margin */
.tl-list { display: grid; gap: clamp(40px, 6vw, 64px); margin: 0; padding: 0; list-style: none; }
.tl-line, .tl-fill { position: absolute; top: 0; left: 50%; width: 2px; margin-left: -1px; border-radius: 2px; }
.tl-line { bottom: 0; background: rgba(242, 241, 236, 0.12); }
.tl-fill { height: 0; background: var(--olivine); box-shadow: 0 0 14px rgba(155, 173, 80, 0.5); }
.tl-item { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 120px minmax(0, 1fr); align-items: center; }
.tl-year {
  grid-column: 2; justify-self: center; position: relative; z-index: 1; padding: 10px 4px;
  background: var(--ink); font-family: var(--headline); font-weight: 700; font-size: clamp(22px, 2.4vw, 30px);
  letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: rgba(242, 241, 236, 0.22); transition: color .4s ease;
}
.tl-card {
  grid-row: 1; padding: 20px 22px 22px; border: 1px solid rgba(242, 241, 236, 0.08); border-radius: 18px;
  background: rgba(255, 255, 255, 0.055); opacity: 0.28; transform: translateY(18px);
  transition: opacity .6s ease, transform .6s cubic-bezier(.2, .8, .2, 1), background .25s ease, border-color .25s ease;
}
.tl-item:nth-child(odd) .tl-card { grid-column: 3; }
.tl-item:nth-child(even) .tl-card { grid-column: 1; }
.tl-item.on .tl-year { color: var(--columbia); }
.tl-item.on .tl-card { opacity: 1; transform: none; }
.tl-card:hover { background: rgba(255, 255, 255, 0.085); border-color: rgba(155, 173, 80, 0.55); }
.tl-card h3 { margin: 0; font-family: var(--headline); font-size: 19px; letter-spacing: -0.01em; color: var(--paper); }
.tl-meta { margin-top: 6px; font: 11px var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--columbia); opacity: 0.85; }
.tl-card p { margin: 12px 0 0; font-size: 14.5px; line-height: 1.55; color: rgba(242, 241, 236, 0.74); }
/* optional pill link inside a card: <a class="tl-metric" href="#work">Find out more →</a> */
.tl-metric {
  display: inline-flex; align-items: center; margin-top: 16px; padding: 9px 16px; border: 1.5px solid var(--olivine);
  border-radius: 999px; color: var(--paper); font: 700 12px/1.2 var(--mono); letter-spacing: 0.1em;
  text-transform: uppercase; text-decoration: none; transition: background .2s ease, color .2s ease;
}
.tl-metric:hover, .tl-metric:focus-visible { background: var(--olivine); color: var(--ink); outline: none; }

/* 8 · small screens ------------------------------------------------------ */
@media (max-width: 960px) { .projects { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px) { .projects { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) {
  .nav a { padding: 12px 18px 14px; font-size: 13px; }
  .pola { width: min(440px, 100%); margin-top: 8px; }
  .about-intro { grid-template-columns: minmax(0, 1fr); }
  .tl-line, .tl-fill { left: 9px; }
  .tl-item { grid-template-columns: minmax(0, 1fr); gap: 10px; padding-left: 34px; }
  .tl-year { grid-column: 1; justify-self: start; padding: 0; background: none; font-size: 24px; }
  .tl-year::before {
    content: ""; position: absolute; left: -31px; top: 50%; width: 12px; height: 12px; margin-top: -6px;
    border-radius: 50%; background: var(--ink); border: 2px solid rgba(242, 241, 236, 0.25);
    transition: border-color .4s ease, background .4s ease;
  }
  .tl-item.on .tl-year::before { border-color: var(--olivine); background: var(--olivine); }
  .tl-item .tl-card, .tl-item:nth-child(odd) .tl-card, .tl-item:nth-child(even) .tl-card { grid-column: 1; grid-row: 2; }
}
/* Tall or square windows (phones and tablets held upright): the text drops to the bottom and the badge
   hangs above it, because side by side there isn't room. Keep this query in sync with PORTRAIT in js/badge/index.js. */
@media (max-aspect-ratio: 23/20) {
  .badge-fallback { left: calc(50% - min(120px, 19vw)); }
  .copy-wrap { align-items: flex-end; padding-bottom: 18px; }
  .copy { width: 100%; gap: 14px; }
  .copy h1 { font-size: clamp(30px, 9vw, 52px); }
  .lede { font-size: clamp(15px, 2.2vw, 19px); }
  .hint { font-size: 11px; }
}
/* three round buttons sit next to the strap, so the Resume label folds away on narrower windows, and phones get 40px buttons */
@media (max-width: 860px) { .q-cv .q-label { display: none; } .q-cv { width: 44px; padding: 0; } }
@media (max-width: 420px) {
  .quick { top: calc(25px + var(--safe-top)); }
  .quick-inner { gap: 6px; }
  .quick a { height: 40px; }
  .q-in, .q-cv { width: 40px; }
}
/* short windows (phones on their side): tighten the type so the text still fits */
@media (max-height: 560px) {
  .hero { min-height: 0; }
  .copy { gap: 12px; }
  .copy h1 { font-size: clamp(26px, 7.4vh, 44px); }
  .lede { font-size: clamp(14px, 3.4vh, 17px); }
}

/* 9 · reduced motion ----------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .hint i, .mark-ring, .caret.idle, .badge-fallback { animation: none; }
  .pola-swing.swaying { animation: none; }
  .btn, .nav-hi, .nav a, .quick a, .tl-card, .tl-year, .project { transition: none; }
}
