/* ---------- tokens ---------- */

:root {
  --bg: #eceef3;
  --ink: #111318;
  --muted: #474c59;
  --faint: #7c8296;
  --accent: #2f5bea;
  --outline: rgb(17 19 24 / .12);
  --state: rgb(17 19 24 / .06);
  --hover: rgb(0 0 0 / .12);
  --glass: rgb(255 255 255 / .55);
  --glass-strong: rgb(255 255 255 / .72);
  --chip: rgb(255 255 255 / .5);
  --rim-hi: rgb(255 255 255 / .95);
  --rim-lo: rgb(255 255 255 / .2);
  --shadow: 0 1px 2px rgb(16 24 40 / .06), 0 28px 56px -20px rgb(16 24 40 / .28);
  --fold: rgb(16 24 40 / .16);
  --blob-o: .6;

  --radius: 28px;
  --tile-radius: 14px;
  --font: "Segoe UI Variable Display", "Segoe UI", "Noto Sans", system-ui, -apple-system, sans-serif;
  --turn: 850ms cubic-bezier(.6, .05, .25, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0c10;
    --ink: #eef0f6;
    --muted: #b0b5c4;
    --faint: #737a8e;
    --accent: #7d9bff;
    --outline: rgb(255 255 255 / .1);
    --state: rgb(255 255 255 / .07);
    --hover: rgb(255 255 255 / .12);
    --glass: rgb(26 28 36 / .55);
    --glass-strong: rgb(36 39 50 / .7);
    --chip: rgb(255 255 255 / .05);
    --rim-hi: rgb(255 255 255 / .3);
    --rim-lo: rgb(255 255 255 / .04);
    --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 28px 56px -20px rgb(0 0 0 / .8);
    --fold: rgb(0 0 0 / .4);
    --blob-o: .38;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0b0c10;
  --ink: #eef0f6;
  --muted: #b0b5c4;
  --faint: #737a8e;
  --accent: #7d9bff;
  --outline: rgb(255 255 255 / .1);
  --state: rgb(255 255 255 / .07);
  --hover: rgb(255 255 255 / .12);
  --glass: rgb(26 28 36 / .55);
  --glass-strong: rgb(36 39 50 / .7);
  --chip: rgb(255 255 255 / .05);
  --rim-hi: rgb(255 255 255 / .3);
  --rim-lo: rgb(255 255 255 / .04);
  --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 28px 56px -20px rgb(0 0 0 / .8);
  --fold: rgb(0 0 0 / .4);
  --blob-o: .38;
  color-scheme: dark;
}

/* ---------- base ---------- */

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

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

h1, h2, h3, p, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }
a { color: inherit; }
button { font: inherit; color: inherit; }

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

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

/* ---------- backdrop: slow colour fields for the glass to refract ---------- */

