/* ==========================================================================
   Cldesignz — Christopher Laguitan Portfolio
   Design tokens: warm-gold + cool-teal duality (Pollen / AI signal system)
   ========================================================================== */

:root{
  /* ---- LIGHT (default) ---- */
  --bg: #F3F4F1;
  --surface: #FFFFFF;
  --surface-2: #FBFBF9;
  --ink: #14161C;
  --ink-soft: #53565F;
  --ink-faint: #8A8D93;
  --line: #DEDFDA;
  --line-strong: #C7C9C2;
  --accent-gold: #7C4DFF;
  --accent-gold-soft: #9B77FF;
  --accent-teal: #FF3D71;
  --accent-teal-soft: #FF6B93;
  --shadow: 0 1px 2px rgba(20,22,28,0.04), 0 12px 32px -16px rgba(20,22,28,0.10);
  --grain-opacity: 0.035;

  --font-display: 'Space Grotesk', ui-sans-serif, system-ui, sans-serif;
  --font-body: 'Inter', ui-sans-serif, system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;

  color-scheme: light;
}

html.dark{
  --bg: #0B0C0F;
  --surface: #15171C;
  --surface-2: #1B1D23;
  --ink: #F1F2EF;
  --ink-soft: #ABAEB6;
  --ink-faint: #6F727B;
  --line: #262830;
  --line-strong: #34363E;
  --accent-gold: #A78BFA;
  --accent-gold-soft: #C4B0FF;
  --accent-teal: #FF6B93;
  --accent-teal-soft: #FF93B0;
  --shadow: 0 1px 2px rgba(0,0,0,0.4), 0 20px 48px -20px rgba(0,0,0,0.6);
  --grain-opacity: 0.05;
  color-scheme: dark;
}

*{ box-sizing: border-box; }

html{
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce){
  html{ scroll-behavior: auto; }
  *{ animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

body{
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.5s ease, color 0.5s ease;
  overflow-x: hidden;
}

/* filter flash-guard during theme transition */
body.theme-transitioning{
  transition: background-color 0.6s ease, color 0.6s ease, filter 0.6s ease;
}

a{ color: inherit; text-decoration: none; }
h1,h2,h3{ font-family: var(--font-display); margin: 0; }
p{ margin: 0; }
button{ font-family: inherit; background: none; border: none; cursor: pointer; color: inherit; }

::selection{ background: var(--accent-gold-soft); color: #14161C; }

:focus-visible{
  outline: 2px solid var(--accent-teal);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ---------------- Grain overlay ---------------- */
.grain{
  position: fixed;
  inset: 0;
  z-index: 9998;
  pointer-events: none;
  opacity: var(--grain-opacity);
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------------- Cursor charm ---------------- */
.cursor-dot{
  position: fixed;
  top: 0; left: 0;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent-gold);
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%,-50%);
  mix-blend-mode: difference;
  transition: opacity 0.3s ease;
}
@media (hover: none){ .cursor-dot{ display: none; } }

/* ================= NAV ================= */
.nav{
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px clamp(20px, 5vw, 56px);
  backdrop-filter: blur(10px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s ease, background-color 0.5s ease;
}
.nav.is-scrolled{ border-bottom-color: var(--line); }

.nav__mark{
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
  display: flex;
  align-items: baseline;
  gap: 2px;
}
.nav__mark-cl{ color: var(--ink); }
.nav__mark-domain{ color: var(--ink-faint); font-weight: 500; }

.nav__links{
  display: flex;
  gap: clamp(18px, 3vw, 36px);
}
.nav__links a{
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.2s ease;
}
.nav__links a:hover{ color: var(--ink); }
.nav__num{
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--accent-teal);
}

.nav__burger{ display: none; flex-direction: column; gap: 5px; width: 22px; }
.nav__burger span{ height: 2px; width: 100%; background: var(--ink); border-radius: 2px; }

/* ---------------- Theme toggle ---------------- */
.theme-toggle{ display: flex; align-items: center; }
.theme-toggle__track{
  width: 52px; height: 28px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  display: flex;
  align-items: center;
  padding: 3px;
  transition: background-color 0.4s ease, border-color 0.4s ease;
}
.theme-toggle__thumb{
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--accent-gold);
  display: flex; align-items: center; justify-content: center;
  color: var(--surface);
  transform: translateX(0);
  transition: transform 0.4s cubic-bezier(0.65,0,0.35,1), background-color 0.4s ease;
}
html.dark .theme-toggle__thumb{
  transform: translateX(24px);
  background: var(--accent-teal-soft);
}
.theme-toggle__thumb svg{ width: 13px; height: 13px; }
.icon-moon{ display: none; }
html.dark .icon-sun{ display: none; }
html.dark .icon-moon{ display: block; }

/* ================= HERO ================= */
.hero{
  min-height: clamp(460px, 82vh, 820px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 140px clamp(20px, 6vw, 64px) 60px;
  max-width: 1180px;
  margin: 0 auto;
}

.hero__eyebrow{
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 28px;
}
.hero__eyebrow .dot{
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent-teal);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent-teal) 18%, transparent);
}

