/* static/css/style.css */

/* --- Design tokens --- */
:root {
  --bg: #ffffff;
  --fg: #0b0b0b;
  --muted: #4b5563;
  --pill: rgba(0, 0, 0, 0.04);
  --pillsim: rgba(239, 239, 239, 0.9);
  --pillsimdark: rgba(227, 227, 227, 0.9);
  --pill-stroke: rgba(0, 0, 0, 0.10);
  --btnhover: var(--bluebutton);
  --lightmodal: rgba(250, 250, 250, 0.04);
  --modal: rgba(250, 250, 250, 0.9);
  --bluebutton: rgba(0, 153, 255, 0.10);
  --darkbluebutton: rgba(0, 153, 255, 0.35);
  --bluesim: rgba(215, 235, 250, 0.8);
  --focus: #2563eb;
  --danger: rgba(220, 29, 72, 0.6);
  --danger-hover: rgba(190, 18, 60, 0.6);

  
  /* Radius scale (rectangular components) */
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-xl: 14px;
  --radius-2xl: 18px;
  --radius-3xl: 20px;

  /* Semantic radius aliases (use these in components) */
  --radius-btn: 0.75rem;               /* ~12px, for interactive pills/buttons */
  --radius-control: var(--radius-sm);
  --radius-badge: var(--radius-sm);
  --radius-logo: var(--radius-lg);
  --radius-card: var(--radius-xl);
  --radius-tile: var(--radius-2xl);
  --radius-modal: var(--radius-3xl);
  --radius-close: var(--radius-md);

  /* Fully rounded */
  --radius-pill: 9999px;

  --shadow-pill: 0 2px 16px rgba(0,0,0,.06), inset 0 0 0 1px var(--pill-stroke);

  /* overlay spacing: keep top margin and bottom padding in sync */
  --tile-gap: 16px;
  --overlay-gap: 90px;
  --overlay-gap-bottom: 33px;
}

/* --- Reset (minimal) --- */
* { box-sizing: border-box; }
html, body { height: 100%; }
html { color-scheme: light; }
body {
  margin: 0;
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji";
  font-optical-sizing: auto;      /* better rendering with Inter variable */
  font-synthesis-weight: none;    /* avoid faux bold/italic */
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* Reduce iOS top-bounce when possible */
html, body { overscroll-behavior-y: contain; }

/* Lock page scroll while a modal is open */
html.modal-open-root, body.modal-open { overflow: hidden; height: 100%; }

/* Screen-reader-only utility */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* Accessibility */
.skip-link {
  position: absolute; left: -9999px; top: auto;
  width: 1px; height: 1px; overflow: hidden;
}
.skip-link:focus {
  position: fixed; left: 1rem; top: 1rem;
  width: auto; height: auto; padding: .5rem .75rem;
  background: #fff; color: var(--fg);
  border: 1px solid var(--focus); border-radius: var(--radius-control);
  z-index: 10000;
}

/* --- Shared effects / consolidations --- */

/* Common 8px blur surfaces */
.tile-media,
.tile-meta,
.details-card,
.modal-bar,
.details-hero {
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}

/* Shimmering sweep skeletons */
.tile-skeleton,
.details-hero .details-skeleton {
  position: absolute; inset: 0;
  background:
    linear-gradient(90deg,
      rgba(255,255,255,0) 0%,
      rgba(255,255,255,.45) 50%,
      rgba(255,255,255,0) 100%),
    var(--pill);
  background-size: 200% 100%, auto;
  background-repeat: no-repeat, no-repeat;
  animation: shimmer 2.7s linear infinite;
  will-change: background-position, transform;
  transform: translateZ(0);
  backface-visibility: hidden;
}

/* --- Header (rounded solid rectangle / “pill” at top) --- */
.site-header {
  position: fixed;
  top: max(10px, calc(env(safe-area-inset-top) + 12px));
  left: 50%;
  transform: translate3d(-50%, 0, 0);
  -webkit-transform: translate3d(-50%, 0, 0);
  display: inline-block;
  width: auto;
  z-index: 1000;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-pill);
  border: 0;
  background: var(--pill);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  background-clip: padding-box;
  isolation: isolate;
  overflow: hidden;
  contain: paint;
  will-change: transform;
  backface-visibility: hidden;
  max-width: calc(100vw - 10px - env(safe-area-inset-left) - env(safe-area-inset-right));
}

