/* portfolio.neilb.app — Grove 3D flip-book (busqueneil.com design language)
   Warm ivory paper, deep forest ink, emerald→teal accents, one amber sun.
   Fraunces display + Inter body + JetBrains Mono labels + Caveat notes. */

:root {
  --paper:   #FAF8F2;
  --paper-2: #F3F0E7;
  --card:    #FFFFFF;
  --line:    rgba(22, 40, 28, 0.12);
  --line-2:  rgba(22, 40, 28, 0.22);
  --ink:     #16281C;
  --muted:   #5C6E60;
  --dim:     #8A9B8D;
  --leaf:    #1F9D55;
  --teal:    #0E8C7F;
  --sun:     #E89B2D;
  --glow:    rgba(31, 157, 85, 0.24);
  --forest:  #14231A;
  --forest-2:#0F1A13;
  --grad: linear-gradient(100deg, var(--leaf), var(--teal));
  --ph: min(80vh, 40rem);
  --pw: calc(var(--ph) * 0.75);
  --radius: 12px;
  --display: "Fraunces", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --hand: "Caveat", cursive;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: var(--sans);
  background:
    radial-gradient(1000px 600px at 90% -180px, rgba(31, 157, 85, 0.08), transparent 62%),
    radial-gradient(800px 520px at -120px 24%, rgba(14, 140, 127, 0.06), transparent 60%),
    var(--paper);
  color: var(--ink);
  overflow: hidden;
  touch-action: manipulation;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--leaf); color: #fff; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}

/* ---------- background: meadow glows + paper grain ---------- */

.mesh { position: fixed; inset: 0; z-index: 0; overflow: hidden; }

.blob {
  position: absolute;
  width: 55vmax; height: 55vmax;
  border-radius: 50%;
  filter: blur(100px);
  will-change: transform;
}
.blob-a { background: rgba(31, 157, 85, .13); top: -22vmax; right: -12vmax; }
.blob-b { background: rgba(14, 140, 127, .11); bottom: -24vmax; left: -14vmax; }
.blob-c { background: rgba(232, 155, 45, .09); bottom: -18vmax; right: 10vmax; }
.blob-d { background: rgba(31, 157, 85, .07); top: -14vmax; left: 8vmax; }

