/* Mahati Batchu portfolio - see DESIGN.md */

/* Habibi's figures are true old-style: 0/1/2 stand at x-height, 3/5/7/9 descend
   0.26em, 6/8 ascend. Beside the all-caps labels they read as a dropped line, and the
   font ships no lining set, so digits borrow one from a serif that has them. Georgia
   is deliberately absent - its figures are old-style too. If none of these resolve,
   the range falls through to Habibi and nothing is worse than before. */
@font-face {
  font-family: 'Lining Figures';
  src: local('Times New Roman'), local('Liberation Serif'),
       local('Nimbus Roman'), local('DejaVu Serif'), local('Tinos');
  unicode-range: U+0030-0039;
}

:root {
  /* Gallery wall theme (client, 2026-12-05): every page is a painted wall lit from
     above, artwork hangs in thin black frames, text is cream. The homepage is the
     warm-charcoal "main hall"; pages.css repaints --wall per category.
     Replaces the DESIGN.md 1 white/black tokens - same names, new values. */
  --wall: #3a3430;
  --wall-ink: #f4eee4;
  --wall-light:
    radial-gradient(ellipse 80% 55% at 50% -8%, rgba(255, 246, 230, 0.22), transparent 70%),
    radial-gradient(ellipse 120% 80% at 50% 120%, rgba(0, 0, 0, 0.28), transparent 60%);
  --mat: #fbf8f2;            /* cream: label cards */
  --frame: #1c1916;          /* frames, bezels */
  --hang-shadow: 0 2px 3px rgba(0, 0, 0, 0.3), 0 24px 48px -12px rgba(0, 0, 0, 0.55);

  --color-artwork: #2b2724;  /* tile placeholder before its image loads */
  --color-ink: var(--wall-ink);
  --color-brand-accent: #A11919;
  --color-surface: var(--wall);
  --color-scrim: var(--wall);
  --color-frame: var(--frame);

  /* DESIGN.md 2 - Figma authored on a 592x363 thumbnail; ~2.4x at 1440, fluid down
     to 1.4x on a phone. Every size below is the raw Figma px count multiplied by this
     one unit, so the relative type scale is preserved exactly at every width.
     It is a *length*, not a number: a unitless clamp() mixing vw is invalid CSS. */
  --unit: clamp(1.4px, 0.686px + 0.119vw, 2.4px);

  --fs-logo: calc(16 * var(--unit));
  --fs-wordmark: calc(12 * var(--unit));
  --fs-artwork-name: calc(13 * var(--unit));
  --fs-medium: calc(10 * var(--unit));
  --fs-email: calc(6 * var(--unit));

  --col-gutter: 14px;

  --ease-out: cubic-bezier(0.22, 0.61, 0.36, 1);

  /* Driven by main.js */
  --progress: 0;
  --scrim-opacity: 0;
  --hero-blur: 0px;
}

* { box-sizing: border-box; }

/* ---------- Page transitions (every same-origin link; enter.js picks special cases) ---------- */

@view-transition { navigation: auto; }

/* The old page drifts up and fades; the new one rises in just behind it. */
::view-transition-old(root) { animation: page-out 260ms ease both; }
::view-transition-new(root) { animation: page-in 520ms 60ms var(--ease-out) both; }
::view-transition-group(*) {
  animation-duration: 560ms;
  animation-timing-function: var(--ease-out);
}

@keyframes page-out { to { opacity: 0; transform: translateY(-14px); } }
@keyframes page-in  { from { opacity: 0; transform: translateY(18px); } }

/* No cross-document transitions (Firefox): pages fade in. Opacity only - a transform
   on <body> would break the homepage's fixed layers mid-animation. */
@media (prefers-reduced-motion: no-preference) {
  .no-vt body { animation: page-fade 420ms ease both; }
}
@keyframes page-fade { from { opacity: 0; } }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;            /* scroll is hijacked; page never scrolls. PLANNING.md Frame 1 */
  overscroll-behavior: none;   /* kills iOS rubber-band over the hijacked stage */
  background: var(--wall-light), var(--color-surface);
  background-attachment: fixed;
  color: var(--color-ink);
  font-family: 'Lining Figures', Habibi, Georgia, serif;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Stage (Frames 1-5) ---------- */

#stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: none;
}

/* ---------- Frame 1: hero ---------- */

#hero {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  text-align: center;
  filter: blur(var(--hero-blur));
  opacity: calc(1 - var(--progress) * 1.35);   /* fully gone before Frame 4 closes */
  will-change: filter, opacity;
}

