/* ==========================================================================
   Varun Saravanan — portfolio
   Stilez palette: cream · navy · brass. Inter throughout.
   The three.js figure lives in its own hero column; everything else is plain and readable.
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  /* Stilez palette: cream paper, navy ink, brass accent */
  --bg:       #F7F3E7;
  --bg-2:     #EFEADB;
  --bg-3:     #FCFAF2;
  --ink:      #101C30;
  --ink-2:    #5A6878;
  --ink-3:    #8A93A0;
  --rule:     #E2DDCB;
  --accent:   #C08A14;
  --accent-2: #8C6410;
  --gold:     #E6C24A;

  --surface:   #EFEADB;   /* tinted band */
  --surface-2: #FCFAF2;   /* elevated card */

  --font-display: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-body:    'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  --gutter:   clamp(20px, 5vw, 72px);
  --page-max: 1440px;
  /* horizontal padding that also centres the page on very wide screens */
  --page-pad: max(var(--gutter), calc((100vw - var(--page-max)) / 2 + var(--gutter)));
  --measure:  1120px;
  --header-h: 64px;
  --ease:     cubic-bezier(.22, .61, .21, 1);
  --ease-in-out: cubic-bezier(.65, 0, .35, 1);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 8px);
  -webkit-text-size-adjust: 100%;
}
body {
  font-family: var(--font-body);
  font-size: 1rem; line-height: 1.55;
  color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}
::selection { background: var(--accent); color: var(--bg); }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
strong, b { font-weight: 600; }
.muted { color: var(--ink-2); }

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

.skip {
  position: absolute; left: 16px; top: -100px; z-index: 100;
  padding: 8px 12px; background: var(--ink); color: var(--bg); font-size: .85rem; border-radius: 2px;
}
.skip:focus { top: 12px; }

/* Small uppercase label used across the site */
.label, .eyebrow {
  font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2);
}
.label > span { color: var(--ink); }
.label > span::after { content: " · "; color: var(--ink-3); }
.label.solo > span::after { content: none; }

/* Text links */
.links { display: flex; flex-wrap: wrap; gap: 8px 28px; }
.links a {
  display: inline-block; padding: 2px 0; font-size: .95rem; color: var(--ink);
  text-decoration: underline; text-decoration-color: var(--ink-3);
  text-decoration-thickness: 1px; text-underline-offset: .24em;
  transition: color .25s, text-decoration-color .25s;
}
.links a:hover { color: var(--accent-2); text-decoration-color: var(--accent); }

/* ---------- Header ---------- */
.site-header {
  /* navy bar so it never blends into the cream page */
  --ink: #F7F3E7; --ink-2: #C3CBDA; --ink-3: #8C97AB; --rule: #263352; --accent: #E6C24A;
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  height: var(--header-h); padding: 0 var(--page-pad);
  display: flex; align-items: center; gap: clamp(20px, 3vw, 48px);
  background: #101C30; color: var(--ink);
  border-bottom: 1px solid #1B2A45;
  transition: transform .5s var(--ease), background .4s, box-shadow .4s;
}
.site-header.is-scrolled {
  background: rgba(16, 28, 48, .92);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  box-shadow: 0 8px 24px -18px rgba(16, 28, 48, .6);
}
.site-header.is-hidden { transform: translateY(-100%); }
.brand {
  margin-right: auto; font-family: var(--font-display); font-size: 1rem; font-weight: 600; letter-spacing: -.01em; white-space: nowrap;
}
.site-nav { display: flex; gap: clamp(16px, 2.4vw, 32px); }
.site-nav a { position: relative; padding: 6px 0; font-size: .9rem; color: var(--ink-2); transition: color .25s; }
.site-nav a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 2px; height: 1px;
  background: var(--accent); transform: scaleX(0); transform-origin: left; transition: transform .35s var(--ease);
}
.site-nav a:hover, .site-nav a[aria-current="true"] { color: var(--ink); }
.site-nav a:hover::after, .site-nav a[aria-current="true"]::after { transform: scaleX(1); }
.header-place { font-size: .8rem; color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.clock:not(:empty)::before { content: "· "; }

/* ---------- Hero ---------- */
.hero {
  min-height: 100svh;
  padding: calc(var(--header-h) + 8vh) var(--page-pad) 6vh;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  column-gap: clamp(32px, 5vw, 80px);
  align-items: center;
}
.hero-text {
  display: flex; flex-direction: column; align-items: flex-start;
  gap: clamp(18px, 2.6vh, 28px);
}
.hero h1 {
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(2rem, 3.4vw, 3.4rem); line-height: 1.1; letter-spacing: -.025em;
  max-width: 21ch; text-wrap: balance;
}
.hero h1 em { color: var(--accent-2); font-style: normal; }
.hero-lede { max-width: 50ch; font-size: clamp(1rem, 1.15vw, 1.1rem); line-height: 1.5; }
.roles {
  width: 100%; max-width: 56ch;
  display: flex; flex-direction: column; gap: 8px;
}
.roles li {
  display: grid; grid-template-columns: minmax(0, 13rem) minmax(0, 1fr); column-gap: 16px;
  padding: 12px 16px; border: 1px solid var(--rule); border-radius: 8px; background: var(--surface-2);
  font-size: .92rem; line-height: 1.4;
}
.roles strong { font-weight: 600; color: var(--ink); }
.roles span { color: var(--ink-2); }
.hero-text .scroll-cue { margin-top: clamp(12px, 3vh, 36px); }
.scroll-cue {
  display: inline-flex; align-items: center; gap: 12px; width: max-content;
  font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); transition: color .25s;
}