.hero__headline{
  font-size: clamp(40px, 7.4vw, 96px);
  font-weight: 600;
  line-height: 1.02;
  letter-spacing: -0.03em;
  color: var(--ink);
  margin-bottom: 36px;
}
.hero__headline .line{ display: block; overflow: hidden; }
.hero__headline .line--accent{ color: var(--accent-gold); }

.hero__sub{
  max-width: 620px;
  font-size: clamp(16px, 1.6vw, 19px);
  line-height: 1.55;
  color: var(--ink-soft);
  margin-bottom: 44px;
}

.hero__cta{
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 20px;
}

.btn{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 15px 26px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  transition: transform 0.25s cubic-bezier(0.65,0,0.35,1), background-color 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
}
.btn--primary{
  background: var(--ink);
  color: var(--bg);
}
html.dark .btn--primary{ background: var(--accent-gold-soft); color: #14161C; }
.btn--primary:hover{ transform: translateY(-2px); box-shadow: var(--shadow); }
.btn--primary svg{ transition: transform 0.25s ease; }
.btn--primary:hover svg{ transform: translateX(3px); }

.btn--ghost{
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--line-strong);
  border-radius: 0;
  padding: 6px 0;
}
.btn--ghost:hover{ color: var(--ink); border-color: var(--ink); }

/* ================= TICKER ================= */
.ticker{
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  overflow: hidden;
  padding: 14px 0;
  transition: background-color 0.5s ease, border-color 0.5s ease;
}
.ticker__track{
  display: flex;
  gap: 48px;
  width: max-content;
  animation: ticker-scroll 32s linear infinite;
}
.ticker__item{
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.03em;
  color: var(--ink-faint);
  white-space: nowrap;
}
.ticker__item b{ color: var(--accent-teal); font-weight: 600; }

@keyframes ticker-scroll{
  from{ transform: translateX(0); }
  to{ transform: translateX(-50%); }
}

