/* Layout: one left-aligned column (max 1040px), a full-bleed 3D tile field behind the hero,
   3D-tilting cards for the photo and section links, CSS-built 3D books on the reading page. */
:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #e9edf2;
  --fg: #121820;
  --muted: #5b6676;
  --line: #d9e0e8;
  --accent: #0e8a84;
  --accent-ink: #0b6f6a;
  --warm: #f0a63a;
  --tile-a: #0e8a84;
  --tile-b: #f0a63a;
  --tile-c: #dfe6ee;
  --shadow: 0 30px 60px -30px rgba(18, 24, 32, 0.35);
  --display: "Bricolage Grotesque", "Helvetica Neue", Arial, sans-serif;
  --body: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --max: 1040px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1218; --surface: #161d26; --surface-2: #1d2631; --fg: #e9eef3; --muted: #98a5b4;
    --line: #253040; --accent: #2cc1b8; --accent-ink: #6fe0d8; --warm: #f4b65a;
    --tile-a: #2cc1b8; --tile-b: #f4b65a; --tile-c: #2a3545;
    --shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.8);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1218; --surface: #161d26; --surface-2: #1d2631; --fg: #e9eef3; --muted: #98a5b4;
  --line: #253040; --accent: #2cc1b8; --accent-ink: #6fe0d8; --warm: #f4b65a;
  --tile-a: #2cc1b8; --tile-b: #f4b65a; --tile-c: #2a3545;
  --shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.8);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 17px/1.6 var(--body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.wrap {
  max-width: var(--max); margin: 0 auto;
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
}
h1, h2, h3 { font-family: var(--display); text-wrap: balance; letter-spacing: -0.02em; }
.label { font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

/* ---------- header / footer ---------- */
.site-header { position: relative; z-index: 2; }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 72px; gap: 16px; }
.brand { font-family: var(--display); font-weight: 700; font-size: 19px; text-decoration: none; white-space: nowrap; letter-spacing: -0.01em; }
.brand span { color: var(--accent); }
.nav { display: flex; gap: 6px; }
.nav a { text-decoration: none; color: var(--muted); font-size: 15px; font-weight: 500; padding: 6px 12px; border-radius: 999px; }
.nav a:hover { color: var(--fg); background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--fg); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }

.site-footer { border-top: 1px solid var(--line); margin-top: 110px; padding-block: 36px 44px; color: var(--muted); font-size: 14px; }
.site-footer .wrap { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 16px; }
.footer-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 26px; font-size: 16px; font-weight: 500; }
.footer-links a { color: var(--fg); text-decoration: none; border-bottom: 1px solid var(--line); padding-bottom: 2px; }
.footer-links a:hover { border-color: var(--accent); color: var(--accent-ink); }
.empty { border: 1px dashed var(--line); border-radius: 22px; padding: 40px; text-align: center; color: var(--muted); margin-top: 24px; }
.empty p { margin: 8px 0 0; font-size: 18px; }
.book-meta h3 a { text-decoration: none; }
.book-meta h3 a:hover { color: var(--accent-ink); }
a.book-scene { text-decoration: none; }

