/* ============================================================
   Nebulys Studio — global stylesheet
   Two worlds, one tear.
   ============================================================ */

:root {
  /* Palette */
  --cream: #F7F6EC;
  --cream-warm: #EFEDE0;
  --ink: #2D2D2D;
  --ink-soft: #4a4a48;
  --black: #111111;
  --black-deep: #0a0a0a;
  --hero-bg: #1a1a1a;
  --burgundy: #A62223;
  --burgundy-deep: #7a1718;
  --rule: rgba(45,45,45,0.14);
  --rule-dark: rgba(247,246,236,0.16);

  /* Type */
  --font-display: "Anton", "Bebas Neue", "Impact", sans-serif;
  --font-body: "Work Sans", "IBM Plex Sans", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "IBM Plex Mono", ui-monospace, monospace;

  /* Texture intensity (0..1) */
  --tex: 0.55;

  /* Header style on sub-pages: cream / dark / split */
  --header-bg: var(--cream);
  --header-fg: var(--ink);
  --header-rule: var(--rule);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--cream); color: var(--ink); }
body {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { font: inherit; cursor: pointer; background: none; border: none; color: inherit; }

/* ============================================================
   Crosshatch texture (used on workshop / dark surfaces)
   ============================================================ */
.tex-hatch {
  position: relative;
  isolation: isolate;
}
.tex-hatch::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    repeating-linear-gradient(
      45deg,
      transparent 0 6px,
      rgba(247,246,236, calc(var(--tex) * 0.05)) 6px 7px
    ),
    repeating-linear-gradient(
      -45deg,
      transparent 0 9px,
      rgba(247,246,236, calc(var(--tex) * 0.04)) 9px 10px
    );
  mix-blend-mode: screen;
  opacity: calc(0.4 + var(--tex) * 0.8);
  z-index: 0;
}
.tex-hatch > * { position: relative; z-index: 1; }

/* Grainy noise on cream surfaces — barely visible */
.tex-grain {
  position: relative;
  isolation: isolate;
}
.tex-grain::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  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='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.18  0 0 0 0 0.18  0 0 0 0 0.18  0 0 0 0.4 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-size: 240px 240px;
  opacity: 0.12;
  mix-blend-mode: multiply;
  z-index: 2;
}

/* ============================================================
   Site header
   ============================================================ */
.site-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 80;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 18px 32px;
  background: var(--header-bg);
  color: var(--header-fg);
  border-bottom: 1px solid var(--header-rule);
  transition: background 0.35s ease, color 0.35s ease, border-color 0.35s ease;
}
.site-header.is-transparent {
  background: transparent;
  color: var(--cream);
  border-bottom-color: transparent;
}
.site-header.is-split {
  background: linear-gradient(to right, var(--cream) 0 50%, var(--black) 50% 100%);
  color: #fff;
  isolation: isolate;
}
.site-header.is-split .brand-mark,
.site-header.is-split .nav-main a,
.site-header.is-split .lang-toggle button,
.site-header.is-split .lang-toggle .sep {
  color: #fff;
  mix-blend-mode: difference;
}
.site-header.is-split .nav-main a.active::after {
  background: #fff;
  mix-blend-mode: difference;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-mark {
  display: block;
  width: 132px;
  height: 28px;
  background-color: currentColor;
  -webkit-mask: url("../assets/logo-white.png") no-repeat left center / contain;
  mask: url("../assets/logo-white.png") no-repeat left center / contain;
  transition: background-color 0.3s ease;
}

.nav-main {
  display: flex;
  gap: 28px;
  justify-self: center;
}
.nav-main a {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 6px 2px;
  position: relative;
  opacity: 0.78;
  transition: opacity 0.2s;
}
.nav-main a:hover { opacity: 1; }
.nav-main a.active {
  opacity: 1;
}
.nav-main a.active::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -2px;
  height: 2px;
  background: var(--burgundy);
}

