/* ==========================================================================
   Appica — shared design system
   Used by every page. Page-specific styles live in home.css / doc.css.
   ========================================================================== */

:root {
  --ink: #09090b;
  --ink-2: #121215;
  --ink-3: #1b1b20;
  --paper: #f1ede4;
  --paper-dim: rgba(241, 237, 228, 0.6);
  --paper-faint: rgba(241, 237, 228, 0.34);
  --line: rgba(241, 237, 228, 0.12);
  --line-strong: rgba(241, 237, 228, 0.24);

  /* The five app colours, used together as the studio's signature */
  --c-reel: #ff4f9a;
  --c-legends: #f0b93a;
  --c-whoami: #ef8f74;
  --c-gambits: #6fe3ff;
  --c-dice: #39d98a;
  --iri: linear-gradient(100deg, #ff4f9a 0%, #f0b93a 28%, #ef8f74 48%, #6fe3ff 72%, #39d98a 100%);

  --serif: "Instrument Serif", ui-serif, Georgia, "Times New Roman", serif;
  --sans: "Inter Tight", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-io: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-back: cubic-bezier(0.34, 1.56, 0.64, 1);

  --pad: clamp(20px, 4.2vw, 64px);
  --max: 1440px;
  --radius: 22px;

  --bg: var(--ink);
  --fg: var(--paper);
  --fg-dim: var(--paper-dim);
  --rule: var(--line);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}

img, svg, canvas, video { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
::selection { background: var(--paper); color: var(--ink); }

:focus-visible { outline: 2px solid currentColor; outline-offset: 4px; border-radius: 6px; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: fixed; top: 12px; left: 12px; z-index: 1000;
  padding: 10px 16px; border-radius: 999px; background: var(--paper); color: var(--ink);
  transform: translateY(-200%); transition: transform 0.3s var(--ease);
}
.skip-link:focus { transform: none; }

/* ----- Type primitives ---------------------------------------------------- */

.eyebrow, .label {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-dim);
}
.label::before { content: "("; } .label::after { content: ")"; }

.display {
  font-family: var(--sans);
  font-weight: 600;
  letter-spacing: -0.045em;
  line-height: 0.92;
}
em, .serif-i { font-family: var(--serif); font-style: italic; font-weight: 400; letter-spacing: -0.02em; }

.iri-text {
  background: var(--iri);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}

/* ----- Grain overlay ------------------------------------------------------ */

.grain {
  pointer-events: none;
  position: fixed; inset: -60px;
  z-index: 90;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 0.9s steps(5) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); } 20% { transform: translate(-34px, 22px); } 40% { transform: translate(24px, -40px); }
  60% { transform: translate(-44px, -20px); } 80% { transform: translate(32px, 44px); } 100% { transform: translate(0, 0); }
}
/* Touch devices: keep the texture, skip the flicker (saves battery) */
@media (pointer: coarse) { .grain { animation: none; } }

/* ----- Custom cursor (fine pointers only) -------------------------------- */

.cursor { display: none; }
@media (pointer: fine) {
  html.has-cursor, html.has-cursor * { cursor: none !important; }
  html.has-cursor input, html.has-cursor textarea { cursor: text !important; }
  .cursor {
    display: block; pointer-events: none;
    position: fixed; top: 0; left: 0; z-index: 9999;
    mix-blend-mode: difference;
  }
  .cursor__dot, .cursor__ring {
    position: absolute; top: 0; left: 0; border-radius: 50%;
    background: #fff;
    will-change: transform;
  }
  .cursor__dot { width: 6px; height: 6px; margin: -3px 0 0 -3px; }
  .cursor__ring {
    width: 38px; height: 38px; margin: -19px 0 0 -19px;
    background: transparent; border: 1px solid #fff;
    transition: width 0.45s var(--ease), height 0.45s var(--ease), margin 0.45s var(--ease), background-color 0.3s, border-color 0.3s;
    display: grid; place-items: center;
  }
  .cursor__label {
    font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
    color: #000; opacity: 0; transition: opacity 0.2s;
  }
  .cursor.is-hover .cursor__ring { width: 64px; height: 64px; margin: -32px 0 0 -32px; }
  .cursor.is-label .cursor__ring { width: 88px; height: 88px; margin: -44px 0 0 -44px; background: #fff; }
  .cursor.is-label .cursor__label { opacity: 1; }
  .cursor.is-label .cursor__dot { opacity: 0; }
  .cursor.is-text .cursor__ring { width: 4px; height: 30px; margin: -15px 0 0 -2px; border-radius: 2px; background: #fff; }
  .cursor.is-hidden { opacity: 0; }
}

/* ----- Page transition curtain ------------------------------------------- */

.curtain {
  position: fixed; inset: 0; z-index: 500; pointer-events: none;
  display: grid; place-items: center;
  background: var(--ink);
  transform: translateY(0);
  animation: curtain-out 1s var(--ease-io) 0.1s forwards;
}
.curtain__mark { width: 56px; height: 56px; color: var(--paper); opacity: 1; animation: fade-out 0.4s ease 0.1s forwards; }
.curtain.is-leaving {
  animation: curtain-in 0.7s var(--ease-io) forwards;
  transform: translateY(100%);
}
.curtain.is-leaving .curtain__mark { animation: none; opacity: 0; }
@keyframes curtain-out { to { transform: translateY(-101%); } }
@keyframes curtain-in { from { transform: translateY(101%); } to { transform: translateY(0); } }
@keyframes fade-out { to { opacity: 0; } }

/* ----- Navigation --------------------------------------------------------- */

.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 22px var(--pad);
  color: #fff;
  mix-blend-mode: difference;
  transition: transform 0.6s var(--ease);
}
.nav.is-hidden { transform: translateY(-120%); }

.brand { display: inline-flex; align-items: center; gap: 12px; font-weight: 600; letter-spacing: -0.02em; font-size: 19px; }
.brand__mark { width: 30px; height: 30px; flex: none; transition: transform 0.8s var(--ease); }
.brand:hover .brand__mark { transform: rotate(-90deg); }

.nav__now {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase;
  display: flex; align-items: center; gap: 10px;
  opacity: 0; transform: translateY(-6px);
  transition: opacity 0.5s var(--ease), transform 0.5s var(--ease);
}
.nav__now.is-on { opacity: 1; transform: none; }
.nav__now-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }
.nav__now-name { display: inline-block; min-width: 9ch; }