.grain {
  position: absolute; inset: 0; opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- HUD ---------- */

.hud { position: fixed; left: 0; right: 0; z-index: 40; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.hud-top { top: 0; padding: 1.1rem 1.4rem; justify-content: flex-start; }
.hud-bottom { bottom: 0; padding: 1rem 1.4rem 1.3rem; gap: 1rem; }
.hud a, .hud button { pointer-events: auto; }

.wordmark {
  font-family: var(--mono); font-size: .8rem; font-weight: 500;
  color: var(--ink); text-decoration: none; letter-spacing: .02em;
  display: inline-flex; align-items: center; gap: .55rem;
  padding: .55rem .95rem; border-radius: 999px;
  background: rgba(255, 255, 255, .65); backdrop-filter: blur(8px);
  border: 1px solid var(--line-2);
}
.wordmark:hover { border-color: var(--leaf); background: #fff; }
.wm-dot {
  width: .55rem; height: .55rem; border-radius: 50%; background: var(--sun);
  box-shadow: 0 0 0 0 rgba(232, 155, 45, .5);
  animation: pulse 2.4s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(232, 155, 45, .45); }
  70% { box-shadow: 0 0 0 6px rgba(232, 155, 45, 0); }
  100% { box-shadow: 0 0 0 0 rgba(232, 155, 45, 0); }
}
.wm-dim { color: var(--dim); }

.hint {
  font-family: var(--mono); font-size: .76rem; color: var(--muted);
  background: rgba(255, 255, 255, .65); backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  padding: .55rem 1rem; border-radius: 999px;
  text-align: center; min-width: 14rem;
}

.nav-btn {
  width: 46px; height: 46px; border-radius: 50%;
  border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, .75); backdrop-filter: blur(8px);
  color: var(--ink); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform .18s ease-out, border-color .18s ease-out, background .18s ease-out;
}
.nav-btn svg { width: 20px; height: 20px; }
.nav-btn:hover { transform: scale(1.08); border-color: var(--leaf); background: #fff; }
.nav-btn:active { transform: scale(.96); }
.nav-btn:disabled { opacity: .35; cursor: default; transform: none; }

/* ---------- chapter tabs ---------- */

.tabs {
  position: fixed; right: 0; top: 50%; transform: translateY(-50%);
  z-index: 40; display: flex; flex-direction: column; gap: .5rem;
}
.tab {
  font-family: var(--mono); font-size: .72rem; font-weight: 500;
  color: var(--muted); background: rgba(255, 255, 255, .8);
  border: 1px solid var(--line-2); border-right: none;
  border-radius: 10px 0 0 10px;
  padding: .6rem .8rem .6rem 1rem; cursor: pointer;
  transform: translateX(8px);
  transition: transform .2s ease-out, background .2s ease-out, color .2s ease-out;
  min-height: 44px;
}
.tab:hover { transform: translateX(0); color: var(--ink); border-color: var(--leaf); }
.tab.active {
  background: linear-gradient(120deg, var(--leaf), var(--teal)); color: #fff;
  transform: translateX(0); border-color: transparent;
  box-shadow: 0 10px 24px -10px var(--glow);
}

/* ---------- stage / book ---------- */

.stage {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  cursor: grab;
  touch-action: pan-y pinch-zoom;
}
.stage.dragging { cursor: grabbing; -webkit-user-select: none; user-select: none; }
.stage img { -webkit-user-drag: none; }

.scene { perspective: 2400px; perspective-origin: 50% 46%; }

.book {
  position: relative;
  width: calc(var(--pw) * 2); height: var(--ph);
  transform-style: preserve-3d;
}

.sheet {
  position: absolute; top: 0; left: 50%;
  width: var(--pw); height: var(--ph);
  transform-origin: 0% 50%;
  transform-style: preserve-3d;
  will-change: transform;
}
/* inner pages sit inside the boards (per-sheet progressive inset from JS);
   boards overhang the spine 1px in opposite directions so no sliver shows */
.sheet.board-front { left: calc(50% - 1px); }
.sheet.board-back { left: calc(50% + 1px); }

.face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: var(--card);
  color: var(--ink);
  border-radius: 3px var(--radius) var(--radius) 3px;
  overflow: hidden;
  display: flex; flex-direction: column;
}
.face.back {
  transform: rotateY(180deg);
  border-radius: var(--radius) 3px 3px var(--radius);
}

/* spine shading only */
.face.front::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 3;
  background: linear-gradient(90deg, rgba(22,40,28,.1), rgba(22,40,28,0) 8%);
}
.face.back::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 3;
  background: linear-gradient(-90deg, rgba(22,40,28,.1), rgba(22,40,28,0) 8%);
}

/* dynamic flip shade, driven from JS via --shade */
.shade {
  position: absolute; inset: 0; pointer-events: none; z-index: 4;
  background: rgba(15, 26, 19, 1); opacity: var(--shade, 0);
}

/* ---------- cover: deep forest board ---------- */