.header-inner {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: .5rem;
  padding-top: .48rem;
  padding-bottom: .48rem;
  padding-left: .56rem;
  padding-right: .67rem;
  line-height: 1;
}

/* brand + logo spacing tuned so the logo appears larger without increasing pill height */
.brand {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: 0 .25rem 0 0; border-radius: var(--radius-btn);
  text-decoration: none; color: var(--fg); white-space: nowrap;
  line-height: 1;
}
.brand:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: var(--radius-btn); }

.logo {
  display: block; border-radius: 50%; background: #ffffff; /* white disc behind the image */
  border: 1px solid rgba(0,0,0,.08);
  inline-size: 2.35rem; block-size: 2.35rem; padding: 1px;
}
.brand-text { font-weight: 700; font-size: 1.05rem; letter-spacing: .2px; line-height: 1; }

.header-right { margin-left: auto; display: inline-flex; align-items: center; gap: .5rem; }
.nav { display: flex; align-items: center; gap: .25rem; list-style: none; margin: 0; padding: 0 .25rem 0 0; }

/* Reactive buttons */
.btn {
  --ring: transparent;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: .92rem;
  padding: .56rem .75rem;
  line-height: 1;
  border-radius: var(--radius-btn); border: 1px solid rgba(0,0,0,.14);
  background: var(--btnhover); color: var(--fg);
  text-decoration: none;
  transition: transform .14s ease, background-color .14s ease, border-color .14s ease, box-shadow .14s ease;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.5);
  will-change: transform;
  backface-visibility: hidden;
}
.btn:hover { transform: translateY(-1px); background: var(--btnhover); }
.btn:active { transform: translateY(0); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--btnhover); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus); }

/* Special resume button: piggybacks on .btn and only overrides what's unique */
.resume-btn {
  position: relative;
  border-top-left-radius: 37em; border-bottom-left-radius: 37em;
  border-top-right-radius: 50em; border-bottom-right-radius: 50em;
  background: var(--darkbluebutton);
}
.resume-btn:hover { transform: translateY(-1px); background: var(--darkbluebutton); }
.resume-btn:active { transform: translateY(0); }
.resume-btn.ghost { background: transparent; }

/* --- Stage & overlay --- */
.stage {
  position: relative;
  width: 100%;
  min-height: 100dvh; /* dynamic viewport for iOS; content layer can grow */
  overflow: visible;
}