.nav__links { display: flex; align-items: center; gap: 30px; font-size: 15px; }
.nav__links a { position: relative; padding: 4px 0; }
.nav__links a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: currentColor;
  transform: scaleX(0); transform-origin: right; transition: transform 0.5s var(--ease);
}
.nav__links a:hover::after, .nav__links a[aria-current="page"]::after { transform: scaleX(1); transform-origin: left; }

.nav__toggle { display: none; width: 44px; height: 44px; position: relative; }
.nav__toggle span { position: absolute; left: 10px; right: 10px; height: 1.5px; background: currentColor; transition: transform 0.5s var(--ease), top 0.5s var(--ease); }
.nav__toggle span:nth-child(1) { top: 18px; }
.nav__toggle span:nth-child(2) { top: 25px; }
.menu-open .nav__toggle span:nth-child(1) { top: 21.5px; transform: rotate(45deg); }
.menu-open .nav__toggle span:nth-child(2) { top: 21.5px; transform: rotate(-45deg); }

.menu {
  position: fixed; inset: 0; z-index: 150;
  background: var(--ink); color: var(--paper);
  padding: 110px var(--pad) 40px;
  display: flex; flex-direction: column; justify-content: space-between;
  clip-path: inset(0 0 100% 0);
  transition: clip-path 0.8s var(--ease-io);
  visibility: hidden;
}
.menu-open .menu { clip-path: inset(0 0 0 0); visibility: visible; }
.menu__list { list-style: none; margin: 0; padding: 0; }
.menu__list a {
  display: flex; align-items: baseline; gap: 14px;
  font-size: clamp(40px, 11vw, 72px); font-weight: 600; letter-spacing: -0.045em; line-height: 1.05;
}
.menu__list small { font-family: var(--mono); font-size: 12px; font-weight: 400; letter-spacing: 0.05em; color: var(--paper-faint); }
.menu__foot { display: flex; justify-content: space-between; gap: 16px; font-size: 14px; color: var(--paper-dim); flex-wrap: wrap; }

@media (max-width: 860px) {
  .nav__links { display: none; }
  .nav__toggle { display: block; }
  .nav__now { display: none; }
}

/* ----- Buttons ------------------------------------------------------------ */