.backdrop {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  background: var(--bg);
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: var(--blob-o);
  animation: drift 36s ease-in-out infinite alternate;
}
.blob-1 { width: 55vmax; height: 55vmax; left: -18vmax; top: -22vmax; background: #3a6bff; }
.blob-2 { width: 40vmax; height: 40vmax; right: -14vmax; top: 4vh; background: #e0409a; animation-duration: 44s; }
.blob-3 { width: 50vmax; height: 40vmax; left: 12vw; bottom: -26vmax; background: #00b8a3; animation-duration: 50s; }
.blob-4 { width: 28vmax; height: 28vmax; right: 4vw; bottom: -6vmax; background: #ffb020; animation-duration: 40s; }

@keyframes drift {
  to { transform: translate(6vmax, 4vmax) scale(1.12); }
}

/* ---------- ripple (Material) ---------- */

.ripple {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.ink {
  position: absolute;
  z-index: -1;
  border-radius: 50%;
  background: currentColor;
  opacity: .22;
  transform: scale(0);
  pointer-events: none;
  animation: ink .6s cubic-bezier(.2, .6, .3, 1) forwards;
}

@keyframes ink {
  to { transform: scale(1); opacity: 0; }
}

/* ---------- shell ---------- */

.app {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  height: 100vh;
  height: 100dvh;
  max-width: 880px;
  margin: 0 auto;
  padding: 16px 16px max(16px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tools { display: flex; flex-shrink: 0; gap: 4px; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: background-color .2s;
}
.icon-btn:hover { background: var(--state); }
.lang-btn { font-size: .78rem; font-weight: 600; letter-spacing: .06em; }

/* ---------- pivot (Metro) ---------- */

.pivot {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  margin-left: -16px;
  padding-left: 16px;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 16px, #000 calc(100% - 24px), transparent);
  mask-image: linear-gradient(90deg, transparent, #000 16px, #000 calc(100% - 24px), transparent);
}
.pivot::-webkit-scrollbar { display: none; }

.pivot ol {
  display: flex;
  gap: 24px;
  width: max-content;
  padding-right: 40px; /* lets the last header scroll clear of the edge fade */
  white-space: nowrap;
}

.pivot button {
  padding: 2px 0 6px;
  border: 0;
  background: none;
  font-size: clamp(1.2rem, 3.2vw, 1.55rem);
  font-weight: 300;
  letter-spacing: -.01em;
  text-transform: lowercase;
  color: var(--ink);
  opacity: .42;
  cursor: pointer;
  transition: opacity .3s;
}
.pivot button:hover { opacity: .65; }
.pivot button[aria-current="page"] { opacity: 1; }

/* ---------- bottom bar: progress + FABs (Material) ---------- */

.bottombar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.progress {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.progress-num { font-size: 1.6rem; font-weight: 300; line-height: 1; font-variant-numeric: tabular-nums; }
.progress-total { font-size: .8rem; color: var(--faint); font-variant-numeric: tabular-nums; }
.progress-track {
  align-self: center;
  width: clamp(60px, 18vw, 140px);
  height: 4px;
  margin-left: 6px;
  border-radius: 2px;
  background: var(--outline);
  overflow: hidden;
}
.progress-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transform-origin: left;
  transform: scaleX(0);
  transition: transform .6s cubic-bezier(.2, .6, .3, 1);
}

.fabs { display: flex; align-items: center; gap: 10px; }

.fab {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 16px;
  background: var(--accent);
  color: #fff;
  box-shadow: inset 0 0 0 100vmax transparent;
  cursor: pointer;
  transition: box-shadow .2s, opacity .2s;
}
.fab:hover:not(:disabled) { box-shadow: inset 0 0 0 100vmax var(--hover); }
.fab svg { width: 24px; height: 24px; stroke-width: 2; }

.fab-small {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--glass-strong);
  color: var(--ink);
  box-shadow: inset 0 0 0 100vmax transparent, inset 0 0 0 1px var(--outline);
  -webkit-backdrop-filter: blur(16px) saturate(170%);
  backdrop-filter: blur(16px) saturate(170%);
}
.fab-small:hover:not(:disabled) { box-shadow: inset 0 0 0 100vmax var(--hover), inset 0 0 0 1px var(--outline); }
.fab-small svg { width: 20px; height: 20px; }

.fab:disabled { opacity: .35; box-shadow: none; cursor: default; }

/* ---------- deck & page turning ---------- */

.deck {
  position: relative;
  min-height: 0;
  margin-bottom: 26px; /* room for the stacked panes peeking out */
  perspective: 2400px;
  perspective-origin: 50% 40%;
  touch-action: pan-y;
}

.card {
  --d: 0;
  --s: 1;
  --tx: 0%;
  --ty: 0%;
  --ry: 0deg;
  --lag: 0ms;
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  background: var(--glass);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  backdrop-filter: blur(30px) saturate(180%);
  box-shadow: var(--shadow), inset 0 1px 1px var(--rim-hi);
  overflow: hidden;
  transform-origin: left center;
  transform: translateX(var(--tx)) translateY(var(--ty)) rotateY(var(--ry)) scale(var(--s));
  backface-visibility: hidden;
  transition: transform var(--turn) var(--lag), opacity .35s ease var(--lag);
  will-change: transform;
}

/* liquid-glass rim: brighter where light would catch the edges */
.card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  padding: 1px;
  border-radius: inherit;
  background: linear-gradient(140deg, var(--rim-hi), var(--rim-lo) 32%, var(--rim-lo) 68%, var(--rim-hi));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

/* shading that sweeps over a pane while it turns */
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(90deg, transparent 30%, var(--fold));
  opacity: 0;
  transition: opacity var(--turn) var(--lag);
}

.card-body {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 34px 38px 34px;
  scrollbar-width: thin;
  scrollbar-color: var(--outline) transparent;
  transition: opacity .4s ease;
}

.card[data-state="front"] { opacity: 1; }

/* panes waiting underneath: empty glass, slightly smaller, edges peeking out */
.card[data-state="stack"] {
  --s: calc(1 - var(--d) * .04);
  --tx: calc(var(--d) * 2%);
  --ty: calc(var(--d) * 2% + var(--d) * 11px);
  opacity: calc(1 - var(--d) * .25);
}
.card[data-state="stack"] .card-body,
.card[data-state="hidden"] .card-body { opacity: 0; }

.card[data-state="hidden"] {
  --s: .84;
  --tx: 8%;
  --ty: calc(8% + 44px);
  opacity: 0;
}

/* panes already read: flipped over the left edge */
.card[data-state="turned"] {
  --ry: -105deg;
  opacity: 0;
  transition: transform var(--turn) var(--lag), opacity .2s ease calc(var(--lag) + 550ms);
}
.card[data-state="turned"]::before { opacity: 1; }

.no-anim .card,
.no-anim .card::before,
.no-anim .card-body { transition: none !important; }

@media (prefers-reduced-motion: reduce) {
  .card,
  .card[data-state="turned"] { transition: opacity .25s ease !important; }
  .card[data-state="turned"],
  .card[data-state="hidden"] { --ry: 0deg; --s: 1; --tx: 0%; --ty: 0%; }
  .blob { animation: none; }
}

/* ---------- card content ---------- */

.card-title {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 28px;
  font-size: clamp(2.2rem, 6vw, 3.1rem);
  font-weight: 300;
  line-height: 1.05;
  letter-spacing: -.025em;
  text-transform: lowercase;
}

.chapter {
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .12em;
  color: var(--accent);
}

.label {
  margin-bottom: 12px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--faint);
}

.prose {
  max-width: 64ch;
  font-size: 1.06rem;
  line-height: 1.8;
}
.prose + .prose { margin-top: 1em; }
.prose a {
  color: var(--accent);
  font-weight: 500;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

/* cover */

.cover {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.eyebrow {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--accent);
  text-transform: lowercase;
}

.cover h1 {
  margin: 4px 0 16px;
  font-size: clamp(2.8rem, 9vw, 4.6rem);
  font-weight: 300;
  line-height: 1;
  letter-spacing: -.04em;
}

.lede {
  max-width: 46ch;
  font-size: 1.06rem;
  color: var(--muted);
}

.cover .label { margin-top: auto; padding-top: 30px; }

/* tiles (Metro, through glass) */

.tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.tiles > li { display: flex; }
.tiles > .tile-about,
.tiles > .tile-education,
.tiles > .tile-contact { grid-column: span 2; }

.tile-about { --c: #2f5bea; }
.tile-skills { --c: #7340e6; }
.tile-experience { --c: #00897b; }
.tile-education { --c: #e8590c; }
.tile-contact { --c: #d6336c; }
.tile-mail { --c: #2f5bea; }
.tile-github { --c: #24292f; }
.tile-linkedin { --c: #0a66c2; }

.tile {
  flex: 1;
  display: grid;
  grid-template-rows: 1fr auto;
  align-items: start;
  min-height: 100px;
  padding: 14px 16px;
  border-radius: var(--tile-radius);
  background: color-mix(in srgb, var(--c) 86%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  backdrop-filter: blur(14px) saturate(160%);
  box-shadow: inset 0 0 0 100vmax transparent;
  color: #fff;
  text-decoration: none;
  transition: transform .2s, box-shadow .2s;
}
.tile:hover { box-shadow: inset 0 0 0 100vmax var(--hover); }
.tile:active { transform: scale(.97); }
.tile > svg { width: 24px; height: 24px; stroke-width: 1.6; }

.tile-num {
  position: absolute;
  top: 12px;
  right: 14px;
  font-size: .75rem;
  font-weight: 600;
  opacity: .75;
}
.tile-num svg { width: 16px; height: 16px; }

.tile-label {
  font-size: 1.1rem;
  font-weight: 400;
  line-height: 1.2;
  text-transform: lowercase;
}

.hint {
  margin-top: 14px;
  font-size: .8rem;
  color: var(--faint);
}

/* skills */

.skill-groups { display: grid; gap: 26px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips li {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--outline);
  background: var(--chip);
  font-size: .92rem;
  font-weight: 500;
}

/* experience & education */

.entry {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 18px;
  padding: 22px 0;
  border-top: 1px solid var(--outline);
}
.entry:first-child { padding-top: 0; border-top: 0; }

.entry-logo {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  object-fit: cover;
  background: #fff;
  box-shadow: 0 0 0 1px var(--outline);
}

.period {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--faint);
}
.entry h3 { margin-top: 2px; font-size: 1.2rem; font-weight: 600; line-height: 1.3; }
.entry-sub { margin: 2px 0 8px; font-weight: 500; color: var(--accent); }
.entry-text { color: var(--muted); }

/* contact */

.contact-tiles {
  grid-template-columns: 1fr 1fr;
  margin: 28px 0 0;
}
.tile-mail { grid-column: 1 / -1; min-height: 120px; }
.tile-mail .tile-label {
  font-size: clamp(1.1rem, 4vw, 1.6rem);
  font-weight: 300;
  text-transform: none;
  overflow-wrap: anywhere;
}
.tile-mail small {
  display: block;
  margin-bottom: 2px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  opacity: .8;
}
.tile-github .tile-label,
.tile-linkedin .tile-label { text-transform: none; }

.copyright {
  margin-top: 32px;
  font-size: .8rem;
  color: var(--faint);
}

/* Static snapshot: visible without JavaScript, hidden until app.js replaces it. */
.snapshot { position: relative; height: 100%; overflow: auto; padding: 8px 24px 24px; }
.snapshot h1 { margin: 0 0 4px; }
.snapshot a { color: inherit; }
.js .snapshot { visibility: hidden; }

/* ---------- small screens ---------- */

@media (max-width: 640px) {
  :root { --radius: 22px; }
  .app { gap: 10px; padding-top: 12px; }
  .pivot ol { gap: 18px; }
  .deck { margin-bottom: 22px; }
  .card-body { padding: 26px 22px; }
  .card-title { margin-bottom: 22px; }
  .tiles { grid-template-columns: 1fr 1fr; }
  .tiles > .tile-about { grid-column: span 2; }
  .tiles > .tile-education,
  .tiles > .tile-contact { grid-column: span 1; }
  .tile { min-height: 88px; }
  .entry { grid-template-columns: 40px 1fr; gap: 14px; }
  .entry-logo { width: 40px; height: 40px; border-radius: 10px; }
  .fab { width: 52px; height: 52px; }
}

/* ---------- print: every page, one after another ---------- */

@media print {
  body { overflow: visible; background: #fff; color: #000; }
  .backdrop, .topbar, .pivot, .bottombar, .hint, .cover .label, .cover .tiles { display: none; }
  .app { display: block; height: auto; max-width: none; padding: 0; }
  .deck { margin: 0; perspective: none; }
  .card {
    position: static;
    opacity: 1 !important;
    transform: none !important;
    background: none;
    backdrop-filter: none;
    box-shadow: none;
    break-inside: avoid;
  }
  .card::before, .card::after { display: none; }
  .card-body { opacity: 1 !important; overflow: visible; padding: 12px 0; }
  .tile { color: #000; background: none; backdrop-filter: none; box-shadow: none; border: 1px solid #ccc; min-height: 0; }
}
