/* ============================================================
   HMBL Labs — retro-modern design system
   Zero-build static CSS. No framework.
   ============================================================ */

:root {
  /* ---- LIGHT THEME (cool off-white) — default ---- */
  --paper:      #f3f4f6;   /* cool gray-white */
  --paper-2:    #e7e9ee;
  --ink:        #141518;   /* foreground: text + borders */
  --ink-soft:   #4a4e57;
  --line:       #141518;
  --shadow-col: #141518;

  --red:        #ff5c38;
  --blue:       #2f6df6;
  --yellow:     #ffcf2e;
  --green:      #18a558;
  --purple:     #8a4dff;

  /* inverted surfaces (dark blocks on the light theme): about / spec card / marquee */
  --invert-bg:  #141518;
  --invert-fg:  #f3f4f6;
  --invert-line:rgba(255,255,255,0.18);
  --invert-chip:rgba(255,255,255,0.4);

  /* grain overlay tuning */
  --grain-opacity: 0.05;
  --grain-blend: multiply;

  --shadow:     6px 6px 0 var(--shadow-col);
  --shadow-lg:  10px 10px 0 var(--shadow-col);
  --shadow-sm:  3px 3px 0 var(--shadow-col);

  --radius:     14px;
  --maxw:       1200px;

  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-mono:    "JetBrains Mono", "SF Mono", ui-monospace, monospace;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---- DARK THEME (soft terminal) ---- */
[data-theme="dark"] {
  --paper:      #16181d;   /* soft slate, lifted off pure black */
  --paper-2:    #1e212a;   /* panels a touch lighter */
  --ink:        #d6d8dd;   /* soft off-white — not stark, easier as text + borders */
  --ink-soft:   #868c99;
  --line:       #d6d8dd;
  --shadow-col: rgba(0,0,0,0.45);  /* gentle offset, not a harsh black slab */

  /* MUTED retro accents — desaturated so they don't glare on dark */
  --red:        #e8826b;   /* soft coral */
  --blue:       #5fb9c9;   /* dusty teal */
  --yellow:     #d9b25c;   /* muted gold */
  --green:      #94c06d;   /* sage */
  --purple:     #a98fd6;   /* soft lavender */

  /* inverted surfaces become gentle raised panels instead of bright blocks */
  --invert-bg:  #1e212a;
  --invert-fg:  #d6d8dd;
  --invert-line:rgba(255,255,255,0.10);
  --invert-chip:rgba(255,255,255,0.22);

  --grain-opacity: 0.035;
  --grain-blend: screen;
}

html { background: var(--paper); transition: background .3s var(--ease); }

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-display);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.5;
  overflow-x: hidden;
  font-size: 18px;
  -webkit-font-smoothing: antialiased;
  transition: background .3s var(--ease), color .3s var(--ease);
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
ul { list-style: none; }

/* paper grain overlay */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
  opacity: var(--grain-opacity);
  mix-blend-mode: var(--grain-blend);
  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.9' numOctaves='3' /%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- layout ---------- */
.wrap { width: min(100% - 40px, var(--maxw)); margin-inline: auto; }
section { position: relative; }
.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.eyebrow::before { content: "▍"; color: var(--red); }