/* ---------- hero (home) ---------- */
.hero { position: relative; min-height: 520px; display: grid; align-items: center; padding-block: 56px 72px; }
.hero-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
.hero .wrap { position: relative; z-index: 1; display: grid; grid-template-columns: 1.25fr 0.75fr; gap: 48px; align-items: center; }
.hero h1 { font-weight: 800; font-size: clamp(42px, 7.2vw, 84px); line-height: 0.98; margin: 14px 0 20px; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero .intro { font-size: clamp(18px, 2vw, 21px); color: var(--muted); max-width: 48ch; margin: 0 0 22px; }
.hero .now { display: inline-flex; align-items: center; gap: 10px; font-size: 15px; padding: 8px 14px 8px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }
.hero .now i { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
.links { display: flex; gap: 16px; margin-top: 26px; flex-wrap: wrap; }
.links a { font-size: 15px; font-weight: 500; color: var(--muted); text-decoration: none; border-bottom: 1px solid var(--line); padding-bottom: 2px; }
.links a:hover { color: var(--fg); border-color: var(--fg); }

/* 3D photo card */
.photo-scene { perspective: 1200px; justify-self: center; }
.photo-card {
  width: min(300px, 70vw); aspect-ratio: 4 / 5; border-radius: 26px; position: relative;
  transform-style: preserve-3d; transition: transform .25s ease-out; will-change: transform;
  box-shadow: var(--shadow);
}
.photo-card .face { position: absolute; inset: 0; border-radius: inherit; overflow: hidden; background: var(--surface); border: 1px solid var(--line); }
.photo-card img { width: 100%; height: 100%; object-fit: cover; }
.photo-card .initials { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--display); font-weight: 800; font-size: 96px; color: var(--accent); background: linear-gradient(145deg, var(--surface), var(--surface-2)); }
.photo-card .shine { position: absolute; inset: 0; border-radius: inherit; background: radial-gradient(circle at var(--mx, 30%) var(--my, 20%), rgba(255,255,255,.35), transparent 55%); mix-blend-mode: soft-light; pointer-events: none; }
.photo-card .tag {
  position: absolute; left: -18px; bottom: 28px; transform: translateZ(50px);
  background: var(--fg); color: var(--bg); font-family: var(--mono); font-size: 12px; letter-spacing: .06em; padding: 8px 12px; border-radius: 10px;
}
.photo-card .tag.two { left: auto; right: -14px; top: 26px; bottom: auto; background: var(--warm); color: #1a1408; }

/* section link cards */
.section-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; perspective: 1400px; }
.tilt { transform-style: preserve-3d; transition: transform .25s ease-out, box-shadow .25s; will-change: transform; }
.tilt:hover { box-shadow: var(--shadow); }
.card {
  display: flex; flex-direction: column; gap: 10px; min-height: 210px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 24px; text-decoration: none;
}
.card .label { transform: translateZ(20px); }
.card h3 { margin: 0; font-size: 30px; font-weight: 700; transform: translateZ(40px); }
.card p { margin: 0; color: var(--muted); font-size: 15px; transform: translateZ(26px); }
.card .arrow { margin-top: auto; align-self: flex-end; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--fg); transform: translateZ(50px); transition: background .2s, color .2s; }
.card:hover .arrow { background: var(--accent); color: #fff; }

/* ---------- generic page ---------- */
.page-head { padding-block: 40px 28px; }
.page-head h1 { font-weight: 800; font-size: clamp(38px, 6vw, 68px); line-height: 1; margin: 10px 0 14px; }
.page-head p { color: var(--muted); font-size: 18px; max-width: 56ch; margin: 0; }
.section-title { font-size: 28px; font-weight: 700; margin: 0 0 20px; }

/* ---------- books ---------- */
.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 34px 28px; margin-top: 24px; }
.book-row { display: grid; grid-template-columns: 120px 1fr; gap: 22px; align-items: center; }
.book-scene { perspective: 900px; height: 170px; display: grid; place-items: center; }
.book {
  --w: 110px; --h: 160px; --d: 26px;
  width: var(--w); height: var(--h); position: relative; transform-style: preserve-3d;
  transform: rotateY(-28deg) rotateX(4deg); transition: transform .45s cubic-bezier(.2,.8,.2,1);
}
.book-row:hover .book { transform: rotateY(-10deg) rotateX(2deg) translateY(-4px); }
.book > div { position: absolute; }
.book .cover {
  inset: 0; border-radius: 3px 8px 8px 3px; background: var(--c, #345); color: var(--ct, #fff);
  transform: translateZ(calc(var(--d) / 2));
  padding: 14px 12px 12px 16px; display: flex; flex-direction: column; justify-content: space-between;
  box-shadow: inset 6px 0 10px -8px rgba(0,0,0,.6), 10px 14px 30px -14px rgba(0,0,0,.55);
  font-family: var(--display);
}
.book .cover b { font-size: 13px; line-height: 1.15; font-weight: 700; letter-spacing: -0.01em; }
.book .cover small { font-size: 10px; opacity: .8; font-family: var(--mono); }
.book .cover::before { content: ""; position: absolute; left: 8px; top: 0; bottom: 0; width: 1px; background: currentColor; opacity: .25; }
.book .back { inset: 0; border-radius: 3px 8px 8px 3px; background: var(--c, #345); filter: brightness(.7); transform: translateZ(calc(var(--d) / -2)); }
.book .spine { width: var(--d); height: var(--h); left: 0; top: 0; background: var(--c, #345); filter: brightness(.85); transform: rotateY(-90deg) translateZ(calc(var(--d) / 2)); border-radius: 3px 0 0 3px; }
.book .pages { width: calc(var(--d) - 4px); height: calc(var(--h) - 8px); left: 0; top: 4px; transform-origin: left center; background: repeating-linear-gradient(90deg, #f6f1e6 0 2px, #d9d2c3 2px 3px); transform: translateX(calc(var(--w) - 1px)) translateZ(calc(var(--d) / 2 - 2px)) rotateY(90deg); }
.book-meta h3 { margin: 0 0 2px; font-size: 20px; font-weight: 700; }
.book-meta .by { color: var(--muted); font-size: 15px; margin: 0 0 8px; }
.book-meta .note { margin: 0; font-size: 15px; }
.book-meta .read-year { margin-top: 10px; display: inline-block; font-size: 11px; padding: 3px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }

.book-tools { display: grid; gap: 14px; margin-top: 14px; padding: 18px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; }
.book-tools .search { display: grid; gap: 6px; }
.book-tools input[type="search"] { font: 16px var(--body); color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; width: 100%; -webkit-appearance: none; }
.book-tools input[type="search"]:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.chip-group { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.chip-group .label { margin-right: 4px; }
.chip { font: 500 13px var(--body); padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); cursor: pointer; }
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.reading-now { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin-top: 4px; padding: 12px 18px; border-radius: 14px;
  background: color-mix(in srgb, var(--warm) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warm) 45%, var(--line)); box-shadow: 0 10px 30px -22px rgba(0,0,0,.4); }
.reading-now .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--warm); box-shadow: 0 0 0 4px color-mix(in srgb, var(--warm) 25%, transparent); animation: pulse 2.4s ease-in-out infinite; }
.reading-now .label { color: var(--fg); opacity: .75; }
.reading-now .item { display: inline-flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.reading-now .item + .item::before { content: "·"; color: var(--muted); margin-right: 4px; }
.reading-now b { font-family: var(--display); font-weight: 700; font-size: 17px; }
.reading-now b a { text-decoration: none; }
.reading-now b a:hover { color: var(--accent-ink); }
.reading-now .muted { color: var(--muted); font-size: 15px; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--warm) 25%, transparent); } 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--warm) 10%, transparent); } }
@media (prefers-reduced-motion: reduce) { .reading-now .dot { animation: none; } }
.book-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.book-tags .read-year { margin-top: 0; }
.book-row[hidden] { display: none; }