/* Portrait frame: the black is the frame itself (padding on an ink background), so
   the photo never gets covered. Bevel = light catching the inner top-left edge, shade
   on the bottom-right, a hairline fillet where frame meets photo, and a soft wall
   shadow under the whole thing. Same 106-unit width the logo had, so the
   wordmark ratio and the Frame 1 column gap are unchanged. */
#portrait-frame,
.about-photo {
  margin: 0;
  background: var(--color-frame);
  border-radius: 2px;
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, 0.22),
    inset -1px -1px 0 rgba(0, 0, 0, 0.6),
    0 calc(4 * var(--unit)) calc(10 * var(--unit)) rgba(0, 0, 0, 0.18);
}

#portrait,
.about-photo img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.28);   /* fillet line */
}

/* The frame is a <button> (opens About), so it drops the native button chrome. */
#portrait-frame {
  display: block;
  width: clamp(190px, 34vmin, 460px);   /* tracks the smaller screen side, so it grows on big screens and still fits short ones */
  padding: calc(5 * var(--unit));
  border: 0;
  font: inherit;
  cursor: pointer;
  transition: transform 200ms ease;
}

/* Gated like the tiles: on touch :hover latches after the tap. */
@media (hover: hover) and (pointer: fine) {
  #portrait-frame:hover { transform: scale(1.02); }
}

#portrait-frame:focus-visible {
  outline: 2px solid var(--color-ink);
  outline-offset: 4px;
}

#hero-row {
  display: flex;
  align-items: center;
  gap: calc(16 * var(--unit));
}

.hero-cats {
  display: flex;
  flex-direction: column;
  gap: calc(4 * var(--unit));
  width: calc(60 * var(--unit));
}

.hero-cats-left  { align-items: flex-end; text-align: right; }
.hero-cats-right { align-items: flex-start; text-align: left; }

.hero-cats a {
  padding: 4px 0;
  color: var(--color-ink);
  font-size: max(11px, var(--fs-email));
  letter-spacing: 0.24em;
  white-space: nowrap;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 160ms ease;
}

.hero-cats a:hover,
.hero-cats a:focus-visible { border-bottom-color: currentColor; }

/* ---------- Ways into About ---------- */

/* Hero: outlined button under the email - reads as a button, not another link. */
#about-btn {
  margin-top: calc(9 * var(--unit));
  padding: 9px 20px 8px;
  border: 1px solid currentColor;
  background: none;
  color: var(--color-ink);
  font: inherit;
  font-size: max(11px, var(--fs-email));
  letter-spacing: 0.3em;
  cursor: pointer;
  transition: background-color 180ms ease, color 180ms ease;
}

/* Gallery: pill at the bottom, only once the grid has docked (the hero is gone then).
   Solid wall + hanging shadow so it stays legible over any artwork. */
#about-pill {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  z-index: 15;
  padding: 11px 26px 10px;
  border: 1px solid rgba(244, 238, 228, 0.55);
  border-radius: 999px;
  background: var(--wall);
  color: var(--color-ink);
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.3em;
  box-shadow: var(--hang-shadow);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 14px);
  transition: opacity 300ms ease, transform 300ms var(--ease-out),
              background-color 180ms ease, color 180ms ease;
}

#stage.docked ~ #about-pill {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

/* Both invert to cream on hover/focus. */
#about-btn:hover, #about-btn:focus-visible,
#about-pill:hover, #about-pill:focus-visible {
  background: var(--color-ink);
  color: var(--wall);
}

#wordmark {
  margin: calc(10 * var(--unit)) 0 0;
  font-size: var(--fs-wordmark);
  letter-spacing: 0.18em;
  color: var(--color-ink);
}

#email {
  position: relative;
  margin-top: calc(4 * var(--unit));
  /* 6px x 1.4 is 8.4px on a phone - unreadable, and this is a real mailto target.
     The floor only bites below ~1.83x; desktop keeps the authored ratio exactly. */
  font-size: max(11px, var(--fs-email));
  letter-spacing: 0.1em;
  color: var(--color-ink);
  text-decoration: none;
}

/* Expands the tap target to ~44px without moving anything. */
#email::after {
  content: '';
  position: absolute;
  inset: -15px -24px;
}

/* ---------- Scrim (Frames 2-4) ---------- */

#scrim {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: var(--color-scrim);
  opacity: var(--scrim-opacity);
  pointer-events: none;
}

/* ---------- Columns (Frames 1-5) ---------- */

#columns {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;   /* the container must not shadow the hero's email link */
}

