/* =====================================================================================
   0xhoard.xyz — kök vitrin.  KARAR-003 (The Unclosed Hoard) uygulaması.
   =====================================================================================
   Bu dosya `index.html` prototipinin <style> bloğundan çıkarıldı (DEBRIEF-01 §7.1).
   Ayrılmasının sebebi estetik değil: Caddy bloğu CSP'yi `style-src 'self'` ile veriyor ve
   `unsafe-inline` AÇILMIYOR ⇒ inline <style> servis edilemez.

   Prototipe göre iki DÜZELTME var, ikisi de yükleme anına ait ve görsel/hareket davranışını
   değiştirmiyor (DEBRIEF-01 §7.1'in "davranışı değiştirmeden" şartı):

   1. KOYU MODDA BEYAZ FLAŞ.  Prototip <html data-mode="light"> ile açılıyor ve koyu mod yalnız
      [data-mode="dark"] seçicisine bağlıydı ⇒ JS çalışana kadar koyu mod kullanıcısı kâğıt
      griyi görüyordu. Artık koyu tokenlar `prefers-color-scheme` medya sorgusunda da tanımlı,
      yani İLK BOYAMA doğru. JS'in yazdığı data-mode hâlâ üste yazar (özgüllük 0,1,1 > 0,1,0).

   2. İMLEÇSİZ KALMA.  `cursor: none` koşulsuzdu ama JS imleci `reduced-motion` altında HİÇ
      çizmiyor ⇒ hareket-azaltma açık masaüstü kullanıcısı tam ekran canvas üzerinde imleçsiz
      kalıyordu. Artık gizleme `.drawing-cursor` sınıfına bağlı ve o sınıfı JS, imleci
      GERÇEKTEN çizdiği koşulun aynısıyla ekliyor ⇒ ikisi ayrışamaz.
   ===================================================================================== */

:root {
  --paper: #eef0ec;
  --paper-solid: #f8f9f6;
  --ink: #101827;
  --ink-soft: #43506a;
  --muted: #7b8799;
  --faint: #a7afb9;
  --line: rgba(16, 24, 39, 0.13);
  --line-strong: rgba(16, 24, 39, 0.24);
  --display: "Avenir Next", "Helvetica Neue", "Segoe UI", Arial, sans-serif;
  --data: "SFMono-Regular", "SF Mono", "Roboto Mono", "Cascadia Code", ui-monospace, monospace;

  /* Zeminler token olarak duruyor ki koyu mod tek yerde tanımlansın ve medya sorgusu ile
     data-mode override'ı aynı satırları iki kez yazmak zorunda kalmasın. */
  --body-bg:
    repeating-linear-gradient(to bottom,
      transparent 0, transparent 3px, rgba(16, 24, 39, 0.018) 4px),
    var(--paper);
  --space-bg:
    repeating-linear-gradient(to bottom,
      transparent 0, transparent 3px, rgba(16, 24, 39, .012) 4px),
    radial-gradient(ellipse at 50% 50%, rgba(255, 255, 255, .16), transparent 48%),
    var(--paper);
}

