/* ─────────────────────────────────────────────
   Aldemir Konuk — Portfolio
   Three.js cube + scroll-pinned chapter cards
   ───────────────────────────────────────────── */

:root {
  --paper:     #EDEAE0;
  --paper-warm:#E6E2D5;
  --ink:       #1B3C30;
  --ink-soft:  #38554A;
  --ink-mute:  #6B7E73;
  --rule:      #C3C2B6;
  --earth:     #7A5E30;   /* used exactly 3x per chapter view, no more */
}

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

html, body {
  background: var(--paper);
  color: var(--ink);
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-weight: 400;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

body {
  background-image:
    radial-gradient(1200px 700px at 18% 22%, rgba(255,255,255,.32), transparent 70%),
    radial-gradient(1000px 560px at 86% 88%, rgba(27,60,48,.05), transparent 70%);
  background-attachment: fixed;
}

/* paper grain */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 200;
  opacity: .28;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.95' numOctaves='2' seed='5'/><feColorMatrix values='0 0 0 0 0.18   0 0 0 0 0.24   0 0 0 0 0.19   0 0 0 .12 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* ─── chrome (corners + lockup) ─── */
.chrome {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 80;
  padding: 22px 32px;
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  mix-blend-mode: multiply;
  pointer-events: none;
}
.chrome .lockup { color: var(--ink); white-space: nowrap; }
.chrome .lockup b { font-weight: 500; }
.chrome .right { display: flex; gap: 22px; white-space: nowrap; font-size: 10px; }

.crop {
  position: fixed;
  width: 14px; height: 14px;
  z-index: 70;
  pointer-events: none;
  mix-blend-mode: multiply;
}
.crop.tl { top: 14px; left: 14px;  border-top: 1px solid var(--ink); border-left: 1px solid var(--ink); }
.crop.tr { top: 14px; right: 14px; border-top: 1px solid var(--ink); border-right: 1px solid var(--ink); }
.crop.bl { bottom: 14px; left: 14px;  border-bottom: 1px solid var(--ink); border-left: 1px solid var(--ink); }
.crop.br { bottom: 14px; right: 14px; border-bottom: 1px solid var(--ink); border-right: 1px solid var(--ink); }

/* ─── cube stage (pinned full-viewport) ─── */
.cube-stage {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;   /* canvas is visual only — no orbit interaction */
}

.cube-canvas {
  width: 64vmin;
  height: 64vmin;
  display: block;
}

/* soft ground shadow under the cube */
.cube-stage::after {
  content: "";
  position: absolute;
  left: 50%;
  top: calc(50% + 26vmin);
  transform: translateX(-50%);
  width: 36vmin;
  height: 3.5vmin;
  background: radial-gradient(ellipse at center, rgba(27,60,48,.32), transparent 70%);
  filter: blur(10px);
  z-index: -1;
  opacity: .8;
}

/* ─── scroll sections (invisible scrollytelling markers) ─── */
.scroll-track {
  position: relative;
  /* one section per chapter — height drives ScrollTrigger ranges */
}
.scroll-section {
  height: 100vh;
  position: relative;
}
.scroll-section + .scroll-section { /* no gap */ }

/* ─── chapter card (anchored over the cube's front face) ─── */
.card-host {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.card {
  position: relative;
  width: 44vmin;
  min-width: 360px;
  max-width: 560px;
  padding: 36px 38px;
  background: rgba(237, 234, 224, 0.78);
  backdrop-filter: blur(8px) saturate(1.05);
  border: 1px solid rgba(27, 60, 48, 0.12);
  border-radius: 14px;
  box-shadow:
    0 30px 80px -30px rgba(27, 60, 48, 0.45),
    0 2px 12px rgba(27, 60, 48, 0.08);
  pointer-events: auto;
  will-change: opacity, transform;
}
/* card mount/exit choreography — use CSS animations so the in/out plays
   every time we toggle classes, including the first mount. */
.card {
  opacity: 0;
}
.card.is-active {
  animation: cardIn .65s cubic-bezier(.2,.7,.2,1) both;
}
.card.is-hidden {
  animation: cardOut .32s cubic-bezier(.4,.0,.6,1) both;
}
@keyframes cardIn {
  0%   { opacity: 0; transform: translateY(20px) scale(.98); }
  100% { opacity: 1; transform: translateY(0)   scale(1);    }
}
@keyframes cardOut {
  0%   { opacity: 1; transform: translateY(0)    scale(1);    }
  100% { opacity: 0; transform: translateY(-10px) scale(.98); }
}

/* card content ─────────────────────────────── */

.card .eyebrow {
  font-family: "JetBrains Mono", monospace;
  font-size: 10.5px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--earth);                    /* EARTH USE 1 — chapter label */
  margin-bottom: 14px;
  display: flex; align-items: baseline; gap: 12px;
}
.card .eyebrow .rule {
  flex: 1;
  height: 1px;
  background: var(--earth);              /* EARTH USE 2 — accent rule */
  opacity: .55;
}
.card .eyebrow .count { color: var(--ink-mute); }

.card h1 {
  font-family: "Instrument Serif", "Times New Roman", serif;
  font-weight: 400;
  font-size: clamp(32px, 3.8vmin, 56px);
  line-height: 1.02;
  letter-spacing: -.015em;
  color: var(--ink);
  margin-bottom: 14px;
  text-wrap: balance;
}
.card h1 em { font-style: italic; }

.card .lede {
  font-family: "Instrument Serif", serif;
  font-size: clamp(15px, 1.7vmin, 19px);
  line-height: 1.4;
  color: var(--ink-soft);
  font-style: italic;
  margin-bottom: 20px;
  max-width: 38ch;
}

.card p.body {
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
  margin-bottom: 12px;
  max-width: 44ch;
}
.card p.body + p.body { margin-top: -2px; }

/* ── chapter-specific content blocks ── */

.card .manifesto {
  display: grid;
  gap: 14px;
  margin-top: 4px;
}
.card .manifesto .line {
  font-family: "Instrument Serif", serif;
  font-size: clamp(17px, 1.9vmin, 22px);
  line-height: 1.32;
  color: var(--ink);
  padding-left: 14px;
  border-left: 1px solid var(--rule);
}

.card .projects {
  display: flex; flex-direction: column;
  border-top: 1px solid var(--rule);
  margin-top: 4px;
}
.card .projects .row {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: baseline;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--rule);
  font-size: 13px;
}
.card .projects .row .idx {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px; color: var(--ink-mute);
  letter-spacing: .1em;
}
.card .projects .row .name {
  font-family: "Instrument Serif", serif;
  font-size: 18px; color: var(--ink);
  line-height: 1.1;
}
.card .projects .row .name .sub {
  display: block;
  font-family: "Space Grotesk", sans-serif;
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-top: 3px;
}
.card .projects .row .yr {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  color: var(--ink-mute);
}