.col {
  position: absolute;
  pointer-events: auto;
  top: 0;
  bottom: 0;
  overflow: hidden;
  padding: 0 calc(var(--col-gutter) / 2);
  will-change: transform;
}

.col-inner {
  position: absolute;
  top: 0;
  left: calc(var(--col-gutter) / 2);
  right: calc(var(--col-gutter) / 2);
  display: flex;
  flex-direction: column;
  gap: var(--col-gutter);
  will-change: transform;
}

/* DESIGN.md 5 - shape-agnostic tile. Aspect ratio is per-piece, never fixed. */
/* Every interactive state is the same three values at different settings, so they live
   in custom properties and each state below is a short override. */
.tile {
  --grow: 1;
  --stroke: 0px;
  --radius: 0px;

  position: relative;   /* so a raised tile paints over its neighbours */
  display: block;       /* it is an <a> */
  width: 100%;
  aspect-ratio: var(--ratio);
  background: var(--color-artwork);
  background-size: cover;
  background-position: center;
  border: 0 solid transparent;
  border-radius: var(--radius);
  transform: scale(var(--grow));   /* grows from its own center, no lift */
  /* All box-shadow, so nothing shifts layout: the hover stroke inside, the thin black
     frame outside (it sits in the column gutter), then the hanging shadow. */
  box-shadow:
    inset 0 0 0 var(--stroke) var(--color-ink),
    0 0 0 4px var(--color-frame),
    var(--hang-shadow);
  cursor: default;
  transition: transform 140ms ease, border-radius 140ms ease, box-shadow 140ms ease;
}

/* Hover affordance is live only once the grid is docked (Frame 5). DESIGN.md 7 */
#stage.docked .tile { cursor: pointer; }

/* Raised: grown out from its own center, heavier stroke. The growth is capped by the
   gutter - the column clips at its own edge, so anything wider gets cut off. */
#stage.docked .tile:focus-visible {
  --grow: 1.03;
  --stroke: 3px;
  --radius: 10px;
  z-index: 1;
  outline: none;
}

/* Gated to real pointers - on touch, :hover latches after a tap and leaves the
   stroke stuck on the last tile touched. */
@media (hover: hover) and (pointer: fine) {
  #stage.docked .tile:hover {
    --grow: 1.03;
    --stroke: 3px;
    --radius: 10px;
    z-index: 1;
  }

  /* Press settles it back toward the grid without dropping the raised look. */
  #stage.docked .tile:active {
    --grow: 1.005;
    transition-duration: 60ms;
  }
}

/* Touch has no hover, so the press itself carries the whole affordance. */
@media (hover: none) {
  #stage.docked .tile:active {
    --grow: 1.02;
    --stroke: 3px;
    --radius: 10px;
    z-index: 1;
  }
}

/* Exit affordance, shared by the About overlay and the PDF viewer. */
#about-close,
#pdf-close {
  position: absolute;
  top: calc(20px + env(safe-area-inset-top));
  right: calc(20px + env(safe-area-inset-right));
  min-width: 44px;                    /* tap target */
  min-height: 44px;
  padding: 8px 14px;
  border: 0;
  background: none;
  color: var(--color-ink);
  font: inherit;
  font-size: var(--fs-email);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  cursor: pointer;
}

/* ---------- Scroll hint (Frame 1 idle) ---------- */

#scroll-hint {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--color-ink);
  font-size: var(--fs-email);
  letter-spacing: 0.3em;
  pointer-events: none;
  opacity: 0;
  transform: translateX(-50%);
  transition: opacity 400ms ease;
}

#scroll-hint.show { opacity: 0.9; }
#scroll-hint.show svg { animation: hint-bob 1.6s ease-in-out infinite; }

@keyframes hint-bob {
  50% { transform: translateY(-6px); }
}

/* ---------- About (opens from the Frame 1 portrait) ---------- */

/* Full white cover. Its opening animation (main.js) clips it to
   the portrait's rectangle and opens the clip to full screen. It scrolls on its own
   when the content outgrows the viewport - the stage's wheel hijack stands down while
   it is open. */
#about {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--wall-light), var(--color-surface);
}

#about[hidden] { display: none; }

/* margin:auto rather than align-items:center - when the content is taller than the
   viewport, flex centering would push its top out of reach of the scroll. */
#about-inner {
  margin: auto;
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1fr);
  align-items: center;
  gap: clamp(32px, 6vw, 110px);
  width: min(1200px, 100%);
  padding: 80px clamp(15px, 5vw, 80px);
}

/* Each links card hangs below the portrait / bio out of flow, so the portrait stays centred
   beside the bio exactly as it was; #about scrolls to reach the card. */