/* Full-viewport canvas host (remove bottom seam on iOS and keep full coverage during URL bar collapse) */
#heroCanvas {
  position: fixed;
  left: 0; right: 0; top: 0;
  bottom: -1px;            /* hide sub-pixel seam at the bottom on iOS */
  width: 100vw;
  height: 100vh;           /* baseline */
  display: block;
  pointer-events: none;    /* events handled on window to not block UI */
  background: #fff;
  contain: paint;
}
@supports (height: 100dvh) { #heroCanvas { height: 100dvh; } }
@supports (height: 100lvh) { #heroCanvas { height: 100lvh; } }

/* Center the main content while keeping it near the top under header */
.overlay.copy {
  position: relative; z-index: 10; pointer-events: auto;
  max-width: min(90ch, 84vw);
  margin: var(--overlay-gap) auto 0;
  padding-bottom: var(--overlay-gap-bottom);
  text-align: center;
}
.overlay h2.page-title { font-size: clamp(1.4rem, 2.2vw + 1rem, 2.25rem); margin: 0 0 .75rem 0; }
.overlay p { margin: 0 0 .5rem 0; color: var(--muted); font-size: clamp(.95rem, .5vw + .85rem, 1.05rem); }

/* --- Subcategory buttons (Projects) --- */
.subnav { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: center; margin: .25rem 0 1rem 0; }

/* Backdrop-filter removed to eliminate flicker with fixed blurred header */
.subnav .btn,
.subnav .btn.ghost {
  border: 1px solid var(--pill-stroke);
  contain: paint;
  backface-visibility: hidden;
  background: var(--pillsim);
}
.subnav .btn[aria-current="page"] { background: var(--bluesim); border-color: rgba(0,0,0,.2); }

/* --- Project list (single-column, variable-height tiles) --- */
.project-list {
  display: grid; grid-template-columns: 1fr; gap: var(--tile-gap);
  margin: 0px auto 0;
}
.project-tile {
  display: block; background: var(--lightmodal); border: 1px solid var(--pill-stroke);
  border-radius: var(--radius-tile);
  overflow: hidden; text-decoration: none; color: inherit;
  contain: paint;
}

/* Media container keeps a stable 1270x640 aspect so there is no height jump */
.tile-media {
  position: relative;
  width: 100%;
  aspect-ratio: 1270 / 640;      /* ~2:1 */
  overflow: hidden;
  background: var(--pill);
  border-bottom: 1px solid var(--pill-stroke);
}

/* Fade video in once ready */
.tile-media video {
  position: absolute; inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.9) contrast(1.02);
  backface-visibility: hidden;
  will-change: opacity;
  contain: paint;
  transition: opacity .18s linear;
  opacity: 0;                    /* start hidden; fade in when ready */
}
/* Hide any native controls if a browser shows them */
.tile-media video::-webkit-media-controls { display: none !important; }

/* When ready, reveal video and retire skeleton */
.tile-media.is-ready video { opacity: 1; }
.tile-media.is-ready .tile-skeleton {
  opacity: 0; visibility: hidden; transition: opacity .18s linear, visibility .18s linear;
}

/* tile meta */
.tile-meta {
  padding: .75rem .9rem; border-top: 1px solid var(--pill-stroke);
  background: linear-gradient(to bottom, rgba(255,255,255,.6), rgba(255,255,255,.5));
}
.tile-meta h3 { font-size: 1.05rem; margin: 0 0 .25rem 0; }
.tile-meta p { margin: 0; color: var(--muted); font-size: .95rem; }

/* --- Modal / Popup (translucent style) --- */
.modal {
  position: fixed; inset: 0;
  display: none; align-items: center; justify-content: center;
  background: rgba(0,0,0,.18);
  -webkit-backdrop-filter: blur(1px); backdrop-filter: blur(1px);
  z-index: 2000;
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right))
           max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  overscroll-behavior: contain;
}
.modal.is-open { display: flex; }
.modal-dialog {
  width: min(1200px, calc(100vw - 16px));
  max-width: 96vw;
  max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  height: auto;
  background: var(--modal); border: 1px solid var(--pill-stroke);
  border-radius: var(--radius-modal); 
  display: flex; flex-direction: column; overflow: hidden;
  min-height: 0; /* allow children with overflow to actually scroll */
}
/* Cleaner modal typography */
.modal-body, .details {
  font-size: 1rem;
  line-height: 1.7;
  letter-spacing: .1px;
}
.modal-bar {
  display: flex; align-items: center; gap: .5rem; padding: .6rem .75rem;
  border-bottom: 1px solid var(--pill-stroke);
  background: rgba(255,255,255,.9);
}
.modal-title { font-weight: 700; margin-right: auto; }
.modal-actions .btn { padding: .4rem .6rem; font-size: .9rem; }

/* Show "View Project" only when it has a real link */
.modal-actions [data-project-open]:not([href]),
.modal-actions [data-project-open][href=""] { display: none !important; }

/* RED close buttons */
.modal-close {
  border: 1px solid var(--danger);
  background: var(--danger);
  color: #fff;
  border-radius: var(--radius-close); width: 34px; height: 34px; line-height: 0;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  transition: transform .14s ease, background-color .14s ease, border-color .14s ease, box-shadow .14s ease;
}
.modal-close:hover {
  transform: translateY(-1px);
  background: var(--danger-hover);
  border-color: var(--danger-hover);
  box-shadow: 0 1px 0 rgba(0,0,0,.06), inset 0 0 0 1px rgba(255,255,255,.5);
}
.modal-close:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(225,17,72,.35);
}