.btn {
  --b-bg: var(--fg); --b-fg: var(--bg);
  position: relative; isolation: isolate; overflow: hidden;
  display: inline-flex; align-items: center; gap: 12px;
  height: 54px; padding: 0 26px; border-radius: 999px;
  background: var(--b-bg); color: var(--b-fg);
  font-weight: 600; font-size: 15px; letter-spacing: -0.01em; white-space: nowrap;
  transition: transform 0.5s var(--ease);
}
.btn::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: var(--iri); transform: translateY(101%); transition: transform 0.6s var(--ease);
}
.btn:hover::before { transform: none; }
.btn:hover { color: #0a0a0a; }
.btn__arrow { width: 16px; height: 16px; transition: transform 0.5s var(--ease); }
.btn:hover .btn__arrow { transform: translateX(4px) rotate(-45deg); }
.btn--ghost { background: transparent; color: var(--fg); box-shadow: inset 0 0 0 1px currentColor; }
.btn--ghost::before { background: var(--fg); }
.btn--ghost:hover { color: var(--bg); }
.btn--sm { height: 42px; padding: 0 18px; font-size: 14px; }

.appstore {
  display: inline-flex; align-items: center; gap: 12px;
  height: 56px; padding: 0 22px 0 18px; border-radius: 16px;
  background: #000; color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.22);
  transition: transform 0.5s var(--ease), box-shadow 0.4s;
}
.appstore:hover { transform: translateY(-3px); box-shadow: inset 0 0 0 1px rgba(255,255,255,.5), 0 18px 40px -18px rgba(0,0,0,.7); }
.appstore svg { width: 22px; height: 22px; }
.appstore span { display: flex; flex-direction: column; line-height: 1.1; }
.appstore small { font-size: 10.5px; letter-spacing: 0.02em; opacity: 0.75; }
.appstore b { font-size: 18px; font-weight: 600; letter-spacing: -0.02em; }

/* ----- Reveal / split text (only when JS is running) ---------------------- */

.js [data-reveal] { opacity: 0; transform: translateY(36px); transition: opacity 1.1s var(--ease), transform 1.1s var(--ease); transition-delay: var(--d, 0s); }
.js [data-reveal].is-in { opacity: 1; transform: none; }
.js [data-reveal="fade"] { transform: none; }
.js [data-reveal="scale"] { transform: scale(0.94); }

.split-line { display: block; overflow: hidden; padding-bottom: 0.08em; margin-bottom: -0.08em; }
.split-word { display: inline-block; white-space: nowrap; }
.js [data-split] .split-inner { display: inline-block; transform: translateY(110%); transition: transform 1.2s var(--ease); transition-delay: calc(var(--i, 0) * 0.06s + var(--d, 0s)); }
.js [data-split].is-in .split-inner { transform: none; }

/* ----- Marquee ------------------------------------------------------------ */

.marquee { overflow: hidden; white-space: nowrap; display: flex; user-select: none; }
.marquee__track { display: flex; flex: none; animation: marquee var(--speed, 40s) linear infinite; }
.marquee:hover .marquee__track { animation-play-state: paused; }
@keyframes marquee { to { transform: translateX(-100%); } }

/* ----- Footer ------------------------------------------------------------- */

.footer {
  position: relative; z-index: 2;
  background: var(--ink); color: var(--paper);
  padding: clamp(80px, 12vw, 160px) var(--pad) 28px;
  overflow: hidden;
}
.footer__cta { display: grid; grid-template-columns: 1.2fr 1fr; gap: 40px; align-items: end; max-width: var(--max); margin: 0 auto; }
.footer__cta h2 { margin: 18px 0 0; font-size: clamp(44px, 7.4vw, 120px); }
.footer__cta p { margin: 0 0 26px; max-width: 34ch; color: var(--paper-dim); font-size: 18px; }
.footer__mail {
  display: inline-flex; align-items: center; gap: 14px;
  font-size: clamp(20px, 2.2vw, 30px); font-weight: 500; letter-spacing: -0.03em;
  padding-bottom: 6px; border-bottom: 1px solid var(--line-strong);
  transition: border-color 0.4s, gap 0.5s var(--ease);
}
.footer__mail:hover { border-color: var(--paper); gap: 22px; }
.footer__mail svg { width: 22px; height: 22px; }

.footer__grid {
  max-width: var(--max); margin: clamp(80px, 10vw, 140px) auto 0;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 32px;
  padding-top: 32px; border-top: 1px solid var(--line);
}
.footer__grid h3 { margin: 0 0 16px; font-family: var(--mono); font-weight: 400; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--paper-faint); }
.footer__grid ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.footer__grid a { color: var(--paper-dim); transition: color 0.3s; }
.footer__grid a:hover { color: var(--paper); }
.footer__clock { font-family: var(--mono); font-size: 13px; color: var(--paper-dim); }

.wordmark {
  max-width: var(--max); margin: clamp(60px, 8vw, 110px) auto 0;
  display: flex; justify-content: space-between;
  font-size: clamp(64px, 21.5vw, 340px); font-weight: 700; letter-spacing: -0.07em; line-height: 0.78;
  user-select: none;
}
.wordmark span {
  display: inline-block;
  transition: transform 0.8s var(--ease), color 0.5s;
  transform: translateY(var(--lift, 0));
}
.wordmark:hover span { color: var(--h, var(--paper)); }
.wordmark span:nth-child(1) { --h: var(--c-reel); }
.wordmark span:nth-child(2) { --h: var(--c-legends); }
.wordmark span:nth-child(3) { --h: var(--c-whoami); }
.wordmark span:nth-child(4) { --h: var(--c-gambits); }
.wordmark span:nth-child(5) { --h: var(--c-dice); }
.wordmark span:nth-child(6) { --h: var(--paper); }

.footer__base {
  max-width: var(--max); margin: 36px auto 0;
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  font-size: 13px; color: var(--paper-faint);
}

@media (max-width: 860px) {
  .footer__cta { grid-template-columns: 1fr; }
  .footer__grid { grid-template-columns: 1fr 1fr; }
}
