/* Website UI, following the approved concept: a light, clean web shell (cream page, white header
   and cards, dark readable type) around a rich pixel-art hero scene. Pixel character comes from the
   scene, the wooden signposts and a few small accents; the UI itself stays simple. */
:root {
  --bg: #faf6ef;            /* cream page */
  --card: #ffffff;
  --ink: #1f1a2e;
  --muted: #5d5770;
  --line: #e9e1d5;          /* hairline borders */
  --accent: #c8642c;        /* warm sunset orange */
  --plum: #4a2f63;
  --focus: #2e64e8;
  --paper: #ffffff;         /* (used by scene.css for the focus ring gap) */
  --radius: 12px;
  --shadow: 0 1px 2px rgba(31, 26, 46, 0.06), 0 8px 24px rgba(31, 26, 46, 0.08);
  --shadow-hover: 0 2px 4px rgba(31, 26, 46, 0.08), 0 16px 36px rgba(31, 26, 46, 0.14);
  --pixel: "Jersey 10", sans-serif;     /* small pixel accents and the scene's signs */
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --gutter: clamp(16px, 4vw, 40px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }
html.has-overlay { overflow: hidden; }

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

a { color: var(--accent); }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.2; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 6px;
}

.wrap {
  width: 100%;
  max-width: 1280px;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* A little pixel-art sprout, used beside big headings (decoration only) */
.sprout {
  display: inline-block;
  width: 0.62em;
  height: 0.62em;
  margin-left: 0.18em;
  vertical-align: 0.04em;
  background: url("../assets/ui/sprout.svg") center / contain no-repeat;
  image-rendering: pixelated;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  padding: 10px 14px;
  background: var(--ink);
  color: #fff;
  border-radius: 8px;
}
.skip-link:focus { top: 12px; }

.loading { padding-block: 40px; color: var(--muted); }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
}
.brand {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  color: var(--ink);
  text-decoration: none;
}
.brand-name { font-weight: 800; font-size: 19px; letter-spacing: -0.01em; }
.brand-role { font-size: 14px; color: var(--muted); }
.site-nav ul { display: flex; gap: 4px; margin: 0; padding: 0; list-style: none; }
.site-nav a {
  display: block;
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.site-nav a:hover { background: #f3ece2; }
.site-nav a[aria-current="page"] { background: var(--ink); color: #fff; }

/* ---------- Hero: the scene, with the intro over its sky ---------- */
.hero { position: relative; }
.intro { padding-block: clamp(26px, 4vw, 44px) 20px; }
.intro h1 { margin: 0; font-size: clamp(34px, 4.6vw, 58px); font-weight: 800; letter-spacing: -0.025em; }
.intro-text { margin: 10px 0 0; max-width: 38ch; font-size: clamp(17px, 1.6vw, 20px); color: var(--muted); }
.intro-hint { margin: 14px 0 0; font: 400 22px/1 var(--pixel); letter-spacing: 0.02em; color: var(--plum); }
.intro-hint::before { content: "▶ "; color: var(--accent); }
.hint-touch { display: none; }

/* Wide screens: the intro sits over the top-left of the scene, like the concept. A soft cream
   wash behind it keeps the text readable whatever the artwork looks like. */
@media (min-width: 1100px) {
  .hero .intro {
    position: absolute;
    inset: 0 0 auto 0;
    z-index: 3;
    pointer-events: none; /* clicks pass through to the scene */
  }
  .hero::before {
    content: "";
    position: absolute;
    z-index: 2;
    left: 0;
    top: 0;
    width: min(62%, 900px);
    height: min(52%, 360px);
    pointer-events: none;
    background: radial-gradient(ellipse at 18% 30%, rgba(250, 246, 239, 0.95) 0%, rgba(250, 246, 239, 0.82) 48%, rgba(250, 246, 239, 0) 74%);
  }
  .hero .intro h1 { text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6); }
}

/* ---------- Section links (phones / small tablets) ---------- */
.section-links {
  display: none;
  grid-template-columns: repeat(2, minmax(0, 1fr)); /* never wider than the screen */
  gap: 12px;
  margin-top: 16px;
}
.section-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 72px;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--ink);
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.section-link img { width: 44px; height: 44px; object-fit: contain; image-rendering: pixelated; flex: none; }
.section-link-text { display: flex; flex-direction: column; min-width: 0; }
.section-link-title { font-weight: 700; font-size: 16px; }
.section-link-desc { font-size: 13px; color: var(--muted); line-height: 1.35; }
/* Section cards share the scene's highlight: hovered, tapped, focused or currently open */
.section-link:hover,
.section-link[aria-current="true"] { border-color: var(--accent); box-shadow: var(--shadow-hover); }
.section-link:active { transform: translateY(1px); }

/* ---------- Cards ---------- */
.featured { padding-block: clamp(32px, 4.5vw, 52px) clamp(48px, 7vw, 80px); }
.featured h2 { margin: 0 0 20px; font-size: clamp(26px, 3vw, 32px); font-weight: 800; letter-spacing: -0.02em; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 22px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.card-item { display: flex; }
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.card-thumb { display: block; aspect-ratio: 16 / 9; overflow: hidden; background: #efe7dc; } /* overflow stops tall images stretching the frame */
.card-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.card-body { display: flex; flex-direction: column; gap: 6px; flex: 1; padding: 14px 16px 16px; }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.card-title { font-weight: 700; font-size: 18px; line-height: 1.3; }
.card-desc { font-size: 15px; color: var(--muted); line-height: 1.45; }
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 0; padding: 0; list-style: none; }
.card-arrow {
  align-self: flex-end;
  margin-top: auto;
  padding-top: 6px;
  font-size: 20px;
  line-height: 1;
  color: var(--ink);
  transition: transform 0.15s;
}
.card:hover .card-arrow { transform: translateX(3px); }

/* Game cards: the JamesCube case shown on a dusky backdrop */
.card-thumb-case {
  display: grid;
  place-items: center;
  padding: 14px;
  background: radial-gradient(ellipse at 50% 115%, rgba(244, 155, 98, 0.35), transparent 60%), linear-gradient(180deg, #2b1f45, #4a2f63);
}
.card-thumb-case .game-case { height: 100%; width: auto; }
/* In the JamesCube list the cards lie on their side: case on the left, details on the right */
.card-grid-game { grid-template-columns: 1fr; gap: 16px; }
.card-grid-game .card { flex-direction: row; }
.card-grid-game .card-thumb-case { flex: none; width: 34%; max-width: 190px; aspect-ratio: auto; background: none; padding: 14px 0 14px 14px; }
.card-grid-game .card-thumb-case .game-case { width: 100%; height: auto; }

.chip {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: #f1e9de;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.chip-status { background: #ece4ff; color: #4b2fc4; }
/* Topic tags: soft pastel pills, colours cycling */
.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #e8f0ff;
  color: #2f5fd0;
}
.tag:nth-child(3n + 2) { background: #e4f4ea; color: #24774a; }
.tag:nth-child(3n + 3) { background: #efe8ff; color: #6a46cf; }
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.chip-list .chip { font-size: 14px; padding: 4px 12px; }

/* "Replace me" placeholders are flagged so they're easy to spot and fill in */
.todo {
  display: inline-block;
  padding: 0 8px;
  border: 1.5px dashed var(--accent);
  border-radius: 6px;
  background: #fff1e8;
  color: #a8471c;
  font-size: 0.85em;
  font-weight: 700;
}

/* ---------- JamesCube game case ---------- */
.game-case {
  --case-w: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  width: var(--case-w);
  aspect-ratio: 5 / 7;
  border-radius: 5px 3px 3px 5px;
  background: #1b1a22;
  padding-left: 7%;
  container-type: inline-size; /* lets the cover text scale with the case */
  box-shadow: inset 0 0 0 2px #0e0d12, 0 8px 18px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}
/* spine */
.game-case::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 7%;
  background: repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0 2px, transparent 2px 6px), #111016;
}
/* clear plastic sleeve shine */
.game-case::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(115deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.04) 24%, transparent 25%, transparent 62%, rgba(255, 255, 255, 0.06) 63%, transparent 76%);
}
.case-banner {
  display: block;
  height: 15%;
  padding: 0 5%;
  background: linear-gradient(180deg, #7457ff, #4527c4);
}
.case-banner-art { display: block; width: 100%; height: 100%; }
.case-cover {
  position: relative;
  flex: 1;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 30% 25%, hsl(var(--h) 85% 64%), transparent 70%),
    linear-gradient(140deg, hsl(var(--h) 60% 42%), hsl(calc(var(--h) + 50) 65% 24%));
}
.case-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.case-placeholder {
  padding: 8%;
  color: #fff;
  font: 400 15cqw / 1.05 var(--pixel);
  letter-spacing: 0.03em;
  overflow-wrap: break-word;
  text-align: center;
  text-shadow: 2px 2px 0 #0b0718; /* solid pixel shadow; a see-through one looks like a ghosted copy */
}

/* ---------- Buttons ---------- */
.button,
.overlay-close {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 18px;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font: 700 15px/1.2 var(--font);
  text-decoration: none;
  cursor: pointer;
}
.button:hover,
.overlay-close:hover { background: #f3ece2; }
.button.primary { background: var(--ink); color: #fff; }
.button.primary:hover { background: #3a3150; }

/* ---------- Overlay (category list, About Me, project details) ---------- */
.overlay {
  width: 100%;
  max-width: min(760px, 100vw);
  height: 100%;
  max-height: 100vh;
  max-height: 100dvh;
  margin: 0 0 0 auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
}
.overlay::backdrop { background: rgba(31, 26, 46, 0.45); }
.overlay[open] .overlay-panel { animation: slideIn 0.28s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes slideIn { from { transform: translateX(40px); } } /* movement only: the panel stays fully solid */
.overlay-panel {
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--bg);
  box-shadow: -8px 0 32px rgba(31, 26, 46, 0.2);
}
.overlay-bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 60px;
  padding: 8px var(--gutter);
  background: rgba(250, 246, 239, 0.95);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.overlay-back { font-weight: 700; text-decoration: none; color: var(--ink); padding: 8px 4px; }
.overlay-back:hover { text-decoration: underline; }
.overlay-close { margin-left: auto; }
.overlay-body { padding: 24px var(--gutter) 56px; }
.overlay-head { margin-bottom: 22px; }
.overlay-head h2,
.detail-head h2 { margin: 0; font-size: clamp(28px, 4vw, 38px); font-weight: 800; letter-spacing: -0.02em; }
.overlay-head p { margin: 6px 0 0; color: var(--muted); }
.overlay h2:focus { outline: none; }
.empty { color: var(--muted); }

/* Project detail */
.detail-hero { margin: 0 0 22px; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 9; background: #efe7dc; }
.detail-hero img { display: block; width: 100%; height: 100%; object-fit: cover; }
.detail-hero-game {
  display: grid;
  place-items: center;
  padding: 24px;
  aspect-ratio: auto;
  background: radial-gradient(ellipse at 50% 120%, rgba(244, 155, 98, 0.3), transparent 60%), linear-gradient(180deg, #2b1f45, #4a2f63);
}
.detail-hero-game .game-case { width: min(220px, 52%); }
.detail-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; }
.detail-summary { margin: 8px 0 0; font-size: 18px; color: var(--muted); }
.detail-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 0; }
.detail-section { margin-top: 28px; }
.detail-section h3 { margin: 0 0 8px; font-size: 19px; }
.detail-section p { margin: 0 0 12px; }
.detail-list { margin: 0; padding-left: 22px; }
.detail-list li { margin-bottom: 6px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
.gallery img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 10px; }
.video { aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: #000; }
.video iframe { width: 100%; height: 100%; border: 0; }
.about p { margin: 0 0 12px; font-size: 18px; }
.about-image { float: right; width: 160px; margin: 0 0 12px 16px; border-radius: var(--radius); }

.load-error { padding-block: 60px; }

/* ---------- Play page ---------- */
body.play-page { background: #1f1a2e; color: #fff; }
.play-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: 8px var(--gutter);
  background: #fff;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}
.play-bar h1 { flex: 1; margin: 0; font-size: 18px; text-align: center; }
.play-stage { padding: 20px var(--gutter); }
.play-stage iframe {
  display: block;
  width: 100%;
  max-width: 1100px;
  height: min(78vh, 760px);
  margin: 0 auto;
  border: 0;
  border-radius: var(--radius);
  background: #000;
}
.play-info { max-width: 1100px; margin: 16px auto 0; color: #e8e2f0; white-space: pre-line; }
.play-exit { display: none; }

/* Immersive play: the game fills the whole window (the fallback for
   browsers that can't put an iframe in fullscreen, such as iPhone Safari). */
body.play-immersive { overflow: hidden; }
body.play-immersive .play-bar,
body.play-immersive .play-info { display: none; }
body.play-immersive .play-stage { padding: 0; }
body.play-immersive .play-stage iframe {
  position: fixed;
  inset: 0;
  z-index: 10;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  border-radius: 0;
}
body.play-immersive .play-exit {
  display: block;
  position: fixed;
  top: max(8px, env(safe-area-inset-top));
  right: max(8px, env(safe-area-inset-right));
  z-index: 11;
  padding: 6px 10px;
  font-size: 14px;
  opacity: 0.75;
}

/* Phones and tablets: give the game the screen, edge to edge. */
@media (pointer: coarse) {
  .play-stage { padding: 0; }
  .play-stage iframe {
    max-width: none;
    height: calc(100vh - 60px);
    height: calc(100dvh - 60px);
    border-radius: 0;
  }
  .play-info { padding: 0 var(--gutter); }
}

/* ---------- Small screens ---------- */
@media (max-width: 760px) {
  body { font-size: 16px; }
  .header-inner { flex-direction: column; align-items: stretch; gap: 4px; padding-block: 10px 6px; min-height: 0; }
  .site-nav { overflow-x: auto; scrollbar-width: none; margin-inline: calc(var(--gutter) * -1); padding-inline: var(--gutter); }
  .site-nav::-webkit-scrollbar { display: none; }
  .site-nav ul { justify-content: space-between; }
  .site-nav a { padding: 6px 7px; font-size: 13px; }
  .section-link-desc { display: none; }
  .section-links { display: grid; }
  .hint-pointer { display: none; }
  .hint-touch { display: inline; }
  .overlay { max-width: 100vw; }
  .overlay[open] .overlay-panel { animation-name: slideUp; }
  @keyframes slideUp { from { transform: translateY(40px); } }
  .card-grid-game .card-thumb-case { width: 38%; }
  .about-image { float: none; display: block; margin: 0 0 12px; }
}
@media (hover: none) and (min-width: 761px) {
  .hint-pointer { display: none; }
  .hint-touch { display: inline; }
}
/* The narrowest phones (≤ 360px): keep all five nav items on screen */
@media (max-width: 360px) {
  .site-nav a { padding: 6px 4px; font-size: 11.5px; }
  .section-link { gap: 6px; padding: 8px; }
  .section-link img { width: 36px; height: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Text for screen readers only */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