/* The figure: the 3D piece lives here, in its own column, never under text. */
.hero-figure { margin: 0; align-self: center; }
.hero-canvas {
  position: relative; aspect-ratio: 5 / 4; width: 100%;
  border: 1px solid var(--rule); border-radius: 6px; background: var(--bg-3);
  overflow: hidden;
}
#figure {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block;
  opacity: 0; transition: opacity .6s var(--ease);
}
#figure.is-ready { opacity: 1; }
.scroll-cue:hover { color: var(--ink); }

/* Split-text masks (applied by JS) */
.w { display: inline-block; overflow: hidden; vertical-align: bottom; padding-bottom: .08em; margin-bottom: -.08em; }
.w > span { display: inline-block; will-change: transform; }

/* ---------- Sections ---------- */
.section {
  padding: clamp(72px, 12vh, 136px) var(--page-pad);
  border-top: 1px solid var(--rule);
}
.section-head { max-width: var(--measure); margin-bottom: clamp(32px, 5vh, 56px); }
.section h2, .case h1 {
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(1.9rem, 3.4vw, 2.8rem); line-height: 1.1; letter-spacing: -.024em;
}
.section-sub { margin-top: 14px; max-width: 58ch; font-size: 1.05rem; color: var(--ink-2); }

/* Surface variants */
.section--tint { background: var(--surface); }
.section--tint .tl-body { border-color: #E4DECC; }
.section--navy, .site-footer--navy {
  --bg: #101C30; --surface: #16233B; --surface-2: #16233B;
  --ink: #F7F3E7; --ink-2: #A8B2C4; --ink-3: #7C8699; --rule: #263352;
  --accent: #E6C24A; --accent-2: #F0D470;
  background: var(--bg); color: var(--ink);
}
.section--navy { border-top-color: transparent; }
.section--navy ::selection { background: var(--accent); color: #101C30; }
.site-footer--navy { border-top-color: var(--rule); }

/* ---------- Timelines (experience, projects) ---------- */
.timeline {
  position: relative; max-width: var(--measure);
  --tl-when: 148px;   /* date column */
  --tl-rail: 28px;    /* rail column */
}
.timeline::before {                      /* the rail */
  content: ""; position: absolute; top: 12px; bottom: 12px;
  left: calc(var(--tl-when) + var(--tl-rail) / 2);
  width: 1px; background: var(--rule);
}
.timeline > li { position: relative; }
.timeline > li::before {                 /* the stop */
  content: ""; position: absolute; top: 46px;
  left: calc(var(--tl-when) + var(--tl-rail) / 2 - 5px);
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--ink);
  transition: background .25s, border-color .25s, transform .3s var(--ease);
  z-index: 1;
}
.timeline > li:hover::before { background: var(--accent); border-color: var(--accent); transform: scale(1.15); }
.timeline > li:has(.tl-static)::before { border-color: var(--ink-3); background: var(--bg); }
.timeline > li:has(.tl-static):hover::before { transform: none; }

.tl-card {
  display: grid; grid-template-columns: var(--tl-when) var(--tl-rail) minmax(0, 1fr);
  padding: 22px 0 30px;
  border-radius: 6px;
}
.tl-when {
  padding-top: 20px; padding-right: 16px;
  font-size: .82rem; letter-spacing: .02em; color: var(--ink-2);
  font-variant-numeric: tabular-nums; text-align: right;
}
.tl-body {
  grid-column: 3;
  padding: 20px 24px 22px;
  background: var(--surface-2);
  border: 1px solid var(--rule); border-radius: 10px;
  transition: border-color .25s, box-shadow .3s var(--ease), transform .3s var(--ease);
}
.tl-card:hover .tl-body { border-color: #D6CFB8; box-shadow: 0 6px 24px -14px rgba(16, 28, 48, .28); transform: translateY(-1px); }
.tl-static .tl-body { background: transparent; border: 1px dashed var(--rule); box-shadow: none; }
.tl-body h3 {
  margin-top: 6px;
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(1.3rem, 1.9vw, 1.6rem); line-height: 1.15; letter-spacing: -.02em;
  transition: color .25s;
}
.tl-card:hover h3 { color: var(--accent-2); }
.tl-summary { margin-top: 12px; max-width: 60ch; font-size: 1rem; line-height: 1.55; text-wrap: pretty; }
.tl-static .tl-summary { color: var(--ink-2); margin-top: 8px; }
.tl-stats { display: flex; flex-wrap: wrap; gap: 12px 32px; margin-top: 18px; }
.tl-stats li { display: flex; flex-direction: column; gap: 2px; }
.tl-stats b {
  font-family: var(--font-display); font-weight: 600;
  font-size: 1.2rem; letter-spacing: -.02em; color: var(--ink); white-space: nowrap; line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.tl-stats span { font-size: .85rem; color: var(--ink-2); line-height: 1.35; }
.tl-tags { margin-top: 16px; font-size: .76rem; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); line-height: 1.7; }
.tl-more {
  display: inline-flex; gap: 8px; align-items: center; margin-top: 14px;
  font-size: .85rem; color: var(--ink-2); transition: color .25s;
}
.tl-more i { font-style: normal; display: inline-block; transition: transform .35s var(--ease); }
.tl-card:hover .tl-more { color: var(--accent-2); }
.tl-card:hover .tl-more i { transform: translateX(4px); }

/* ---------- Table (toolkit) ---------- */
.table {
  max-width: var(--measure);
  background: var(--surface-2); border: 1px solid var(--rule); border-radius: 10px;
  padding: 4px clamp(18px, 2.5vw, 32px);
}
.table > div {
  display: grid; grid-template-columns: 200px minmax(0, 1fr); column-gap: clamp(24px, 4vw, 56px);
  padding: 18px 0; border-bottom: 1px solid var(--rule);
}
.table > div:last-child { border-bottom: none; }
.table dt { padding-top: 3px; font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }
.table dd { font-size: 1rem; line-height: 1.55; max-width: 70ch; }

/* ---------- Contact ---------- */
.contact { padding-top: clamp(96px, 18vh, 200px); padding-bottom: clamp(88px, 14vh, 160px); }
.contact h2 {
  font-weight: 600;
  font-size: clamp(2.4rem, 5.6vw, 4.6rem); line-height: 1.02; letter-spacing: -.03em;
}
.contact h2 em { color: var(--accent); font-style: normal; }
.contact-lede { margin-top: 28px; max-width: 52ch; font-size: clamp(1.02rem, 1.25vw, 1.2rem); line-height: 1.5; }
.contact-mail {
  display: inline-block; margin: 32px 0 26px;
  font-family: var(--font-display); font-weight: 500;
  font-size: clamp(1.25rem, 2.6vw, 2rem); letter-spacing: -.02em; line-height: 1.1;
  border-bottom: 1px solid var(--ink-3); overflow-wrap: anywhere;
  transition: color .25s, border-color .25s;
}
.contact-mail:hover { color: var(--accent-2); border-bottom-color: var(--accent); }

/* Embedded report (case pages) */
.case-report { margin-bottom: clamp(48px, 7vh, 80px); }
.case-report-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 24px; margin-bottom: 16px; }
.case-report-head h2 { font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); font-weight: 500; }
.case-report-head p { font-size: .95rem; color: var(--ink-2); }
.case-report-head a, .case-report-fallback a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--ink-3); text-underline-offset: .22em; }
.case-report-head a:hover, .case-report-fallback a:hover { color: var(--accent-2); text-decoration-color: var(--accent); }
.case-report-embed {
  display: block; width: 100%; height: min(82vh, 1000px);
  border: 1px solid var(--rule); border-radius: 6px; background: var(--bg-3);
}
.case-report-fallback { padding: 24px; font-size: .95rem; color: var(--ink-2); }
@media (max-width: 720px) {
  /* phones render embedded PDFs poorly (often just page one); send them to the file instead */
  .case-report-embed { display: none; }
  .case-report-head p::after { content: ""; }
}