.about-side {
  position: relative;
  justify-self: end;
  display: grid;
  gap: 28px;
  /* Bounded by height too, so the 4:5 photo always fits the viewport with room to spare. */
  width: min(460px, 100%, calc((100vh - 200px) * 0.8));
}

.about-photo { padding: calc(7 * var(--unit)); }

.about-bio { position: relative; display: grid; gap: 28px; width: fit-content; }
section.about-links { display: block; }   /* single section: no grid gap under its heading */

/* Studies / resume / LinkedIn / contact: one ruled section each on the small card. */
.about-links {
  position: absolute;
  top: calc(100% + 28px);
  left: 0;
  right: 0;
  display: grid;
  gap: 1.3em;
}
.about-links.about-links { max-width: none; }   /* full photo width, beats the 50ch below */
.about-links > section + section { padding-top: 1.3em; border-top: 1px solid rgba(28, 25, 22, 0.15); }

/* Cream label card, same as the caption beside each artwork (.piece-meta in pages.css).
   Re-pointing --color-ink turns every link and heading inside dark. */
.about-text,
.about-links {
  --color-ink: var(--frame);
  max-width: 50ch;
  padding: clamp(24px, 3vw, 40px);
  background: var(--mat);
  color: var(--frame);
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.25), 0 18px 36px -14px rgba(0, 0, 0, 0.5);
}

#about-title {
  margin: 0 0 1em;
  font-size: var(--fs-artwork-name);
  font-weight: 400;
  letter-spacing: 0.14em;
}

.about-text p {
  margin: 0 0 1.1em;
  font-size: var(--fs-medium);
  line-height: 1.7;
  letter-spacing: 0.04em;
}


.about-studies h3 {
  margin: 0 0 0.7em;
  font-size: var(--fs-medium);
  font-weight: 400;
  letter-spacing: 0.14em;
}

.about-studies ul {
  display: flex;
  flex-direction: column;
  align-items: start;
  gap: 0.6em;
  margin: 0;
  padding: 0;
  list-style: none;
}

.about-studies a {
  color: var(--color-ink);
  font-size: max(12px, calc(7.5 * var(--unit)));   /* a step under the section heading */
  letter-spacing: 0.08em;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}

/* ---------- PDF overlay (dialog in the top layer, above About) ---------- */

#pdf-viewer {
  width: min(1100px, 100vw - 40px);
  height: calc(100vh - 40px);
  max-width: none;
  max-height: none;
  padding: 0;
  border: 0;
  background: var(--color-surface);
  color: var(--color-ink);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

#pdf-viewer[open] {
  display: flex;
  flex-direction: column;
  animation: pdf-in 280ms var(--ease-out);
}

#pdf-viewer::backdrop { background: rgba(0, 0, 0, 0.55); }

@keyframes pdf-in {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
}

.pdf-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 4px 20px;
}

#pdf-title {
  margin: 0 auto 0 0;
  font-size: var(--fs-medium);
  font-weight: 400;
  letter-spacing: 0.14em;
}

#pdf-newtab {
  color: var(--color-ink);
  font-size: var(--fs-email);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  text-decoration: none;
}

#pdf-close { position: static; }

#pdf-pages {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: #525659;
}

#pdf-pages img {
  display: block;
  width: 100%;
  max-width: 1100px;
  height: auto;
  background: var(--color-surface);   /* page-shaped placeholder while it loads */
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* ---------- Narrow viewports ---------- */
@media (max-width: 760px) {
  #about-inner {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 28px;
    padding: calc(64px + env(safe-area-inset-top)) 22px calc(40px + env(safe-area-inset-bottom));
  }

  .about-side { justify-self: center; width: min(340px, 100%); }
  .about-photo { justify-self: center; width: min(300px, 72vw); }
  .about-links { position: static; text-align: center; }
  .about-text { text-align: center; }
  .about-studies ul { align-items: center; }
  #pdf-viewer { width: 100vw; height: 100dvh; }

  /* No room beside the portrait on a phone: the buttons drop below it as two rows. */
  #hero-row { flex-direction: column; gap: calc(8 * var(--unit)); }
  #portrait-frame { order: -1; }
  .hero-cats,
  .hero-cats-left,
  .hero-cats-right {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    width: auto;
    gap: 2px 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  .tile { transition: none; }
  #portrait-frame { transition: none; }
  #pdf-viewer[open] { animation: none; }
  #scroll-hint.show svg { animation: none; }
  #about-pill, #about-btn { transition: none; }
}