.face.f-cover {
  background:
    radial-gradient(520px 380px at 85% 10%, rgba(31, 157, 85, .2), transparent 60%),
    radial-gradient(420px 320px at 12% 92%, rgba(14, 140, 127, .16), transparent 60%),
    linear-gradient(160deg, var(--forest) 0%, var(--forest-2) 100%);
  color: var(--paper);
}
.cover-inner {
  position: relative; flex: 1; display: flex; flex-direction: column;
  justify-content: space-between; padding: 2.1rem 1.9rem;
}
.cover-eyebrow {
  font-family: var(--mono); font-size: .7rem; letter-spacing: .22em;
  text-transform: uppercase; color: rgba(250, 248, 242, .55);
  display: flex; align-items: center; gap: .6rem;
}
.cover-eyebrow::before { content: ""; width: 26px; height: 1px; background: var(--leaf); }
.cover-rule { display: none; }
.cover-title {
  font-family: var(--display); font-weight: 620;
  font-variation-settings: "opsz" 72;
  font-size: clamp(2.4rem, calc(var(--pw) * .16), 3.6rem);
  line-height: 1.02; letter-spacing: -.015em;
  margin-top: 1.1rem;
}
.cover-title .hl {
  font-style: italic;
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.cover-sub { font-size: .97rem; color: rgba(250, 248, 242, .66); margin-top: .95rem; max-width: 17rem; line-height: 1.6; }
.cover-sun {
  position: absolute; top: 2rem; right: 1.9rem;
  width: .85rem; height: .85rem; border-radius: 50%;
  background: var(--sun);
  box-shadow: 0 0 22px 4px rgba(232, 155, 45, .45);
}
.cover-hand {
  font-family: var(--hand); font-size: 1.45rem; line-height: 1.1;
  color: rgba(250, 248, 242, .85);
  transform: rotate(-3deg);
  display: inline-flex; align-items: center; gap: .5rem;
  align-self: flex-start;
}
.cover-hand svg { width: 34px; height: 20px; color: var(--sun); }

/* ---------- generic page chrome ---------- */

.page-pad { flex: 1; display: flex; flex-direction: column; padding: 1.8rem 1.7rem 1.2rem; min-height: 0; }
.page-num {
  font-family: var(--mono); font-size: .66rem; color: var(--dim);
  margin-top: auto; padding-top: .8rem; display: flex; justify-content: space-between;
  border-top: 1px solid var(--line);
}

.eyebrow {
  font-family: var(--mono); font-size: .67rem; letter-spacing: .2em;
  text-transform: uppercase; color: var(--dim); margin-bottom: .95rem;
  display: flex; align-items: center; gap: .6rem;
}
.eyebrow::before { content: ""; width: 22px; height: 1px; background: var(--leaf); opacity: .7; }

/* intro (inside cover) */
.intro-hand {
  font-family: var(--hand); font-size: 1.5rem; color: var(--leaf);
  transform: rotate(-2deg); margin-bottom: .5rem; display: inline-block;
}
.intro-hello {
  font-family: var(--display); font-weight: 620; font-variation-settings: "opsz" 40;
  font-size: 1.85rem; margin-bottom: 1rem; color: var(--ink);
}
.intro-hello::after { content: ""; display: block; width: 2.4rem; height: 2px; background: var(--grad); margin-top: .7rem; border-radius: 2px; }
.intro-copy { font-size: .95rem; line-height: 1.65; color: var(--ink); max-width: 30ch; }
.intro-copy + .intro-copy { margin-top: .7rem; }
.toc { margin-top: 1.5rem; display: flex; flex-direction: column; gap: .55rem; }
.toc-row {
  display: flex; align-items: baseline; gap: .6rem;
  font-size: .92rem; font-weight: 600;
}
.toc-row .dots { flex: 1; border-bottom: 2px dotted var(--line-2); }
.toc-row .num { font-family: var(--mono); font-size: .72rem; color: var(--leaf); }

/* chapter dividers: dusk-forest panels */
.face.f-div { color: var(--paper); }
.face.f-div.ch-1 {
  background:
    radial-gradient(480px 360px at 80% 12%, rgba(31, 157, 85, .22), transparent 60%),
    linear-gradient(160deg, #15251B 0%, #0F1A13 70%);
}
.face.f-div.ch-2 {
  background:
    radial-gradient(480px 360px at 80% 12%, rgba(232, 155, 45, .18), transparent 60%),
    linear-gradient(160deg, #1A2318 0%, #10180F 70%);
}
.div-inner { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; padding: 2rem 1.8rem; position: relative; }
.div-kanji { display: none; }
.div-num-big {
  position: absolute; top: .8rem; right: 1.2rem;
  font-family: var(--display); font-weight: 500; font-style: italic;
  font-variation-settings: "opsz" 90;
  font-size: clamp(4.2rem, calc(var(--pw) * .3), 6.4rem);
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  opacity: .85; line-height: 1;
}
.f-div.ch-2 .div-num-big { background: linear-gradient(100deg, var(--sun), var(--leaf)); -webkit-background-clip: text; background-clip: text; }
.div-jp {
  font-family: var(--mono); font-size: .68rem; letter-spacing: .22em; text-transform: uppercase;
  color: rgba(250, 248, 242, .55); margin-bottom: .7rem;
  display: flex; align-items: center; gap: .6rem;
}
.div-jp::before { content: ""; width: 26px; height: 1px; background: var(--leaf); }
.div-word {
  font-family: var(--display); font-weight: 620; font-variation-settings: "opsz" 72;
  font-size: clamp(1.8rem, calc(var(--pw) * .125), 2.7rem);
  line-height: 1.06; letter-spacing: -.01em;
}
.div-word em {
  font-style: italic;
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.f-div.ch-2 .div-word em { background: linear-gradient(100deg, var(--sun), var(--leaf)); -webkit-background-clip: text; background-clip: text; }
.div-line { font-size: .95rem; color: rgba(250, 248, 242, .6); margin-top: .7rem; }

/* project image page (left) */
.img-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 1.4rem 1.3rem .4rem; min-height: 0; }
.img-frame {
  position: relative; width: 100%;
  background: #fff; border-radius: 14px;
  padding: .55rem;
  border: 1px solid var(--line);
  box-shadow: 0 18px 40px -12px rgba(22, 40, 28, .28);
  transform: rotate(-2deg);
}
.img-frame img {
  display: block; width: 100%; height: auto; aspect-ratio: 1200 / 750;
  object-fit: cover; border-radius: 9px; background: var(--paper-2);
}
.img-badge {
  position: absolute; top: -1rem; left: -.8rem;
  width: 2.6rem; height: 2.6rem; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-weight: 700; font-size: .85rem; color: #fff;
  box-shadow: 0 10px 20px -6px var(--glow);
  transform: rotate(6deg);
}
.img-caption {
  font-family: var(--mono); font-size: .72rem; color: var(--dim);
  text-align: center; padding: .9rem 1rem 1.3rem;
}

/* project text page (right) */
.proj-name {
  font-family: var(--display); font-weight: 620; font-variation-settings: "opsz" 40;
  font-size: clamp(1.4rem, calc(var(--pw) * .09), 1.85rem);
  margin-bottom: .5rem; letter-spacing: -.01em;
}
.proj-tag { font-size: 1.02rem; font-weight: 650; line-height: 1.35; margin-bottom: .75rem; }
.proj-tag em {
  font-style: normal;
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.proj-desc { font-size: .9rem; line-height: 1.62; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .95rem; }
.chip {
  font-family: var(--mono); font-size: .66rem; letter-spacing: .03em;
  border: 1px solid var(--line-2); border-radius: 999px;
  padding: .3rem .65rem; color: var(--muted); background: rgba(255,255,255,.7);
}
.visit {
  display: inline-flex; align-items: center; gap: .55rem;
  margin-top: 1.15rem; align-self: flex-start;
  font-weight: 600; font-size: .92rem; color: #fff; text-decoration: none;
  background: linear-gradient(120deg, var(--leaf), var(--teal));
  border-radius: 12px; padding: .72rem 1.2rem;
  box-shadow: 0 14px 34px -12px var(--glow), inset 0 1px 0 rgba(255,255,255,.25);
  transition: transform .18s ease-out, box-shadow .18s ease-out;
  min-height: 44px;
}
.visit svg { width: 15px; height: 15px; }
.visit:hover { transform: translateY(-2px); box-shadow: 0 20px 44px -12px var(--glow), inset 0 1px 0 rgba(255,255,255,.25); }

/* stats interlude */
.stat-big {
  font-family: var(--display); font-weight: 620; font-variation-settings: "opsz" 72;
  font-size: 2.8rem; line-height: 1;
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.stat-label { font-size: .95rem; font-weight: 600; margin: .35rem 0 1.1rem; }
.stat-rows { display: flex; flex-direction: column; gap: .6rem; margin-top: .4rem; }
.stat-row { display: flex; align-items: center; gap: .6rem; font-size: .9rem; color: var(--muted); }
.stat-row svg { width: 16px; height: 16px; color: var(--leaf); flex: none; }

/* back cover: dusk forest */
.face.f-back-cover {
  background:
    radial-gradient(480px 380px at 15% 90%, rgba(14, 140, 127, .18), transparent 60%),
    linear-gradient(160deg, var(--forest) 0%, var(--forest-2) 65%);
  color: var(--paper);
}
.backcover-inner { flex: 1; display: flex; flex-direction: column; justify-content: space-between; padding: 2.1rem 1.9rem; }
.backcover-title {
  font-family: var(--display); font-weight: 620; font-variation-settings: "opsz" 72;
  font-size: clamp(1.5rem, calc(var(--pw) * .098), 2rem); line-height: 1.25;
}
.backcover-title em {
  font-style: italic;
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.backcover-copy { font-size: .95rem; line-height: 1.6; color: rgba(250, 248, 242, .64); margin-top: .9rem; max-width: 27ch; }
.visit.visit-invert { background: var(--paper); color: var(--ink); box-shadow: 0 14px 34px -12px rgba(0,0,0,.4); }
.visit.visit-invert:hover { background: #fff; }
.backcover-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; }
.colophon { font-family: var(--mono); font-size: .66rem; color: rgba(250, 248, 242, .38); line-height: 1.7; }
.kan-seal { display: none; }
.sign-hand {
  flex: none;
  font-family: var(--hand); font-size: 1.7rem; color: var(--sun);
  transform: rotate(-4deg);
}

/* mobile compact project page */
.m-proj { padding: 1.2rem 1.2rem .9rem; }
.m-shot {
  display: block; width: 100%; height: auto; aspect-ratio: 1200 / 750;
  object-fit: cover; border-radius: 10px;
  border: 1px solid var(--line);
  box-shadow: 0 10px 24px -8px rgba(22, 40, 28, .25);
  margin: .1rem 0 .8rem;
}
.m-proj .proj-name { font-size: 1.2rem; margin-bottom: .3rem; }
.m-proj .proj-tag { font-size: .9rem; margin-bottom: .5rem; }
.m-proj .proj-desc {
  font-size: .8rem; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.m-proj .chips { margin-top: .6rem; }
.m-proj .visit { margin-top: .8rem; padding: .55rem 1rem; font-size: .85rem; min-height: 42px; }
.m-proj .page-num { display: none; }

/* decorative sheet backs (mobile mode) */
.face.f-deco {
  background:
    radial-gradient(circle at 30% 25%, rgba(31, 157, 85, .07), transparent 45%),
    var(--paper-2);
  align-items: center; justify-content: center;
}

/* endpapers: forest boards with a faint sprig pattern */
.face.f-endpaper {
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56'%3E%3Cg fill='none' stroke='%231F9D55' stroke-opacity='.14' stroke-linecap='round'%3E%3Cpath d='M14 42c0-10 4-18 12-24'/%3E%3Cpath d='M20 30c-3-1-6-1-9 1M23 24c-2-2-5-3-8-2M27 19c-1-3-3-5-6-5'/%3E%3C/g%3E%3C/svg%3E"),
    linear-gradient(160deg, #15241B 0%, #101B14 100%);
}

/* ---------- responsive ---------- */

@media (max-width: 767px) {
  :root {
    --ph: min(70vh, 36rem);
    --pw: min(91vw, calc(var(--ph) * .74));
  }
  .stage { align-items: flex-start; padding-top: 6.5vh; }
  .book { width: var(--pw); }
  .sheet { left: 0; }
  .sheet.board-front { left: -1px; }
  .sheet.board-back { left: 0; }
  .tabs { top: auto; bottom: 5.4rem; right: 0; flex-direction: row; gap: .35rem; left: 0; justify-content: center; }
  .tab {
    border-radius: 999px; border: 1px solid var(--line-2);
    transform: none; padding: .5rem .75rem;
  }
  .hint { min-width: 0; font-size: .7rem; }
  .hud-top { padding: .9rem 1rem; }
  .cover-sun { top: 1.6rem; right: 1.5rem; }
}

@media (min-width: 768px) and (max-width: 1023px) {
  :root { --ph: min(64vh, 29rem); }
}
@media (min-width: 1024px) and (max-width: 1279px) {
  :root { --ph: min(72vh, 33rem); }
}

/* ---------- noscript ---------- */

.noscript {
  position: fixed; inset: 0; z-index: 100; background: var(--paper);
  padding: 3rem 1.5rem; overflow: auto; font-size: 1rem; line-height: 1.7;
}
.noscript h1 { font-family: var(--display); margin-bottom: 1rem; }
.noscript ul { margin-top: 1rem; padding-left: 1.2rem; }
.noscript a { color: var(--teal); }

/* ---------- motion prefs ---------- */

@media (prefers-reduced-motion: reduce) {
  .blob { display: none; }
  .wm-dot { animation: none; }
  * { transition-duration: .01ms !important; }
}

/* focus */
a:focus-visible, button:focus-visible {
  outline: 3px solid var(--leaf); outline-offset: 2px; border-radius: 6px;
}