.lang-toggle {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.16em;
}
.lang-toggle button {
  padding: 6px 9px;
  opacity: 0.5;
  text-transform: uppercase;
  transition: opacity 0.2s;
}
.lang-toggle button.active {
  opacity: 1;
  color: var(--burgundy);
}
.lang-toggle .sep {
  opacity: 0.3;
}

/* ============================================================
   Footer
   ============================================================ */
.site-footer {
  background: var(--black);
  color: var(--cream);
  padding: 60px 32px 32px;
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr 1.2fr 1fr;
  gap: 40px;
  font-size: 14px;
}
.site-footer .foot-mark {
  font-family: var(--font-display);
  font-size: 38px;
  letter-spacing: 0.02em;
  text-transform: lowercase;
  line-height: 0.9;
}
.site-footer .foot-mark .accent { color: var(--burgundy); }
.site-footer h4 {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 14px;
  opacity: 0.55;
  font-weight: 500;
}
.site-footer ul { list-style: none; display: grid; gap: 8px; }
.site-footer a:hover { color: var(--burgundy); }
.site-footer .foot-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.4;
  margin-top: 14px;
}
.site-footer .foot-bottom {
  grid-column: 1 / -1;
  border-top: 1px solid var(--rule-dark);
  padding-top: 22px;
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.5;
}

@media (max-width: 880px) {
  .site-footer {
    grid-template-columns: 1fr 1fr;
    padding: 48px 24px 24px;
    gap: 32px 24px;
    font-size: 13px;
  }
  .site-footer > div:first-child {
    grid-column: 1 / -1;
    border-bottom: 1px solid var(--rule-dark);
    padding-bottom: 28px;
    margin-bottom: 0;
  }
  .site-footer .foot-mark { font-size: 44px; }
  .site-footer .foot-bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    font-size: 10px;
    padding-top: 18px;
  }
}
@media (max-width: 480px) {
  .site-footer { grid-template-columns: 1fr; gap: 28px; }
  .site-footer > div { padding-bottom: 0; }
}

/* ============================================================
   Generic page sections
   ============================================================ */
.page-pad-top { padding-top: 96px; }

.section-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  opacity: 0.65;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.section-eyebrow::before {
  content: "";
  width: 28px;
  height: 1px;
  background: currentColor;
  opacity: 0.6;
}

.h-display {
  font-family: var(--font-display);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.005em;
  line-height: 0.92;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 22px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  border: 1px solid currentColor;
  transition: background 0.2s ease, color 0.2s ease;
}
.btn:hover { background: var(--burgundy); color: var(--cream); border-color: var(--burgundy); }
.btn.solid {
  background: var(--burgundy);
  color: var(--cream);
  border-color: var(--burgundy);
}
.btn.solid:hover { background: var(--burgundy-deep); border-color: var(--burgundy-deep); }
.btn .arrow { font-family: var(--font-body); font-size: 14px; letter-spacing: 0; }

/* ============================================================
   Mobile menu toggle — clean 3-line burger, right-aligned
   The toggle is appended directly to <body> by site.js, NOT to the
   header, so its z-index isn't capped by the header's stacking context.
   On desktop it stays display:none.
   ============================================================ */
.menu-toggle {
  display: none;
  position: fixed;
  top: 14px;
  right: 18px;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  z-index: 100;
  background: transparent;
}
.menu-toggle .mt-bars {
  position: relative;
  width: 24px;
  height: 14px;
}
.menu-toggle .mt-bar {
  position: absolute;
  left: 0;
  height: 1.5px;
  background: currentColor;
  width: 100%;
  border-radius: 1px;
  transition:
    transform 0.35s cubic-bezier(0.65, 0.05, 0.2, 1),
    opacity 0.2s ease,
    background 0.2s ease,
    width 0.35s ease,
    left 0.35s ease,
    top 0.35s ease;
}
.menu-toggle .mt-bar.b1 { top: 0; }
.menu-toggle .mt-bar.b2 { top: 6px; width: 60%; background: var(--burgundy); }
.menu-toggle .mt-bar.b3 { top: 12px; }
.menu-toggle:hover .mt-bar.b2 { width: 100%; }