/* ================= SECTION SHELL ================= */
.section{
  max-width: 1180px;
  margin: 0 auto;
  padding: 120px clamp(20px, 6vw, 64px) 0;
}
.section__head{ margin-bottom: 56px; max-width: 720px; }
.section__eyebrow{
  display: block;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent-teal);
  letter-spacing: 0.05em;
  margin-bottom: 14px;
}
.section__title{
  font-size: clamp(28px, 3.6vw, 44px);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.section__note{
  margin-top: 14px;
  color: var(--ink-soft);
  font-size: 15px;
}

/* ================= BENTO ================= */
.bento{
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: minmax(180px, auto);
  gap: 16px;
}
.bento__card{
  grid-column: span 2;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: transform 0.3s cubic-bezier(0.65,0,0.35,1), border-color 0.3s ease, background-color 0.5s ease, box-shadow 0.3s ease;
}
.bento__card:hover{
  transform: translateY(-4px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
}
.bento__card--lg{ grid-column: span 2; grid-row: span 2; }
.bento__card--wide{ grid-column: span 2; }

.bento__glyph{ width: 40px; height: 40px; color: var(--accent-gold); }
.bento__card:nth-child(3) .bento__glyph{ color: var(--accent-teal); }
.bento__card h3{ font-size: 19px; font-weight: 600; letter-spacing: -0.01em; }
.bento__card p{ color: var(--ink-soft); font-size: 14.5px; line-height: 1.55; }

/* ================= MANIFEST / CASE STUDIES ================= */
.manifest{
  border-top: 1px solid var(--line-strong);
}
.manifest__row{
  border-bottom: 1px solid var(--line-strong);
}
.manifest__summary{
  width: 100%;
  display: grid;
  grid-template-columns: 90px 1fr auto 20px;
  align-items: center;
  gap: 24px;
  padding: 30px 4px;
  text-align: left;
}
.manifest__id{
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent-gold);
}
.manifest__title{
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: var(--font-display);
  font-size: clamp(19px, 2.4vw, 26px);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.manifest__title em{
  font-style: normal;
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 13.5px;
  color: var(--ink-faint);
}
.manifest__tags{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}
.manifest__tags span{
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-soft);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 5px 11px;
}
.manifest__chev{
  color: var(--ink-faint);
  transition: transform 0.3s ease;
}
.manifest__row[data-open] .manifest__chev{ transform: rotate(180deg); }

.manifest__detail{
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.45s cubic-bezier(0.65,0,0.35,1);
}
.manifest__row[data-open] .manifest__detail{ grid-template-rows: 1fr; }
.manifest__detail > *{ overflow: hidden; }

.manifest__split{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  padding: 0 4px 32px;
}
.manifest__label{
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--accent-teal);
  margin-bottom: 10px;
}
.manifest__col p{ color: var(--ink-soft); font-size: 15px; line-height: 1.6; }

.manifest__viz{ padding: 0 4px 40px; }
.manifest__viz svg{ display: block; height: auto; max-height: 200px; }

.manifest__viz{ padding: 0 4px 40px; }
.manifest__viz svg{ display: block; height: auto; max-height: 200px; overflow: visible; }

.viz-panel{ fill: var(--surface-2); stroke: var(--line-strong); stroke-width: 1; }
.viz-label{ font-family: var(--font-mono); font-size: 9.5px; fill: var(--ink-faint); letter-spacing: 0.03em; }
.viz-line{ fill: none; stroke-width: 2.5; stroke-linecap: round; }
.viz-area{ opacity: 0; }
.viz-dot{ fill: var(--accent-gold); }
.viz-dot-ring{ fill: none; stroke: var(--accent-gold); stroke-width: 1.4; opacity: 0; }
.viz-bar{ opacity: 0.92; }
.viz-track{ fill: var(--surface); stroke: var(--line-strong); stroke-width: 1; }
.viz-fill{ opacity: 0.95; }
.viz-fill-dot{ fill: var(--surface); stroke: var(--accent-gold); stroke-width: 2; opacity: 0; }
.viz-core{ fill: var(--surface); stroke: var(--accent-gold); stroke-width: 1.8; }
.viz-core-glow{ opacity: 0; }
.viz-core-label{ font-family: var(--font-mono); font-size: 10px; fill: var(--ink); font-weight: 600; }
.viz-agent{ fill: var(--surface); stroke: var(--accent-teal); stroke-width: 1.6; }
.viz-agent-glow{ opacity: 0; }
.viz-agent-label{ font-family: var(--font-mono); font-size: 9px; fill: var(--ink-soft); }
.viz-link{ fill: none; stroke: var(--line-strong); stroke-width: 1.4; }
.viz-token-gem{ opacity: 0; stroke: var(--surface); stroke-width: 1.5; }
.viz-flow-dot{ fill: var(--accent-gold); opacity: 0; filter: drop-shadow(0 0 2px var(--accent-gold)); }
.viz-system rect.viz-panel{ fill: var(--surface); }

