/* Current symbol ink (#835 r6b, set by sigils-ui.js sgSetInk); registered so it transitions as a colour. */
@property --sg-ink-cur {
  syntax: '<color>';
  inherits: true;
  initial-value: #ece6da;
}
/* Background tint target: the current ink, except the logo (CLARITY keeps its primaries on neutral black). */
@property --sg-tint-cur {
  syntax: '<color>';
  inherits: true;
  initial-value: #ece6da;
}
:root {
  --sg-ink-cur: #ece6da;
  --sg-tint-cur: #ece6da;
  /* The page black leans 3% toward the current tint (r6b); scene.js does the same for the WebGL black. */
  --sg-bg: color-mix(in srgb, #060505 97%, var(--sg-tint-cur));
  transition: --sg-ink-cur 1.2s ease, --sg-tint-cur 1.2s ease;
  --sg-ink: #ece6da;
  --sg-ink-dim: #b3ab9d;
  --sg-line: rgba(236, 230, 218, 0.22);
  --sg-focus: #f6d21f;
  --sg-error: #f0a493;
  --sg-ok: #b9d8a8;
  /* Official Painter Studio face (#835 r6c, studio summary doc): Montserrat 400/500/600 only. */
  --sg-font: "Montserrat", system-ui, "Segoe UI", sans-serif;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

/* Native scroll (#835 r6a): one snap stop per full-height section; the fixed canvas follows it. */
html {
  scroll-snap-type: y mandatory;
  scrollbar-width: thin;
  scrollbar-color: #26221e transparent;
}
html, body {
  margin: 0;
  background: var(--sg-bg);
}
/* Nothing behind the open contact dialog scrolls (PageDown on the dialog scrolled the root, r6a run). */
html:has(.sg-dialog[open]) { overflow: hidden; }
.sg-section {
  height: 100svh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}
.sg-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

body {
  color: var(--sg-ink);
  font: 400 13px/1.5 var(--sg-font);
  -webkit-font-smoothing: antialiased;
}

a, button { color: inherit; }
:focus-visible { outline: 2px solid var(--sg-focus); outline-offset: 3px; }

/* The canvas is the page. */
#sg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
  touch-action: pan-y pinch-zoom;
}
/* Unused since r6d (reduced motion dissolves in the scene, scene.js advanceReduced); kept for old caches. */
.sg-fade {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.sg-fade.is-on { opacity: 1; }

/* Breathing frame (#835 r6b, after hermes-agent's 42 s light border): an inset glow in the current ink whose
   opacity alone animates (compositor only), 0.03 -> 0.07 -> 0.03 over 24 s. */
.sg-frame {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  box-shadow: inset 0 0 80px var(--sg-ink-cur);
  opacity: 0.03;
  will-change: opacity;
  animation: sg-frame-breathe 24s ease-in-out infinite;
}
@keyframes sg-frame-breathe {
  0%, 100% { opacity: 0.03; }
  50% { opacity: 0.07; }
}
html.sg-no-webgl .sg-frame { display: none; }

/* Ghost wordmark (#835 r6b): last section only, 4% behind the symbol. Montserrat 400 is the loaded face; the
   horizontal squeeze stands in for a condensed cut (no new font family). `lighten` keeps every grain brighter
   than the 4% grey untouched, so the type reads as behind the dust. */
.sg-ghostmark {
  position: fixed;
  left: 50%;
  top: 64%;
  z-index: 2;
  pointer-events: none;
  /* r6c: 22vw -> 19vw, Montserrat is wider than the r6b face and ran edge to edge at 1920. */
  font: 400 19vw/1 var(--sg-font);
  letter-spacing: -0.04em;
  white-space: nowrap;
  color: #ece6da;
  mix-blend-mode: lighten;
  transform: translate(-50%, -50%) scaleX(0.56);
  opacity: 0;
  transition: opacity 2s ease;
}
.sg-ghostmark.is-on { opacity: 0.03; }
/* Portrait: below the symbol, above the legend. */
@media (max-aspect-ratio: 1/1) { .sg-ghostmark { top: 68%; } }
html:not(.sg-live) .sg-ghostmark { display: none; }

/* Poster: shown without JS, without WebGL2, or when three.js never loads. */
.sg-poster {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: grid;
  place-items: center;
  padding: 72px 24px 110px;
  background: radial-gradient(ellipse 60% 55% at 50% 46%, #11100e, var(--sg-bg) 72%);
}
html.sg-js:not(.sg-no-webgl) .sg-poster { display: none; }
.sg-poster-logo {
  position: relative;
  width: min(44vw, 52vh * 1.26, 520px);
  aspect-ratio: 567 / 450;
  background: #1f1f1f;
}
.sg-poster-logo i { position: absolute; display: block; }
.sg-b1 { left: 3.175%; top: 3.333%; width: 46.56%; height: 35.78%; background: #f6d21f; }
.sg-b2 { left: 52.38%; top: 3.333%; width: 11.99%; height: 50.67%; background: #3b7fd0; }
.sg-b3 { left: 67.02%; top: 3.333%; width: 29.98%; height: 14.89%; background: #f2f2f0; }
.sg-b4 { left: 67.02%; top: 21.33%; width: 29.98%; height: 32.67%; background: #e0301e; }
.sg-b5 { left: 3.175%; top: 41.78%; width: 28.57%; height: 28.44%; background: #f2f2f0; }
.sg-b6 { left: 3.175%; top: 73.56%; width: 28.57%; height: 23.11%; background: #3b7fd0; }
.sg-b7 { left: 34.22%; top: 56.67%; width: 62.79%; height: 40%; background: #f2f2f0; }
@media (max-width: 600px) {
  .sg-poster-logo { width: min(78vw, 360px); }
}

/* Header (#835 mobile polish): one row edge to edge, wordmark and OST button on the same centre line
   (they were 4 px apart, tmp/zerg-835/layout-audit.mjs). Side gutters clear the phone's safe area. */
.sg-top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: max(14px, env(safe-area-inset-top, 0px)) max(26px, env(safe-area-inset-right, 0px)) 0 max(26px, env(safe-area-inset-left, 0px));
  pointer-events: none;
}
.sg-top > * { pointer-events: auto; }
.sg-wordmark {
  font: 600 12px/1 var(--sg-font);
  letter-spacing: 0.34em;
  text-decoration: none;
  color: var(--sg-ink);
  padding: 12px 0;
}

/* Studio OST button: icon only (play / stop) in a thin ring that fills with the track's progress, since it
   plays once. 44 x 44 hit area; the drawn ring is 28 px. */
.sg-music {
  --sg-music-p: 0;
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-right: -8px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--sg-ink-dim);
  cursor: pointer;
  transition: color 0.35s ease;
  -webkit-tap-highlight-color: transparent;
}
.sg-music-icon { width: 28px; height: 28px; overflow: visible; transition: transform 0.15s ease; }
/* Ring at 0.55: ~3.5:1 against the canvas (WCAG 1.4.11 for control outlines); the glyph itself is ~8.6:1. */
.sg-music-ring { fill: none; stroke: currentColor; stroke-width: 1.25; opacity: 0.55; transition: opacity 0.35s ease; }
.sg-music-progress {
  fill: none; stroke: var(--sg-ink); stroke-width: 1.25; stroke-linecap: round;
  stroke-dasharray: 100; stroke-dashoffset: calc(100 - var(--sg-music-p));
  transform: rotate(-90deg); transform-origin: 16px 16px; opacity: 0; transition: opacity 0.35s ease;
}
.sg-music-play, .sg-music-stop { fill: currentColor; transition: opacity 0.25s ease, transform 0.25s ease; transform-origin: 16px 16px; }
.sg-music-stop { opacity: 0; transform: scale(0.6); }
.sg-music:hover, .sg-music:focus-visible { color: var(--sg-ink); }
.sg-music:hover .sg-music-ring, .sg-music:focus-visible .sg-music-ring { opacity: 0.8; }
.sg-music:focus-visible { outline: 2px solid var(--sg-ink); outline-offset: 0; }
.sg-music:active .sg-music-icon { transform: scale(0.94); }
.sg-music[aria-pressed="true"] { color: var(--sg-ink); }
.sg-music[aria-pressed="true"] .sg-music-ring { opacity: 0.25; }
.sg-music[aria-pressed="true"] .sg-music-progress { opacity: 1; }
.sg-music[aria-pressed="true"] .sg-music-play { opacity: 0; transform: scale(0.6); }
.sg-music[aria-pressed="true"] .sg-music-stop { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .sg-music-icon, .sg-music-play, .sg-music-stop, .sg-music-ring, .sg-music-progress { transition: none; }
}

/* Legend: the current symbol's caption, and the studio line only while `studio` is formed. */
.sg-legend {
  position: fixed;
  left: 0;
  right: 0;
  /* Owner (2026-10-20): marks and caption sit higher, closer to the symbol, clear of the footer. */
  bottom: clamp(96px, 15vh, 170px);
  z-index: 2;
  text-align: center;
  pointer-events: none;
}
.sg-caption, .sg-tagline {
  margin: 0;
  opacity: 0;
  transition: opacity 1.1s ease;
}
/* The caption names the studio value or game: the one word with weight on the page (owner, 2026-10-20). */
.sg-caption {
  --sg-track: 0.42em;
  font: 600 clamp(14px, 1.15vw, 18px)/1 var(--sg-font);
  letter-spacing: var(--sg-track);
  padding-left: var(--sg-track);
  color: var(--sg-ink);
}
/* Arrival (#835 r6b): the current caption contracts from 0.6em into its tracking over 1.1 s. */
#sg-caption { transition: opacity 0.7s ease, letter-spacing 1.1s cubic-bezier(0.22, 1, 0.36, 1), padding-left 1.1s cubic-bezier(0.22, 1, 0.36, 1); }
#sg-caption.is-wide { letter-spacing: 0.6em; padding-left: 0.6em; }
.sg-tagline {
  font: 400 12px/1.4 var(--sg-font);
  letter-spacing: 0.02em;
  color: var(--sg-ink-dim);
  margin-bottom: 12px;
}
.sg-caption.is-on { opacity: 0.96; }
.sg-tagline.is-on { opacity: 1; }
html:not(.sg-js) .sg-caption, html:not(.sg-js) .sg-tagline { opacity: 0.86; }
/* Crossfade (#835 r4): the ghost holds the outgoing caption on top of the live one. */
.sg-captions { display: grid; }
.sg-captions > .sg-caption { grid-area: 1 / 1; transition-duration: 0.7s; }
.sg-caption-ghost { pointer-events: none; }
.is-instant { transition: none !important; }
.sg-captions { position: relative; }

/* Scroll hint (#835 r6a): a 1 x 22 px line with a dot sliding down it, gone after the first scroll. No text.
   Since the studio opens the page (owner, 2026-10-21) it sits under the CLARITY caption. */
.sg-hint {
  position: absolute;
  left: 50%;
  top: calc(100% + 10px);
  width: 1px;
  height: 22px;
  background: rgba(236, 230, 218, 0.16);
  opacity: 0;
  transition: opacity 0.7s ease;
}
.sg-hint.is-on { opacity: 1; }
.sg-hint.is-gone { opacity: 0; }
.sg-hint::after {
  content: "";
  position: absolute;
  left: -1px;
  top: 0;
  width: 3px;
  height: 3px;
  background: var(--sg-ink-dim);
  animation: sg-hint-drop 2.4s ease-in-out infinite;
}
@keyframes sg-hint-drop {
  0% { transform: translateY(0); opacity: 0; }
  20% { opacity: 1; }
  80% { opacity: 1; }
  100% { transform: translateY(19px); opacity: 0; }
}

/* Indicator (#835 r4; r6a: seven marks, 44 px touch targets): 8 px tiles on a grout ring. */
.sg-marks {
  display: flex;
  justify-content: center;
  margin: -10px 0 -2px;
  pointer-events: auto;
}
html:not(.sg-live) .sg-marks { visibility: hidden; }
.sg-mark {
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.sg-mark::before {
  content: "";
  width: 8px;
  height: 8px;
  border: 1px solid var(--sg-mark);
  box-shadow: 0 0 0 2px #26221e;
  opacity: 0.55;
  transition: background-color 0.5s ease, opacity 0.5s ease;
}
.sg-mark:hover::before { opacity: 1; }
.sg-mark.is-current::before { background: var(--sg-mark); opacity: 1; }
.sg-mark:focus-visible { outline-offset: -2px; }

.sg-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding: 14px 12px 18px;
  white-space: nowrap;
  font: 400 12px/1.4 var(--sg-font);
  color: var(--sg-ink-dim);
}
.sg-footer a { text-decoration: none; padding: 4px 0; }
.sg-footer a:hover { color: var(--sg-ink); text-decoration: underline; text-underline-offset: 3px; }
.sg-dot { color: #6f685d; }
.sg-lang {
  font: inherit;
  background: none;
  border: 0;
  padding: 4px 0;
  cursor: pointer;
  color: var(--sg-ink-dim);
}
.sg-lang .is-active { color: var(--sg-ink); text-decoration: underline; text-underline-offset: 3px; }
.sg-lang:hover { color: var(--sg-ink); }

@media (max-width: 480px) {
  .sg-top { padding-left: max(18px, env(safe-area-inset-left, 0px)); padding-right: max(18px, env(safe-area-inset-right, 0px)); padding-top: max(8px, env(safe-area-inset-top, 0px)); }
  .sg-wordmark { font-size: 12px; letter-spacing: 0.28em; }
  .sg-footer { gap: 6px; font-size: 11px; padding: 12px 6px 16px; }
  /* Phones: the legend sits just above the footer; the symbol band above it gets the height (layout audit). */
  .sg-legend { bottom: calc(env(safe-area-inset-bottom, 0px) + clamp(76px, 9.5vh, 92px)); }
  .sg-caption { font-size: 13px; --sg-track: 0.36em; }
  #sg-caption.is-wide { letter-spacing: 0.5em; padding-left: 0.5em; }
  .sg-tagline { font-size: 11px; padding: 0 24px; }
}

/* Contact dialog: nothing but the form. */
.sg-dialog {
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow: auto;
  padding: 26px 26px 20px;
  border: 1px solid var(--sg-line);
  background: #110f0d;
  color: var(--sg-ink);
}
.sg-dialog::backdrop { background: rgba(3, 3, 2, 0.7); }
.sg-dialog-title {
  margin: 0 0 18px;
  font: 500 12px/1 var(--sg-font);
  letter-spacing: 0.34em;
  text-transform: uppercase;
}
.sg-form { display: grid; gap: 14px; }
.sg-field { display: grid; gap: 6px; font-size: 13px; color: #d2cbbe; }
.sg-field input, .sg-field select, .sg-field textarea {
  width: 100%;
  font: 400 14px/1.4 var(--sg-font);
  color: var(--sg-ink);
  background: #1a1714;
  border: 1px solid #5a5348;
  border-radius: 2px;
  padding: 9px 10px;
}
.sg-field textarea { resize: vertical; min-height: 96px; }
.sg-field input:focus-visible, .sg-field select:focus-visible, .sg-field textarea:focus-visible {
  outline: 2px solid var(--sg-focus);
  outline-offset: 1px;
}
.sg-turnstile {
  width: 300px;
  max-width: 100%;
  height: 65px;
  display: grid;
  place-items: center;
  border: 1px dashed #7a7266;
  color: var(--sg-ink-dim);
  font: 400 12px/1 var(--sg-font);
}
.sg-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.sg-send, .sg-close {
  font: 500 13px/1 var(--sg-font);
  padding: 11px 16px;
  border-radius: 2px;
  cursor: pointer;
}
.sg-send { background: var(--sg-ink); color: #111; border: 1px solid var(--sg-ink); }
.sg-send:disabled { opacity: 0.6; cursor: progress; }
.sg-close { background: transparent; color: var(--sg-ink); border: 1px solid #5a5348; }
.sg-status { margin: 0; min-height: 1.4em; font-size: 13px; }
.sg-status.is-ok { color: var(--sg-ok); }
.sg-status.is-error { color: var(--sg-error); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  /* r6d: captions crossfade and the frame keeps breathing (opacity only); only travel is removed. */
  #sg-caption, .sg-captions > .sg-caption, .sg-tagline { transition: opacity 0.6s ease; }
  .sg-ghostmark { transition: none; }
  .sg-hint::after { animation: none; top: 9px; }
}

/* Contact honeypot (#835): off-screen, never focusable by people. */
.sg-hp { position: absolute; left: -10000px; width: 1px; height: 1px; opacity: 0; }

/* QA r6 (#835): the Turnstile box is labelled only in the prototype; on the site the widget fills it and no
   English placeholder flashes in the Portuguese dialog. */
:root:not([data-sg-turnstile]) .sg-turnstile::before { content: "Turnstile check"; }
/* No WebGL = poster only: the symbol sections would be an empty scroll the wheel cannot leave (QA r6). */
.sg-no-webgl .sg-section { display: none; }
.sg-no-webgl { scroll-snap-type: none; }

/* Portrait tablets (#835 layout audit: 768x1024 left ~25% empty under the legend): same low legend as phones. */
@media (orientation: portrait) and (min-width: 601px) and (max-width: 1100px) {
  .sg-legend { bottom: calc(env(safe-area-inset-bottom, 0px) + clamp(84px, 9vh, 110px)); }
}