/* Open state: clean X. Bar 1 + bar 3 cross, bar 2 fades out. */
.menu-toggle.is-open .mt-bar.b1 {
  top: 6px;
  transform: rotate(45deg);
  background: var(--burgundy);
}
.menu-toggle.is-open .mt-bar.b2 {
  opacity: 0;
  width: 0;
  left: 50%;
}
.menu-toggle.is-open .mt-bar.b3 {
  top: 6px;
  transform: rotate(-45deg);
  background: var(--burgundy);
}
/* When the menu's dark half covers the burger, keep it visible against black */
body.menu-open .menu-toggle { color: var(--cream); }
body.menu-open .menu-toggle.is-open .mt-bar.b1,
body.menu-open .menu-toggle.is-open .mt-bar.b3 { background: var(--burgundy); }

/* Full-screen mobile menu — two-world tear (matches the home hero rip) */
.mobile-menu {
  position: fixed;
  inset: 0;
  z-index: 85;
  pointer-events: none;
  /* Always in DOM/rendered: avoids visibility-hidden transition quirk where the
     first click didn't animate. The halves sit fully off-screen until is-open. */
  display: none;
}
.mobile-menu.is-prepped { display: block; }
.mobile-menu.is-open { pointer-events: auto; }

.mm-half {
  position: absolute;
  left: 0;
  width: 100%;
  /* Halves are 55% tall and overlap by 10vh in the middle — that overlap is
     where the torn-paper edges interlock. */
  height: 55%;
  overflow: hidden;
  will-change: transform;
  transition: transform 1.4s cubic-bezier(0.72, 0.02, 0.18, 1);
  transform-origin: center;
  filter: drop-shadow(0 4px 16px rgba(0,0,0,0.18));
}
.mm-top {
  top: 0;
  background: var(--black);
  color: var(--cream);
  transform: translateY(-115%) rotate(-1.8deg);
  /* clip-path is set dynamically by site.js so the two halves share one
     ragged centerline (real interlocking torn-paper look) */
}
.mm-bot {
  bottom: 0;
  background: var(--cream);
  color: var(--ink);
  transform: translateY(115%) rotate(1.8deg);
  /* clip-path set by site.js — see above */
}
.mobile-menu.is-open .mm-top { transform: translateY(0) rotate(0deg); }
.mobile-menu.is-open .mm-bot { transform: translateY(0) rotate(0deg); }

/* The burgundy thread is now just a thin highlight along the tear line — the
   real visual interest is the interlocking clip-paths on the two halves. */
.mm-thread {
  position: absolute;
  left: 0; right: 0;
  top: 50%;
  height: 2px;
  background: var(--burgundy);
  transform: translateY(-50%) scaleX(0);
  transform-origin: center;
  transition: transform 0.7s cubic-bezier(0.65, 0.05, 0.2, 1) 0.65s,
              opacity 0.25s ease;
  z-index: 3;
  opacity: 0.85;
}
.mobile-menu.is-open .mm-thread { transform: translateY(-50%) scaleX(1); }
.mobile-menu:not(.is-open) .mm-thread {
  transition: transform 0.2s ease, opacity 0.1s;
  opacity: 0;
}

/* Menu content */
.mm-content {
  position: relative;
  height: 100%;
  padding: 80px 28px 28px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
/* Halves are now 55vh tall and overlap 10vh in the middle. Push content away
   from the ragged-edge zone so no character gets clipped by a tooth. */
.mm-top .mm-content { padding-bottom: 18vh; justify-content: flex-end; }
.mm-bot .mm-content { padding-top: 18vh; justify-content: flex-start; }
.mm-eye {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  opacity: 0.55;
  margin-bottom: 22px;
  display: flex; align-items: center; gap: 10px;
}
.mm-eye .sq { width: 8px; height: 8px; background: var(--burgundy); }

.mm-links {
  list-style: none;
  display: grid;
  gap: 4px;
}
.mm-links li { opacity: 0; transform: translateY(14px); transition: opacity 0.5s, transform 0.5s; }
.mobile-menu.is-open .mm-links li { opacity: 1; transform: translateY(0); }
.mobile-menu.is-open .mm-links li:nth-child(1) { transition-delay: 0.4s; }
.mobile-menu.is-open .mm-links li:nth-child(2) { transition-delay: 0.48s; }
.mobile-menu.is-open .mm-links li:nth-child(3) { transition-delay: 0.56s; }
.mobile-menu.is-open .mm-links li:nth-child(4) { transition-delay: 0.64s; }
.mobile-menu.is-open .mm-links li:nth-child(5) { transition-delay: 0.72s; }
.mm-links a {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 6px 0;
  font-family: var(--font-display);
  font-size: 38px;
  text-transform: uppercase;
  letter-spacing: 0.005em;
  line-height: 1;
}
.mm-links a .mm-num {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--burgundy);
  flex-shrink: 0;
  width: 26px;
  transform: translateY(-4px);
}
.mm-links a.active { color: var(--burgundy); }