/* Koyu tokenlar TEK yerde. Aşağıdaki iki seçici de buraya işaret eder. */
@media (prefers-color-scheme: dark) {
  :root:not([data-mode="light"]) {
    --paper: #07101b;
    --paper-solid: #0d1928;
    --ink: #edf2f2;
    --ink-soft: #a6b3c5;
    --muted: #718096;
    --faint: #536175;
    --line: rgba(220, 236, 239, 0.11);
    --line-strong: rgba(220, 236, 239, 0.22);
    --body-bg:
      repeating-linear-gradient(to bottom,
        transparent 0, transparent 3px, rgba(220, 236, 239, 0.022) 4px),
      var(--paper);
    --space-bg:
      repeating-linear-gradient(to bottom,
        transparent 0, transparent 3px, rgba(220, 236, 239, .012) 4px),
      radial-gradient(ellipse at 50% 48%, #02040a 0%, #02050b 38%, #050511 70%, #02040a 100%);
  }
}

html[data-mode="dark"] {
  --paper: #07101b;
  --paper-solid: #0d1928;
  --ink: #edf2f2;
  --ink-soft: #a6b3c5;
  --muted: #718096;
  --faint: #536175;
  --line: rgba(220, 236, 239, 0.11);
  --line-strong: rgba(220, 236, 239, 0.22);
  --body-bg:
    repeating-linear-gradient(to bottom,
      transparent 0, transparent 3px, rgba(220, 236, 239, 0.022) 4px),
    var(--paper);
  --space-bg:
    repeating-linear-gradient(to bottom,
      transparent 0, transparent 3px, rgba(220, 236, 239, .012) 4px),
    radial-gradient(ellipse at 50% 48%, #02040a 0%, #02050b 38%, #050511 70%, #02040a 100%);
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  min-height: 100%;
  overscroll-behavior: none;
}

html { background: var(--paper); }

body {
  margin: 0;
  min-height: 100svh;
  overflow: hidden;
  color: var(--ink);
  background: var(--body-bg);
  font-family: var(--display);
  transition: background-color 250ms ease, color 250ms ease;
}

.stage {
  position: relative;
  min-height: 100svh;
  isolation: isolate;
}

.space {
  position: absolute;
  z-index: 0;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  background: var(--space-bg);
}

.space::before,
.space::after {
  content: "";
  position: absolute;
  inset: -12%;
  pointer-events: none;
}

.space::before {
  opacity: .2;
  filter: blur(54px) saturate(125%);
  background:
    radial-gradient(ellipse 42% 58% at 8% 38%, rgba(40, 124, 142, .58), transparent 72%),
    radial-gradient(ellipse 36% 52% at 92% 30%, rgba(58, 71, 137, .48), transparent 72%),
    radial-gradient(ellipse 52% 34% at 72% 92%, rgba(128, 45, 118, .45), transparent 74%),
    radial-gradient(ellipse 38% 42% at 25% 88%, rgba(59, 43, 117, .42), transparent 76%);
  transform: rotate(-3deg) scale(1.08);
  animation: space-drift 32s ease-in-out infinite alternate;
}

.space::after {
  inset: -4%;
  opacity: .56;
  background:
    radial-gradient(ellipse 48% 46% at 50% 49%, transparent 0 48%, rgba(0, 0, 0, .27) 76%, rgba(0, 0, 0, .58) 100%),
    radial-gradient(ellipse 24% 62% at 4% 58%, rgba(27, 95, 111, .09), transparent 75%),
    radial-gradient(ellipse 26% 54% at 96% 62%, rgba(111, 45, 107, .085), transparent 76%);
}

#hoard {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* 🔴 Sistem imleci YALNIZCA JS kendi imlecini çizerken gizlenir. Sınıfı ekleyen koşul,
   drawCursor()'ın erken dönüş koşulunun tam tersidir ⇒ "imleç yok, yerine de bir şey
   çizilmiyor" durumu temsil edilemez hâle gelir. */
#hoard.drawing-cursor { cursor: none; }

.x-link {
  position: fixed;
  z-index: 5;
  top: max(22px, env(safe-area-inset-top));
  right: max(24px, env(safe-area-inset-right));
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  color: var(--ink-soft);
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 50%;
  transition: color 180ms ease, border-color 180ms ease, transform 180ms ease;
}

.x-link:hover {
  color: var(--ink);
  border-color: var(--line-strong);
  transform: rotate(-4deg);
}

.x-link:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 4px;
}

.x-link svg { width: 15px; height: 15px; }

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

@media (pointer: coarse) {
  #hoard, #hoard.drawing-cursor { cursor: default; }
}

@media (prefers-reduced-motion: reduce) {
  .x-link { transition: none; }
  .space::before { animation: none; }
  /* Emniyet kemeri: JS bir şekilde sınıfı bırakmış olsa bile imleç geri gelir. */
  #hoard, #hoard.drawing-cursor { cursor: default; }
}

@keyframes space-drift {
  from { transform: translate3d(-1.5%, -1%, 0) rotate(-3deg) scale(1.08); }
  to { transform: translate3d(1.5%, 1%, 0) rotate(2deg) scale(1.13); }
}