/* ---------- Footer ---------- */
.site-footer {
  padding: 24px var(--page-pad) 40px; border-top: 1px solid var(--rule);
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px 32px;
  font-size: .8rem; color: var(--ink-3);
}

/* ---------- Case study pages ---------- */
.case { padding: calc(var(--header-h) + clamp(48px, 8vh, 96px)) var(--page-pad) clamp(72px, 12vh, 120px); }
.case > * { max-width: var(--measure); }
.case-back { display: inline-flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--ink-2); margin-bottom: 40px; transition: color .25s; }
.case-back:hover { color: var(--ink); }
.case-head { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); column-gap: clamp(32px, 6vw, 96px); row-gap: 28px; align-items: start; }
.case h1 { margin-top: 12px; max-width: 16ch; text-wrap: balance; }
.case-lede { margin-top: 20px; max-width: 54ch; font-size: clamp(1.05rem, 1.3vw, 1.2rem); line-height: 1.5; color: var(--ink); text-wrap: pretty; }
.case-meta { background: var(--surface-2); border: 1px solid var(--rule); border-radius: 10px; padding: 4px 20px; }
.case-meta > div { display: grid; grid-template-columns: 96px 1fr; column-gap: 20px; padding: 14px 0; border-bottom: 1px solid var(--rule); font-size: .95rem; }
.case-meta > div:last-child { border-bottom: none; }
.case-meta dt { font-size: .76rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); padding-top: 3px; }
.case-meta dd { color: var(--ink); line-height: 1.5; }
.case-meta .links { gap: 6px 20px; }
.case-meta .links a { font-size: .95rem; }
.case-meta .todo { color: var(--ink-3); font-size: .85rem; }