.mm-foot {
  margin-top: 26px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  opacity: 0.65;
}
.mm-lang { display: inline-flex; gap: 0; }
.mm-lang button {
  padding: 6px 8px;
  color: inherit;
  opacity: 0.5;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.mm-lang button.active { opacity: 1; color: var(--burgundy); }
.mm-lang .sep { opacity: 0.3; align-self: center; }

@media (max-width: 880px) {
  .menu-toggle { display: inline-flex; }
  /* Hide desktop nav + lang on mobile */
  .site-header .nav-main,
  .site-header .lang-toggle { display: none; }
  .site-header { grid-template-columns: 1fr; padding-right: 76px; }
  body.menu-open { overflow: hidden; }
  body.menu-open .site-header { background: transparent; border-bottom-color: transparent; }
}

/* ============================================================
   Tweaks panel (vanilla)
   ============================================================ */
#tweaks-panel {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 300px;
  background: #fefdf6;
  color: var(--ink);
  border: 1px solid rgba(0,0,0,0.12);
  box-shadow: 0 16px 40px rgba(0,0,0,0.18), 0 2px 6px rgba(0,0,0,0.1);
  z-index: 200;
  font-family: var(--font-body);
  display: none;
  max-height: calc(100vh - 36px);
  overflow: auto;
}
#tweaks-panel.is-open { display: block; }
#tweaks-panel .tp-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(0,0,0,0.08);
  background: #f3f1e6;
  position: sticky;
  top: 0;
  z-index: 2;
}
#tweaks-panel .tp-title {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.22em;
}
#tweaks-panel .tp-close {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border-radius: 50%;
  opacity: 0.6;
}
#tweaks-panel .tp-close:hover { opacity: 1; background: rgba(0,0,0,0.05); }
#tweaks-panel .tp-section {
  padding: 14px 14px 16px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
#tweaks-panel .tp-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  opacity: 0.6;
  margin-bottom: 8px;
  display: block;
}
#tweaks-panel .tp-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(56px, 1fr));
  gap: 6px;
}
#tweaks-panel .tp-chip {
  padding: 8px 10px;
  border: 1px solid rgba(0,0,0,0.15);
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  text-align: center;
  background: #fff;
  transition: all 0.15s;
}
#tweaks-panel .tp-chip:hover { border-color: var(--ink); }
#tweaks-panel .tp-chip.active {
  background: var(--ink);
  color: #fefdf6;
  border-color: var(--ink);
}
#tweaks-panel .tp-swatches {
  display: flex; gap: 6px; flex-wrap: wrap;
}
#tweaks-panel .tp-sw {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2px solid #fff;
  outline: 1px solid rgba(0,0,0,0.15);
  cursor: pointer;
  transition: transform 0.15s;
}
#tweaks-panel .tp-sw:hover { transform: scale(1.08); }
#tweaks-panel .tp-sw.active {
  outline-color: var(--ink);
  outline-width: 2px;
}
#tweaks-panel .tp-slider {
  width: 100%;
  accent-color: var(--burgundy);
}
#tweaks-panel .tp-value {
  font-family: var(--font-mono);
  font-size: 10px;
  opacity: 0.55;
  float: right;
}