/* ---------- custom cursor ---------- */
.cursor-dot, .cursor-ring {
  position: fixed; top: 0; left: 0;
  pointer-events: none; z-index: 9999;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  mix-blend-mode: difference;
}
.cursor-dot { width: 8px; height: 8px; background: #fff; }
.cursor-ring {
  width: 38px; height: 38px; border: 2px solid #fff;
  transition: width .2s var(--ease), height .2s var(--ease), background .2s;
}
.cursor-ring.hover { width: 60px; height: 60px; background: rgba(255,255,255,.15); }
@media (hover: none), (max-width: 768px) { .cursor-dot, .cursor-ring { display: none; } }

/* ---------- nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 100;
  background: var(--paper);
  border-bottom: 3px solid var(--line);
}
.nav-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 68px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; letter-spacing: -0.02em;
}
.brand .logo {
  width: 30px; height: 30px; border: 2.5px solid var(--ink);
  border-radius: 8px; display: grid; place-items: center;
  background: var(--yellow); font-family: var(--font-mono);
  font-weight: 700; font-size: 0.9rem;
  box-shadow: var(--shadow-sm);
  transition: transform .3s var(--ease);
}
.brand:hover .logo { transform: rotate(-8deg) scale(1.05); }
.nav-links { display: flex; align-items: center; gap: 28px; }
.nav-links a {
  font-family: var(--font-mono); font-size: 0.85rem; font-weight: 500;
  position: relative;
}
.nav-links a::after {
  content: ""; position: absolute; left: 0; bottom: -4px;
  width: 100%; height: 2px; background: var(--red);
  transform: scaleX(0); transform-origin: right; transition: transform .3s var(--ease);
}
.nav-links a:hover::after { transform: scaleX(1); transform-origin: left; }
.nav-cta {
  border: 2.5px solid var(--ink); background: var(--ink); color: var(--paper);
  padding: 9px 18px; border-radius: 10px; font-family: var(--font-mono);
  font-size: 0.82rem; font-weight: 600; box-shadow: var(--shadow-sm);
  transition: transform .15s var(--ease), box-shadow .15s var(--ease);
}
.nav-cta:hover { transform: translate(-2px,-2px); box-shadow: 5px 5px 0 var(--ink); }
.nav-toggle { display: none; }

/* theme toggle */
.theme-toggle {
  width: 40px; height: 40px; flex-shrink: 0;
  border: 2.5px solid var(--ink); border-radius: 10px;
  background: var(--paper); color: var(--ink);
  display: grid; place-items: center; font-size: 1.05rem;
  box-shadow: var(--shadow-sm);
  transition: transform .15s var(--ease), box-shadow .15s var(--ease), background .3s var(--ease);
}
.theme-toggle:hover { transform: translate(-2px,-2px) rotate(-6deg); box-shadow: 5px 5px 0 var(--shadow-col); }
.theme-toggle .sun { display: none; }
.theme-toggle .moon { display: block; }
[data-theme="dark"] .theme-toggle .sun { display: block; }
[data-theme="dark"] .theme-toggle .moon { display: none; }

/* smooth the recolor on the main surfaces when switching theme */
.nav, .btn, .service, .proj-card, .proj-tag, .next-proj, .feature,
.spec-card, .about, .marquee, .mission, .proj-card .go, .service .ico,
.feature .fnum, .brand .logo {
  transition: background .3s var(--ease), color .3s var(--ease),
              border-color .3s var(--ease), box-shadow .15s var(--ease);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  border: 2.5px solid var(--ink); border-radius: 12px;
  padding: 14px 24px; font-family: var(--font-mono);
  font-weight: 600; font-size: 0.92rem;
  box-shadow: var(--shadow); background: var(--paper);
  transition: transform .15s var(--ease), box-shadow .15s var(--ease);
}
.btn:hover { transform: translate(-3px,-3px); box-shadow: 9px 9px 0 var(--ink); }
.btn:active { transform: translate(2px,2px); box-shadow: 2px 2px 0 var(--ink); }
.btn-red   { background: var(--red);   color: #fff; }
.btn-blue  { background: var(--blue);  color: #fff; }
.btn-yellow{ background: var(--yellow); color: var(--ink); }
.btn .arrow { transition: transform .2s var(--ease); }
.btn:hover .arrow { transform: translateX(4px); }

/* ---------- hero ---------- */
.hero { padding: 70px 0 40px; position: relative; }
.hero-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 40px; align-items: center; }
.hero h1 {
  font-size: clamp(2.6rem, 7vw, 5.4rem);
  line-height: 0.95; letter-spacing: -0.03em; font-weight: 700;
  margin: 18px 0 26px;
}
.hero h1 .word { display: inline-block; }
.hero h1 em {
  font-style: normal; color: var(--red); position: relative; white-space: nowrap;
}
.hero h1 em::after {
  content: ""; position: absolute; left: -2%; bottom: 6%; width: 104%; height: 14%;
  background: var(--yellow); z-index: -1; transform: rotate(-1.2deg);
}
.hero p {
  font-size: 1.15rem; max-width: 42ch; color: var(--ink-soft); margin-bottom: 30px;
}
.hero-cta { display: flex; gap: 14px; flex-wrap: wrap; }

/* physics canvas pit */
.pit {
  position: relative;
  height: 420px;
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  background:
    repeating-linear-gradient(45deg, transparent, transparent 18px, rgba(0,0,0,.025) 18px, rgba(0,0,0,.025) 19px),
    var(--paper-2);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.pit canvas { display: block; }
.pit-label {
  position: absolute; top: 12px; left: 14px; z-index: 2;
  font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ink-soft); pointer-events: none;
}
.pit-hint {
  position: absolute; bottom: 12px; right: 14px; z-index: 2;
  font-family: var(--font-mono); font-size: 0.7rem; color: var(--ink-soft);
  pointer-events: none; opacity: .7;
}

/* ---------- marquee ---------- */
.marquee {
  border-top: 3px solid var(--line); border-bottom: 3px solid var(--line);
  background: var(--invert-bg); color: var(--invert-fg);
  overflow: hidden; white-space: nowrap; padding: 16px 0;
  margin-top: 50px;
}
.marquee-track { display: inline-flex; gap: 36px; will-change: transform; }
.marquee span {
  font-family: var(--font-mono); font-weight: 600; font-size: 1rem;
  letter-spacing: 0.1em; text-transform: uppercase;
  display: inline-flex; align-items: center; gap: 36px;
}
.marquee span::after { content: "✦"; color: var(--yellow); }

/* ---------- section heading ---------- */
.sec-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 40px; flex-wrap: wrap; }
.sec-head h2 {
  font-size: clamp(2rem, 5vw, 3.4rem); line-height: 1; letter-spacing: -0.03em; font-weight: 700;
}
.sec-head p { font-family: var(--font-mono); font-size: 0.85rem; color: var(--ink-soft); max-width: 36ch; }
.section-pad { padding: 90px 0; }

/* ---------- services ---------- */
.services-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; border: 3px solid var(--ink); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-lg); }
.service {
  padding: 30px 26px; border-right: 3px solid var(--ink);
  background: var(--paper); position: relative; min-height: 240px;
  display: flex; flex-direction: column; justify-content: space-between;
  transition: background .25s var(--ease);
}
.service:last-child { border-right: none; }
.service:hover { background: var(--paper-2); }
.service .num { font-family: var(--font-mono); font-size: 0.72rem; color: var(--ink-soft); }
.service .ico {
  width: 52px; height: 52px; border: 2.5px solid var(--ink); border-radius: 12px;
  display: grid; place-items: center; font-size: 1.5rem; margin: 14px 0 16px;
  box-shadow: var(--shadow-sm); transition: transform .3s var(--ease);
}
.service:hover .ico { transform: rotate(-6deg) translateY(-2px); }
.service h3 { font-size: 1.15rem; letter-spacing: -0.01em; margin-bottom: 6px; }
.service p { font-size: 0.88rem; color: var(--ink-soft); font-family: var(--font-mono); line-height: 1.45; }
.service:nth-child(1) .ico { background: var(--red); }
.service:nth-child(2) .ico { background: var(--blue); color:#fff; }
.service:nth-child(3) .ico { background: var(--yellow); }
.service:nth-child(4) .ico { background: var(--green); color:#fff; }

/* ---------- projects ---------- */
.proj-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 26px; }
.proj-card {
  border: 3px solid var(--ink); border-radius: var(--radius);
  background: var(--paper); box-shadow: var(--shadow); overflow: hidden;
  display: flex; flex-direction: column;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
  position: relative;
}
.proj-card:hover { transform: translate(-4px,-4px); box-shadow: 12px 12px 0 var(--ink); }
.proj-top {
  padding: 26px 26px 0; display: flex; align-items: flex-start; justify-content: space-between;
}
.proj-tag {
  font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: .12em;
  text-transform: uppercase; border: 2px solid var(--ink); border-radius: 100px;
  padding: 4px 12px; background: var(--paper);
}
.proj-card h3 { font-size: 2rem; letter-spacing: -0.03em; padding: 14px 26px 4px; }
.proj-card .desc { padding: 0 26px 22px; color: var(--ink-soft); font-size: 0.98rem; }
.proj-visual {
  margin: 0 26px 26px; border: 2.5px solid var(--ink); border-radius: 10px;
  height: 200px; position: relative; overflow: hidden;
  display: grid; place-items: center;
}
.proj-visual .glyph { font-size: 3.4rem; filter: grayscale(.1); }
.proj-visual img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform .4s var(--ease);
}
.proj-card:hover .proj-visual img { transform: scale(1.04); }
.proj-meta { display: flex; gap: 16px; padding: 0 26px 24px; flex-wrap: wrap; margin-top: auto; }
.proj-meta span { font-family: var(--font-mono); font-size: 0.72rem; color: var(--ink-soft); }
.proj-card .go {
  position: absolute; top: 22px; right: 22px; width: 40px; height: 40px;
  border: 2.5px solid var(--ink); border-radius: 50%; display: grid; place-items: center;
  background: var(--paper); transition: transform .25s var(--ease), background .25s;
}
.proj-card:hover .go { transform: rotate(-45deg); background: var(--yellow); }
/* per-project visual tints */
.v-ardi { background: var(--green); color:#fff; }
.v-next { background: var(--purple); color:#fff; }

/* ---------- about strip ---------- */
.about {
  border: 3px solid var(--ink); border-radius: var(--radius);
  background: var(--invert-bg); color: var(--invert-fg); padding: 60px 50px;
  box-shadow: var(--shadow-lg); position: relative; overflow: hidden;
}
.about h2 { font-size: clamp(1.8rem, 4vw, 3rem); line-height: 1.05; letter-spacing: -0.02em; max-width: 22ch; position: relative; z-index: 1; }
.about h2 b { color: var(--yellow); font-weight: 700; }
.about .blob { position: absolute; font-size: 9rem; opacity: .08; right: 20px; bottom: -30px; }
/* robot mascot — white-on-black art, so screen-blend drops the black background */
.about .blob-img {
  position: absolute; right: 24px; bottom: -10px; width: 200px; height: auto;
  mix-blend-mode: screen; opacity: .9; pointer-events: none; z-index: 0;
}
.about h2 { position: relative; z-index: 1; }

/* ---------- contact / footer ---------- */
.footer { border-top: 3px solid var(--line); margin-top: 90px; padding: 70px 0 40px; }
.foot-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 40px; align-items: center; }
.foot-grid h2 { font-size: clamp(2rem, 6vw, 4rem); letter-spacing: -0.03em; line-height: 0.95; }
.mailto {
  display: inline-flex; align-items: center; gap: 12px; margin-top: 22px;
  font-family: var(--font-mono); font-size: 1rem; font-weight: 600;
  border-bottom: 3px solid var(--red); padding-bottom: 4px;
}
.mailto:hover { color: var(--red); }
.foot-meta { font-family: var(--font-mono); font-size: 0.8rem; color: var(--ink-soft); }
.foot-bottom { display: flex; justify-content: space-between; align-items:center; margin-top: 60px; padding-top: 24px; border-top: 2px dashed var(--ink-soft); flex-wrap: wrap; gap: 12px; }
.foot-bottom span { font-family: var(--font-mono); font-size: 0.75rem; color: var(--ink-soft); }

/* ---------- doodles ---------- */
.doodle { position: absolute; pointer-events: none; z-index: 0; }

/* ---------- reveal animation (IntersectionObserver + CSS, no rAF dependency) ----------
   Content is visible by default; only hidden once <html class="js"> is set by the
   inline head script. So JS-disabled visitors still see everything. */
.reveal { transition: opacity .7s var(--ease), transform .7s var(--ease); }
.js .reveal { opacity: 0; transform: translateY(28px); }
.js .reveal.in { opacity: 1; transform: none; }
.reveal[data-delay="1"] { transition-delay: .08s; }
.reveal[data-delay="2"] { transition-delay: .16s; }
.reveal[data-delay="3"] { transition-delay: .24s; }

/* ============================================================
   PROJECT PAGE
   ============================================================ */
.proj-hero { padding: 60px 0 30px; }
.proj-back { font-family: var(--font-mono); font-size: 0.82rem; display: inline-flex; gap: 8px; align-items: center; margin-bottom: 26px; }
.proj-back:hover { color: var(--red); }
.proj-hero h1 { font-size: clamp(3rem, 12vw, 8rem); letter-spacing: -0.04em; line-height: 0.9; font-weight: 700; }
.proj-hero .lead { font-size: 1.25rem; max-width: 50ch; margin-top: 20px; color: var(--ink-soft); }
.proj-hero .accent-bar { height: 14px; border-radius: 100px; border: 2.5px solid var(--ink); margin: 28px 0; max-width: 320px; }

/* big app screenshot under the project hero */
.proj-shot {
  margin: 36px 0 0; border: 3px solid var(--ink); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow-lg); position: relative;
}
.proj-shot img {
  width: 100%; height: clamp(280px, 44vh, 480px); object-fit: cover; display: block;
}
.proj-shot .shot-tag {
  position: absolute; left: 16px; bottom: 14px;
  font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: .1em; text-transform: uppercase;
  background: var(--paper); color: var(--ink); border: 2px solid var(--ink);
  border-radius: 100px; padding: 5px 12px; box-shadow: var(--shadow-sm);
}