.case-figures {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 24px 32px;
  margin: clamp(48px, 7vh, 80px) 0; padding: 28px clamp(20px, 3vw, 36px);
  background: var(--surface); border-radius: 10px;
}
.case-figures b {
  display: block; font-family: var(--font-display); font-weight: 600;
  font-size: clamp(1.8rem, 3vw, 2.6rem); line-height: 1; letter-spacing: -.03em; font-variant-numeric: tabular-nums;
}
.case-figures span { display: block; margin-top: 8px; font-size: .9rem; color: var(--ink-2); line-height: 1.4; max-width: 24ch; }

.case-body { display: grid; grid-template-columns: 200px minmax(0, 1fr); column-gap: clamp(24px, 4vw, 64px); row-gap: 40px; }
.case-body h2 {
  font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); font-weight: 500; padding-top: 6px;
  position: sticky; top: calc(var(--header-h) + 24px);
}
.case-body .prose p { max-width: 62ch; font-size: clamp(1rem, 1.15vw, 1.1rem); line-height: 1.6; margin-bottom: 1em; text-wrap: pretty; }
.case-body .prose p:last-child { margin-bottom: 0; }
.case-body .prose ul { max-width: 62ch; display: flex; flex-direction: column; gap: 10px; }
.case-body .prose li { position: relative; padding-left: 18px; font-size: clamp(1rem, 1.15vw, 1.1rem); line-height: 1.55; }
.case-body .prose li::before { content: ""; position: absolute; left: 0; top: .72em; width: 8px; height: 1px; background: var(--accent); }