/* SCROLLABLE modal body */
.modal-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  -webkit-backdrop-filter: blur(1px);
  backdrop-filter: blur(1px);
}

/* PDF modal: ensure pinch-zoom is honored inside iframe on iOS */
.modal--pdf .modal-body {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  -webkit-overflow-scrolling: auto;
  overscroll-behavior: auto;
  touch-action: auto;
}

.modal--pdf .modal-dialog {
  width: min(1400px, 96vw);
  height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}
@supports (height: 100svh) {
  .modal--pdf .modal-dialog {
    height: calc(100svh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }
}

/* Ensure the iframe fills the dialog's vertical space */
.modal--pdf .pdf-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #fff;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  touch-action: auto;
}

/* Project details content */
.details { padding: 1rem; overflow: auto; height: 100%; text-align: left; }
.details h4 { margin: 1rem 0 .4rem 0; font-size: 1rem; }
.details p { margin: .25rem 0; color: var(--muted); }

/* Head section (no tile chrome) */
.details-head { margin: .25rem 0 .75rem 0; }
.details-head .head-title {
  margin: 0 0 .25rem 0;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: .2px;
  color: var(--fg);
}
.details-head .head-desc { margin: 0; }
.details-head .head-link { margin-top: .1rem; font-weight: 600; }

/* Hero image/video scrub at the top of project details */
.details-hero {
  position: relative;
  width: min(850px, 87%);
  aspect-ratio: 1270 / 640; /* ~2:1 */
  overflow: hidden;
  background: var(--pill);
  border: 1px solid var(--pill-stroke);
  border-radius: var(--radius-card);
  margin: 0.25rem auto 1rem auto;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;
  isolation: isolate;
  contain: paint;
}

.details-hero.is-scrubbing { cursor: grabbing; }
.details-hero.is-disabled { cursor: progress; }

/* Canvas fills the hero area and fades in when ready */
.details-hero .scrub-canvas {
  position: absolute;
  inset: 0;
  display: block;
  pointer-events: none;
  will-change: contents;
  opacity: 0;
  transition: opacity .18s linear;
  z-index: 0;
}

/* When ready, reveal canvas and retire skeleton */
.details-hero.is-ready .scrub-canvas { opacity: 1; }
.details-hero.is-ready .details-skeleton {
  opacity: 0; visibility: hidden; transition: opacity .18s linear, visibility .18s linear;
}

/* Video fills the hero the same way your canvas did */
.details-hero .hero-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Optional: hide the old GIF canvas if it still exists */
.details-hero .scrub-canvas { display: none; }

/* Scrub hint badge */
.scrub-hint {
  position: absolute;
  left: 50%; bottom: 12px;
  transform: translateX(-50%);
  padding: .35rem .6rem;
  font-size: .85rem; font-weight: 600;
  color: var(--fg);
  background: var(--pillsim);
  border: 1px solid var(--pill-stroke);
  border-radius: var(--radius-pill);
  display: inline-flex; align-items: center; gap: .4rem;
  pointer-events: none;
  opacity: .95;
  transition: opacity .25s ease, transform .25s ease, background-color .2s ease, box-shadow .2s ease;
  z-index: 2;
}
.scrub-hint svg { width: 16px; height: 16px; display: block; }
.scrub-hint .scrub-text, .scrub-hint svg { position: relative; z-index: 1; }
.scrub-hint.is-hidden { opacity: 0; transform: translate(-50%, 8px) scale(.98); }

/* ===== Details grid layout ===== */
.details-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 12px;
}

.details-card {
  background: rgba(0, 0, 0, 0.00);
  border: 1px solid var(--pill-stroke);
  border-radius: var(--radius-card);
  padding: 14px 16px;
}

.details-card .card-title {
  margin: 0 0 .35rem 0;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: .2px;
  color: var(--fg);
}