/* ---------- games ---------- */
.game-list { display: grid; gap: 22px; margin-top: 24px; perspective: 1400px; }
.game-row { display: grid; grid-template-columns: 180px 1fr; gap: 28px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 26px; padding: 22px; text-decoration: none; }
.game-art { aspect-ratio: 1; border-radius: 22px; display: grid; place-items: center; font-size: 72px; background: linear-gradient(135deg, var(--a), var(--b)); background: linear-gradient(in oklab 135deg, var(--a), var(--b)); transform: translateZ(30px); overflow: hidden; }
.game-art img { width: 100%; height: 100%; object-fit: cover; }
.game-row h3 { margin: 6px 0 6px; font-size: 32px; font-weight: 700; }
.game-row p { margin: 0; color: var(--muted); }
.pill { display: inline-block; font-family: var(--mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; padding: 5px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.pill.live { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent-ink); }

/* game detail */
.game-hero { position: relative; overflow: hidden; border-radius: 30px; margin-top: 24px; padding: 48px; color: #fff; background: linear-gradient(135deg, var(--a), var(--b)); background: linear-gradient(in oklab 135deg, var(--a), var(--b)); display: flex; gap: 28px; align-items: center; flex-wrap: wrap; }
.game-hero .icon { width: 120px; height: 120px; border-radius: 28px; background: rgba(255,255,255,.22); border: 1px solid rgba(255,255,255,.4); display: grid; place-items: center; font-size: 60px; overflow: hidden; flex: none; }
.game-hero .icon img { width: 100%; height: 100%; object-fit: cover; }
.game-hero h1 { font-weight: 800; font-size: clamp(36px, 6vw, 64px); line-height: 1; margin: 8px 0 8px; }
.game-hero p { margin: 0; font-size: 19px; opacity: .92; max-width: 44ch; }
.game-hero .pill { background: rgba(255,255,255,.22); color: #fff; }
.game-body { display: grid; grid-template-columns: 1.3fr 1fr; gap: 48px; padding-top: 44px; }
.game-body p { font-size: 18px; color: var(--muted); margin-top: 0; }
.btn { display: inline-flex; align-items: center; gap: 10px; padding: 12px 20px; border-radius: 14px; background: var(--fg); color: var(--bg); text-decoration: none; font-weight: 600; font-size: 15px; }
.btn.ghost { background: transparent; color: var(--fg); border: 1px solid var(--line); }
.btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }
.features { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.features li { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; font-size: 16px; }
.features li::before { content: ""; flex: none; width: 10px; height: 10px; margin-top: 8px; border-radius: 3px; background: var(--a, var(--accent)); transform: rotate(45deg); }

/* ---------- projects ---------- */
.projects { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; margin-top: 24px; perspective: 1400px; }
.project { display: flex; flex-direction: column; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 24px; text-decoration: none; }
.project .top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.project h3 { margin: 0; font-size: 24px; font-weight: 700; transform: translateZ(30px); }
.project p { margin: 0; color: var(--muted); font-size: 15px; flex: 1; }
.stack { display: flex; flex-wrap: wrap; gap: 6px; }
.stack span { font-family: var(--mono); font-size: 11px; padding: 4px 8px; border-radius: 6px; background: var(--surface-2); color: var(--muted); }

.example-tag { font-family: var(--mono); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--warm); border: 1px dashed var(--warm); padding: 2px 6px; border-radius: 6px; }

/* ---------- legal ---------- */
.legal { max-width: 760px; padding-top: 48px; }
.legal .crumbs { font-size: 14px; color: var(--muted); margin-bottom: 18px; }
.legal h1 { font-weight: 800; font-size: clamp(32px, 5vw, 48px); line-height: 1.05; margin: 0 0 8px; }
.legal .meta { color: var(--muted); font-size: 15px; margin: 0 0 32px; }
.legal h2 { font-size: 22px; font-weight: 700; margin: 40px 0 10px; }
.legal ul { padding-left: 22px; }
.legal li { margin-bottom: 6px; }
.legal .summary { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 14px; padding: 18px 22px; }
.legal .summary p { margin: 0 0 6px; }
.legal .summary ul { margin: 6px 0 0; }
.legal .caps { text-transform: uppercase; font-size: 14px; letter-spacing: .02em; }

.notfound { text-align: center; padding-block: 120px 40px; }
.notfound h1 { font-size: 72px; margin: 0; }

@media (prefers-reduced-motion: reduce) {
  .tilt, .photo-card, .book { transition: none !important; transform: none !important; }
}
@media (max-width: 820px) {
  .hero .wrap { grid-template-columns: 1fr; gap: 36px; }
  .photo-scene { justify-self: start; }
  .section-cards { grid-template-columns: 1fr; }
  .game-body { grid-template-columns: 1fr; gap: 30px; }
  .game-row { grid-template-columns: 110px 1fr; gap: 18px; padding: 16px; }
  .game-art { font-size: 44px; border-radius: 16px; }
  .game-row h3 { font-size: 24px; }
  .game-hero { padding: 30px 24px; }
  .nav a { padding: 6px 9px; font-size: 14px; }
}