/* ---- Animated, illustrative diagrams: replay each time a case study opens ---- */
.manifest__row[data-open] .viz-line{
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  animation: viz-draw 1.1s cubic-bezier(0.16,1,0.3,1) forwards;
}
.manifest__row[data-open] .viz-area{
  animation: viz-fade-in 0.8s ease-out 0.9s forwards;
}
.manifest__row[data-open] .viz-dot{
  animation: viz-pop 0.4s ease-out 1s backwards, viz-dot-pulse 1.6s ease-in-out 1.4s infinite;
}
.manifest__row[data-open] .viz-dot-ring{
  animation: viz-ripple 1.8s ease-out 1.1s infinite;
}
.manifest__row[data-open] .viz-bar{
  transform-box: fill-box;
  transform-origin: bottom;
  animation: viz-grow-y 0.6s cubic-bezier(0.34,1.56,0.64,1) backwards;
  animation-delay: calc(var(--i, 0) * 0.09s);
}
.manifest__row[data-open] .viz-fill{
  transform-box: fill-box;
  transform-origin: left;
  animation: viz-grow-x 0.7s cubic-bezier(0.34,1.56,0.64,1) backwards;
  animation-delay: calc(var(--i, 0) * 0.12s + 0.1s);
}
.manifest__row[data-open] .viz-fill-dot{
  transform-box: fill-box;
  transform-origin: center;
  animation: viz-pop 0.3s ease-out backwards;
  animation-delay: calc(var(--i, 0) * 0.12s + 0.75s);
}
.manifest__row[data-open] .viz-link{
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  animation: viz-draw 0.8s ease-out backwards;
  animation-delay: calc(var(--i, 0) * 0.1s);
}
.manifest__row[data-open] .viz-flow-dot{
  animation: viz-flow-in 0.3s ease-out 1.2s forwards;
}
.manifest__row[data-open] .viz-agent{
  transform-box: fill-box;
  transform-origin: center;
  animation: viz-pop 0.45s cubic-bezier(0.34,1.56,0.64,1) backwards, viz-float 3.4s ease-in-out infinite;
  animation-delay: calc(var(--i, 0) * 0.1s + 0.15s), calc(var(--i, 0) * 0.35s + 0.6s);
}
.manifest__row[data-open] .viz-agent-glow{
  animation: viz-fade-in 0.6s ease-out backwards;
  animation-delay: calc(var(--i, 0) * 0.1s + 0.1s);
}
.manifest__row[data-open] .viz-core{
  transform-box: fill-box;
  transform-origin: center;
  animation: viz-pop 0.5s cubic-bezier(0.34,1.56,0.64,1) backwards, viz-breathe 2.6s ease-in-out 0.5s infinite;
}
.manifest__row[data-open] .viz-core-glow{
  animation: viz-fade-in 0.8s ease-out 0.2s forwards, viz-breathe 2.6s ease-in-out 0.5s infinite;
}
.manifest__row[data-open] .viz-token-gem{
  transform-box: fill-box;
  transform-origin: center;
  animation: viz-pop 0.5s cubic-bezier(0.34,1.56,0.64,1) backwards forwards, viz-breathe 2.6s ease-in-out 0.5s infinite;
}
.manifest__row[data-open] .viz-system .viz-panel{
  transform-box: fill-box;
  transform-origin: center;
  animation: viz-rise 0.5s cubic-bezier(0.34,1.56,0.64,1) backwards;
  animation-delay: calc(var(--i, 0) * 0.1s + 0.5s);
}