.details-card .card-text {
  margin: 0;
  color: var(--muted);
  font-size: .98rem;
  line-height: 1.65;
}

.details-card.card--wide { grid-column: 1 / -1; }
.details-card.card--compact { padding: 12px 14px; }

/* Role display — cleaner */
.role-line {
  font-size: 1.02rem;
  font-weight: 400;
  margin: .15rem 0 0 0;
}

/* Tag badges (used for constraints & tools) */
.badge {
  display: inline-flex;
  align-items: center; justify-content: center;
  padding: .25rem .55rem;
  border-radius: var(--radius-badge);
  border: 1px solid var(--pill-stroke);
  background: var(--pill);
  font-size: .82rem;
  font-weight: 600;
  color: var(--fg);
  margin: 3px;
}

.tools-tags, .constraint-tags {
  display: flex; flex-wrap: wrap; gap: 6px;
}

/* ===== Glass sections (rounded, translucent) ===== */
.glass-card {
  position: relative;
  border-radius: var(--radius-card);
  border: 1px solid var(--pill-stroke);
  background: var(--lightmodal);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  padding: 16px 18px;
  margin-top: var(--tile-gap);
  isolation: isolate;
  contain: paint;
}

/* Section title inside glass cards */
.glass-title {
  margin: .25rem 0 .5rem 0;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: .2px;
  color: var(--fg);
}

/* About page story block */
.about-story p {
  margin: .65rem 0;
  color: var(--muted);
  font-size: clamp(.98rem, .5vw + .9rem, 1.05rem);
  line-height: 1.75;
  text-align: left;
}

/* Experience container */
.about-experience .exp-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 8px 0 0 0;
  padding: 0;
  list-style: none;
  text-align: left;
}

/* Each experience row: 2-column grid (logo/time on the left, content on the right) */
.exp-item {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 14px;
  align-items: start;
  padding: 12px 0;
  border-top: 1px solid var(--pill-stroke);
}
.exp-item:first-child { border-top: 0; padding-top: 0; }

.exp-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 72px;
}

.exp-logo {
  width: 60px; height: 60px;
  display: block;
  object-fit: contain;
  border-radius: var(--radius-logo);
  background: #fff;
  border: 1px solid rgba(0,0,0,.08);
  box-shadow: 0 1px 0 rgba(0,0,0,.04);
}

.exp-time {
  font-size: .9rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.2;
}

/* Right column (content) */
.exp-body .exp-header {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}

/* “Reactive” title button linking to company website (reuses .btn) */
.exp-title { background: var(--bluebutton); }
.exp-title.btn { padding: .45rem .65rem; font-size: .92rem; }
.exp-title svg { width: 16px; height: 16px; display: block; }
.exp-title.btn:hover,
.exp-title.btn:active,
.exp-title.btn:focus-visible { background: var(--bluebutton); }

/* Description */
.exp-desc {
  margin: .4rem 0 .5rem 0;
  color: var(--muted);
  font-size: .98rem;
  line-height: 1.65;
}

/* Tools (pill badges reusing .badge) */
.exp-tools {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px;
}
.exp-tools .badge { margin: 0; }

/* Shimmer animation — animate the 1st background layer (sweep), keep base fixed */
@keyframes shimmer {
  0%   { background-position: 200% 0, 0 0; }
  100% { background-position: -200% 0, 0 0; }
}

/* --- Small screens --- */
@media (max-width: 640px) {
  :root { --radius-logo: var(--radius-md); } /* tighter logos on small screens */

  .glass-card { padding: 14px 14px; }
  .exp-item { grid-template-columns: 56px 1fr; gap: 12px; }
  .exp-logo { width: 52px; height: 52px; }

  .brand-text { display: none; }
  .modal-dialog { width: 96vw; }
  .details-grid { grid-template-columns: 1fr; }
}

/* Extra-tight phones */
@media (max-width: 420px) {
  .header-inner { gap: .4rem; }
  .btn { padding: .45rem .6rem; font-size: .9rem; }
  .resume-btn { padding: .45rem .45rem; }
}