.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 40px; align-items: start; }
.feature {
  border: 3px solid var(--ink); border-radius: var(--radius); padding: 28px 30px;
  background: var(--paper); box-shadow: var(--shadow); margin-bottom: 20px;
  display: flex; gap: 20px; align-items: flex-start;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.feature:hover { transform: translate(-3px,-3px); box-shadow: 9px 9px 0 var(--ink); }
.feature .fnum {
  font-family: var(--font-mono); font-weight: 700; font-size: 1.4rem;
  border: 2.5px solid var(--ink); border-radius: 10px; width: 48px; height: 48px;
  display: grid; place-items: center; flex-shrink: 0; box-shadow: var(--shadow-sm);
}
.feature h3 { font-size: 1.2rem; margin-bottom: 4px; }
.feature p { font-size: 0.95rem; color: var(--ink-soft); }

.spec-card {
  border: 3px solid var(--ink); border-radius: var(--radius); background: var(--invert-bg); color: var(--invert-fg);
  padding: 30px; box-shadow: var(--shadow-lg); position: sticky; top: 90px;
}
.spec-card .row { padding: 16px 0; border-bottom: 1px solid var(--invert-line); }
.spec-card .row:last-child { border-bottom: none; }
.spec-card .k { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: .12em; text-transform: uppercase; opacity: .6; margin-bottom: 6px; }
.spec-card .v { font-size: 1rem; font-weight: 500; }
.spec-card .chips { display: flex; flex-wrap: wrap; gap: 8px; }
.spec-card .chip {
  font-family: var(--font-mono); font-size: 0.74rem; border: 1.5px solid var(--invert-chip);
  border-radius: 100px; padding: 4px 11px;
}
.spec-card .btn { margin-top: 24px; width: 100%; justify-content: center; color: var(--ink); }

.mission {
  border: 3px solid var(--ink); border-radius: var(--radius); padding: 50px;
  box-shadow: var(--shadow-lg); margin-top: 30px; position: relative; overflow:hidden;
}
.mission .eyebrow { margin-bottom: 18px; }
.mission p { font-size: clamp(1.2rem, 2.8vw, 1.7rem); line-height: 1.4; letter-spacing: -0.01em; max-width: 60ch; }

.next-proj {
  display: flex; align-items: center; justify-content: space-between;
  border: 3px solid var(--ink); border-radius: var(--radius); padding: 40px;
  margin-top: 40px; background: var(--paper); box-shadow: var(--shadow);
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), background .25s;
}
.next-proj:hover { transform: translate(-4px,-4px); box-shadow: 12px 12px 0 var(--ink); background: var(--yellow); }
.next-proj .np-label { font-family: var(--font-mono); font-size: 0.78rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-soft); }
.next-proj .np-name { font-size: clamp(2rem, 6vw, 3.6rem); letter-spacing: -0.03em; line-height: 1; }
.next-proj .np-arrow { font-size: 2.4rem; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; }
  .pit { height: 320px; }
  .services-grid { grid-template-columns: repeat(2, 1fr); }
  .service:nth-child(2) { border-right: none; }
  .service:nth-child(1), .service:nth-child(2) { border-bottom: 3px solid var(--ink); }
  .proj-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .spec-card { position: static; }
  .foot-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  body { font-size: 17px; }
  .nav-links { display: none; }
  .services-grid { grid-template-columns: 1fr; }
  .service { border-right: none !important; border-bottom: 3px solid var(--ink); min-height: auto; }
  .service:last-child { border-bottom: none; }
  .mission { padding: 32px 24px; }
  .about { padding: 40px 28px; }
  .next-proj { flex-direction: column; gap: 18px; align-items: flex-start; }
}

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; }
  * { scroll-behavior: auto !important; }
}