@keyframes viz-draw{ to{ stroke-dashoffset: 0; } }
@keyframes viz-fade-in{ to{ opacity: 1; } }
@keyframes viz-flow-in{ to{ opacity: 0.9; } }
@keyframes viz-pop{ from{ transform: scale(0); opacity: 0; } to{ transform: scale(1); opacity: 1; } }
@keyframes viz-grow-y{ from{ transform: scaleY(0); } to{ transform: scaleY(1); } }
@keyframes viz-grow-x{ from{ transform: scaleX(0); } to{ transform: scaleX(1); } }
@keyframes viz-rise{ from{ transform: translateY(10px) scale(0.9); opacity: 0; } to{ transform: translateY(0) scale(1); opacity: 1; } }
@keyframes viz-float{ 0%, 100%{ transform: translateY(0); } 50%{ transform: translateY(-4px); } }
@keyframes viz-breathe{ 0%, 100%{ transform: scale(1); } 50%{ transform: scale(1.05); } }
@keyframes viz-dot-pulse{
  0%, 100%{ r: 3.5; opacity: 1; }
  50%{ r: 5; opacity: 0.65; }
}
@keyframes viz-ripple{
  0%{ r: 3.5; stroke-opacity: 0.6; opacity: 1; }
  100%{ r: 16; stroke-opacity: 0; opacity: 0; }
}

@media (prefers-reduced-motion: reduce){
  .viz-flow-dot{ display: none; }
}

/* ================= TIMELINE ================= */
.timeline{ border-top: 1px solid var(--line); }
.timeline__row{
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 28px;
  padding: 32px 4px;
  border-bottom: 1px solid var(--line);
}
.timeline__date{
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent-gold);
  padding-top: 4px;
}
.timeline__body h3{ font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.timeline__org{
  display: block;
  font-size: 13px;
  color: var(--accent-teal);
  font-weight: 500;
  margin-bottom: 10px;
}
.timeline__body p{ color: var(--ink-soft); font-size: 14.5px; max-width: 560px; line-height: 1.55; }
.timeline__extra{ font-style: normal; }

/* ================= CONTACT ================= */
.contact{
  margin-top: 140px;
  padding: 100px clamp(20px, 6vw, 64px) 90px;
  background: var(--surface);
  border-top: 1px solid var(--line);
  transition: background-color 0.5s ease, border-color 0.5s ease;
}
.contact__inner{ max-width: 720px; margin: 0 auto; text-align: center; }
.contact__headline{
  font-size: clamp(30px, 5vw, 54px);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 18px 0 20px;
}
.contact__sub{ color: var(--ink-soft); font-size: 16px; max-width: 520px; margin: 0 auto 40px; }
.contact__actions{ display: flex; justify-content: center; flex-wrap: wrap; gap: 20px; }

/* ================= FOOTER ================= */
.footer{
  display: flex;
  justify-content: space-between;
  padding: 28px clamp(20px, 6vw, 64px);
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-faint);
}

/* ================= REVEAL ANIM HOOK ================= */
[data-reveal]{ opacity: 0; transform: translateY(28px); }
[data-reveal].is-visible{
  animation: reveal-up 0.7s cubic-bezier(0.16,1,0.3,1) forwards;
}
@keyframes reveal-up{
  to{ opacity: 1; transform: translateY(0); }
}

/* ================= RESPONSIVE ================= */
@media (max-width: 860px){
  .nav__links{ display: none; }
  .nav__burger{ display: flex; }
  .hero{ min-height: auto; padding-top: 120px; }
  .bento{ grid-template-columns: repeat(2, 1fr); }
  .bento__card--lg{ grid-row: span 1; }
  .manifest__summary{ grid-template-columns: 60px 1fr 20px; }
  .manifest__tags{ display: none !important; }
  .manifest__split{ grid-template-columns: 1fr; }
  .timeline__row{ grid-template-columns: 1fr; gap: 8px; }
  .contact{ margin-top: 90px; }
}

@media (max-width: 540px){
  .hero{ padding-top: 120px; min-height: auto; }
  .section{ padding-top: 88px; }
  .bento{ grid-template-columns: 1fr; }
  .bento__card--lg, .bento__card--wide{ grid-column: span 1; }
}