.case-nav {
  display: grid; grid-template-columns: 1fr 1fr; gap: 24px;
  margin-top: clamp(64px, 10vh, 112px); padding-top: 28px; border-top: 1px solid var(--rule);
}
.case-nav a { display: block; transition: color .25s; }
.case-nav a:hover { color: var(--accent-2); }
.case-nav .label { display: block; margin-bottom: 6px; }
.case-nav .next { text-align: right; }
.case-nav strong { font-family: var(--font-display); font-weight: 600; font-size: 1.1rem; letter-spacing: -.01em; }

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  .js .w > span { transform: translateY(115%); animation: word-rise 1.1s var(--ease) forwards; }
  @keyframes word-rise { to { transform: none; } }
  .js .hero-lede, .js .roles, .js .hero-text .links, .js .scroll-cue, .js .hero-figure { opacity: 0; transform: translateY(12px); animation: fade-rise 1s var(--ease) forwards; }
  .js .hero-lede { animation-delay: .8s; }
  .js .roles { animation-delay: .95s; }
  .js .hero-text .links { animation-delay: 1.1s; }
  .js .hero-figure { animation-delay: .5s; }
  .js .scroll-cue { animation-delay: 1.2s; }
  @keyframes fade-rise { to { opacity: 1; transform: none; } }
  .js [data-reveal] { opacity: 0; transform: translateY(14px); transition: opacity .8s var(--ease), transform .8s var(--ease); }
  .js [data-reveal].is-visible { opacity: 1; transform: none; }
  .scroll-cue svg { animation: bob 2.4s var(--ease-in-out) infinite; }
  @keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(5px); } }
}

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .timeline { --tl-when: 112px; }
  .case-head { grid-template-columns: 1fr; }
  .header-place { display: none; }
  .hero { grid-template-columns: 1fr; row-gap: 40px; align-items: start; padding-top: calc(var(--header-h) + 5vh); }
  .hero-figure { max-width: 560px; }
  .hero-canvas { aspect-ratio: 16 / 10; }
  .case-body { grid-template-columns: 1fr; row-gap: 12px; }
  .case-body h2 { position: static; }
  .case-body .prose { margin-bottom: 20px; }
}
@media (max-width: 720px) {
  /* phone: date sits above the card, rail hugs the left edge */
  .timeline { --tl-when: 0px; --tl-rail: 22px; }
  .tl-card { grid-template-columns: var(--tl-rail) minmax(0, 1fr); padding: 18px 0 26px; }
  .tl-when { grid-column: 2; text-align: left; padding: 0 0 6px 8px; }
  .tl-body { grid-column: 2; padding: 16px 16px 18px; }
  .timeline > li::before { top: 22px; }
  .tl-stats { gap: 10px 22px; }
  .table > div { grid-template-columns: 1fr; row-gap: 6px; padding: 14px 0; }
  .case-nav { grid-template-columns: 1fr; }
  .case-nav .next { text-align: left; }
}
@media (max-width: 520px) {
  .roles li { grid-template-columns: 1fr; row-gap: 2px; }
  .site-nav { gap: 14px; }
  .site-nav a { font-size: .85rem; }
  .brand { font-size: .98rem; }
}

/* ---------- Print ---------- */
@media print {
  :root { --bg: #fff; --bg-2: #fff; --ink: #000; --ink-2: #444; --ink-3: #666; --rule: #bbb; --accent: #000; --accent-2: #000; }
  #figure, .hero-canvas, .site-header, .scroll-cue, .clock, .tl-more { display: none; }
  .hero { min-height: 0; }
  .hero { padding-top: 24px; grid-template-columns: 1fr; }
  .section, .case { padding: 28px 0; }
  .tl-card { break-inside: avoid; }
  [data-reveal], .hero-lede, .roles, .hero-text .links, .hero-figure, .w > span { opacity: 1 !important; transform: none !important; animation: none !important; }
  .links a[href^="http"]::after { content: " (" attr(href) ")"; font-size: .8em; color: var(--ink-2); }
}