/* craft / skills constellation — a tight tag-cluster, not really nodes
   (treatment deferred); arranged with slight offsets for atlas feel */
.card .craft {
  display: flex; flex-wrap: wrap; gap: 8px 10px;
  margin-top: 4px;
}
.card .craft .skill {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding: 6px 11px;
  border: 1px solid var(--rule);
  border-radius: 999px;
}
.card .craft .skill.is-core {
  color: var(--ink);
  border-color: var(--ink);
}

/* contact */
.card .contact-link {
  display: inline-block;
  font-family: "Instrument Serif", serif;
  font-style: italic;
  font-size: clamp(22px, 2.8vmin, 34px);
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--ink);
  padding-bottom: 2px;
  transition: opacity .25s;
}
.card .contact-link:hover { opacity: .65; }

/* github contribution mini-grid (placeholder treatment) */
.card .grid-contrib {
  display: grid;
  grid-template-columns: repeat(20, 1fr);
  grid-auto-rows: 8px;
  gap: 3px;
  margin-top: 4px;
  margin-bottom: 14px;
}
.card .grid-contrib .cell {
  background: var(--rule);
  border-radius: 1.5px;
}
.card .grid-contrib .cell.l1 { background: #B0C0B0; }
.card .grid-contrib .cell.l2 { background: #6B8A77; }
.card .grid-contrib .cell.l3 { background: #1B3C30; }

/* ─── twist indicator (EARTH USE 3) ─── */
.twist-indicator {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 60;
  display: flex; align-items: center; gap: 12px;
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  white-space: nowrap;
  background: rgba(237,234,224,.7);
  backdrop-filter: blur(6px);
  border: 1px solid var(--earth);          /* EARTH USE 3 */
  padding: 6px 14px;
  border-radius: 999px;
}
.twist-indicator .kind {
  color: var(--earth);
  font-weight: 500;
}

/* ─── rail (chapter navigation, right edge) ─── */
.rail {
  position: fixed;
  top: 50%; right: 24px;
  transform: translateY(-50%);
  z-index: 60;
  display: flex; flex-direction: column;
  gap: 14px;
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: .1em;
  mix-blend-mode: multiply;
}
.rail .tick {
  display: grid;
  grid-template-columns: 28px 24px auto;
  align-items: center;
  gap: 10px;
  color: var(--ink-mute);
  transition: color .4s ease;
  cursor: pointer;
}
.rail .tick .bar {
  height: 1px; background: var(--ink-mute);
  transition: background .4s, width .4s;
  width: 16px;
}
.rail .tick.is-active { color: var(--ink); }
.rail .tick.is-active .bar { background: var(--ink); width: 44px; margin-left: -16px; }

/* ─── scroll cue (only on Entry) ─── */
.scroll-cue {
  position: fixed;
  left: 32px;
  bottom: 28px;
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-mute);
  display: flex; align-items: center; gap: 10px;
  z-index: 60;
  transition: opacity .6s;
}
.scroll-cue.is-hidden { opacity: 0; pointer-events: none; }
.scroll-cue .line {
  display: inline-block;
  width: 36px; height: 1px;
  background: var(--ink-mute);
  position: relative;
  overflow: hidden;
}
.scroll-cue .line::after {
  content: "";
  position: absolute; inset: 0;
  background: var(--ink);
  animation: cue 1.8s ease-in-out infinite;
}
@keyframes cue {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ─── intro overlay (covers until solve completes) ─── */
.intro-veil {
  position: fixed; inset: 0;
  z-index: 90;
  background: var(--paper);
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  transition: opacity 0.6s ease;
}
.intro-veil.is-gone { opacity: 0; }

.intro-veil .label {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  letter-spacing: .25em;
  text-transform: uppercase;
  color: var(--ink-soft);
  display: flex; align-items: center; gap: 14px;
}
.intro-veil .label::before { content: "PORTFOLIO INDEX"; }
.intro-veil .label .pulse {
  width: 6px; height: 6px;
  background: var(--ink);
  border-radius: 50%;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: .3; transform: scale(1); }
  50%      { opacity: 1;  transform: scale(1.3); }
}

/* ─── responsive ─── */
@media (max-width: 720px) {
  .cube-canvas { width: 80vmin; height: 80vmin; }
  .card { width: 80vmin; min-width: 0; padding: 24px 22px; }
  .rail { display: none; }
  .chrome { padding: 14px 16px; font-size: 9.5px; }
  .chrome .right { gap: 12px; }
  .chrome .right span:nth-child(1) { display: none; }
}
