/* GillNation landing. No inline styles — this is the only stylesheet. CSP style-src 'self'. */
:root {
  --bg: #000000;
  --fg: #eef4f6;
  --muted: rgba(210, 228, 232, 0.62);
  --muted-strong: rgba(236, 246, 248, 0.96);
  --teal: #6ee0e6;
  --gold: #f0c07a;
  --magenta: #e89ad0;
  --pad: clamp(20px, 4.2vw, 56px);
}

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

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}

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

#scene, #scene-copy {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  outline: none;
  background: var(--bg);
}
canvas:focus, canvas:focus-visible { outline: none; }
#scene-copy[hidden] { display: none; }
body.shot-blit #scene { visibility: hidden; }
body.shot-blit #scene-copy { display: block; visibility: visible; }

#fallback {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}
#fallback[hidden] { display: none; }
#fallback picture, #fallback img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  pointer-events: none;
}

body.booting #scene,
body.booting #fallback { opacity: 0; }
body.ready-gpu #fallback { display: none; }
body.ready-static #scene { display: none; }
body.ready-gpu #scene,
body.ready-static #fallback { opacity: 1; }

#ui {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  padding: var(--pad);
}

.sign-btn {
  pointer-events: auto;
  position: absolute;
  right: var(--pad);
  bottom: var(--pad);
  color: var(--muted-strong);
  text-decoration: none;
  font-size: 0.78rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  padding: 0.62rem 1.2rem;
  border-radius: 999px;
  border: 1px solid rgba(110, 224, 230, 0.42);
  background: rgba(2, 6, 12, 0.62);
  box-shadow:
    0 0 0 1px rgba(240, 192, 122, 0.08),
    0 0 18px rgba(80, 200, 210, 0.22),
    inset 0 0 14px rgba(80, 180, 200, 0.1);
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  opacity: 0.9;
  cursor: pointer;
}
.sign-btn:hover,
.sign-btn:focus-visible {
  color: #fff;
  opacity: 1;
  border-color: rgba(240, 192, 122, 0.7);
  background: rgba(6, 12, 20, 0.82);
  box-shadow:
    0 0 0 1px rgba(240, 192, 122, 0.28),
    0 0 26px rgba(110, 224, 230, 0.35),
    inset 0 0 16px rgba(110, 224, 230, 0.12);
  outline: none;
}
.sign-btn.signout {
  right: auto;
  left: var(--pad);
  letter-spacing: 0.16em;
  border-color: rgba(232, 154, 208, 0.35);
}
.sign-btn[hidden] { display: none; }

/* Dashboard: 78% x 68% of the viewport, centered — matches the WebGPU flame frame. */
.dashboard {
  pointer-events: none;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 78%;
  height: 68%;
  max-width: 1500px;
  max-height: 800px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: clamp(1.4rem, 3vw, 2.8rem) clamp(1.6rem, 3.4vw, 3.2rem);
  border-radius: 36px;
  background: rgba(2, 4, 10, 0.18);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.7s ease, visibility 0.7s ease, background 0.7s ease;
}
body.signed-in.dash-enter .dashboard {
  opacity: 0.4;
  visibility: visible;
  background: rgba(2, 4, 10, 0.28);
}
body.signed-in.dash-in .dashboard {
  pointer-events: auto;
  opacity: 1;
  visibility: visible;
  background: rgba(3, 6, 14, 0.32);
  /* Soft rim: flame tongues can pass under the panel without a hard shear. */
  -webkit-mask-image: radial-gradient(ellipse 100% 100% at 50% 50%, #000 91%, transparent 100%);
  mask-image: radial-gradient(ellipse 100% 100% at 50% 50%, #000 91%, transparent 100%);
}
body.ready-static.signed-in .dashboard {
  pointer-events: auto;
  opacity: 1;
  visibility: visible;
  background: rgba(3, 6, 14, 0.36);
  -webkit-mask-image: radial-gradient(ellipse 100% 100% at 50% 50%, #000 91%, transparent 100%);
  mask-image: radial-gradient(ellipse 100% 100% at 50% 50%, #000 91%, transparent 100%);
  transition: none;
}

/* r4.5: self-hosted display face (Fredoka, SIL OFL 1.1 — /fonts/Fredoka-OFL.txt), Latin subset */
@font-face {
  font-family: "GN Fredoka";
  src: url("/fonts/fredoka-latin.woff2?v=20261114r45") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

.dash-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  column-gap: 1rem;
  margin-bottom: clamp(1rem, 2.2vh, 1.6rem);
  flex-shrink: 0;
}
.dash-eyebrow {
  grid-column: 1 / -1;
  margin: 0 0 0.35rem;
  font: 500 0.72rem/1 "GN Fredoka", system-ui, sans-serif;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: rgba(110, 224, 230, 0.78);
  text-shadow: 0 0 12px rgba(110, 224, 230, 0.35);
}
.dash-eyebrow[hidden] { display: none; }
.dash-title {
  margin: 0;
  min-width: 0;
  font: 600 clamp(1.35rem, 2.7vw, 2.05rem)/1.15 "GN Fredoka", system-ui, sans-serif;
  letter-spacing: 0.015em;
  color: var(--muted-strong);
  text-shadow: 0 0 22px rgba(232, 154, 208, 0.22);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* the username in the wordmark's own gradient (orange -> red -> magenta -> violet) */
.dash-name {
  font-weight: 700;
  background: linear-gradient(100deg, #ffc27a 0%, #ff7a4d 22%, #ff4f7d 46%, #d46bff 72%, #9b8bff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 0 10px rgba(255, 110, 150, 0.35));
}
.dash-user {
  margin: 0;
  font: 500 0.78rem/1 "GN Fredoka", system-ui, sans-serif;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  padding-bottom: 0.3rem;
}
.dash-user[hidden] { display: none; }

.dash-empty {
  margin: 1.5rem 0 0;
  color: var(--muted);
  font-family: "GN Fredoka", system-ui, sans-serif;
  letter-spacing: 0.04em;
  font-size: 1rem;
  max-width: 36rem;
}
.dash-empty[hidden] { display: none; }

.dash-apps {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14.5rem, 1fr));
  gap: clamp(0.7rem, 1.4vw, 1.1rem);
  overflow: auto;
  margin: 0;
  padding: 0.35rem 0.3rem 0.6rem;
  flex: 1;
  align-content: start;
  align-items: start;
  scrollbar-width: thin;
  scrollbar-color: rgba(180, 220, 230, 0.25) transparent;
}
.dash-apps[data-count="1"], .dash-apps[data-count="2"], .dash-apps[data-count="3"] {
  grid-template-columns: repeat(auto-fill, minmax(15.5rem, 19rem));
}

/* glass tile: tinted pane in the app's hue, neon hairline, lifts on hover */
.dash-apps .tile {
  --h: 190;
  --h2: 135;
  pointer-events: auto;
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  min-width: 0;
  padding: 0.75rem 1rem 0.75rem 0.75rem;
  border-radius: 20px;
  color: var(--muted-strong);
  text-decoration: none;
  background:
    linear-gradient(155deg, hsl(var(--h) 70% 30% / 0.30) 0%, hsl(var(--h2) 60% 18% / 0.16) 45%, rgba(6, 10, 18, 0.74) 100%);
  border: 1px solid hsl(var(--h) 85% 72% / 0.20);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), inset 0 -10px 24px rgba(0, 0, 0, 0.25), 0 6px 18px rgba(0, 0, 0, 0.35);
  -webkit-backdrop-filter: blur(8px) saturate(1.25);
  backdrop-filter: blur(8px) saturate(1.25);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.dash-apps .tile::after {
  /* thin specular sheen across the top of the pane */
  content: "";
  position: absolute;
  inset: 1px 14px auto 14px;
  height: 1px;
  border-radius: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  opacity: 0.55;
  pointer-events: none;
}
.dash-apps .tile:hover {
  transform: translateY(-3px);
  border-color: hsl(var(--h) 95% 74% / 0.55);
  background:
    linear-gradient(155deg, hsl(var(--h) 75% 34% / 0.42) 0%, hsl(var(--h2) 65% 20% / 0.22) 45%, rgba(8, 12, 22, 0.80) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.10), inset 0 -10px 24px rgba(0, 0, 0, 0.22),
    0 12px 26px rgba(0, 0, 0, 0.45), 0 0 26px hsl(var(--h) 95% 60% / 0.28);
}
.dash-apps .tile:active {
  transform: translateY(-1px) scale(0.985);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 4px 12px rgba(0, 0, 0, 0.4), 0 0 18px hsl(var(--h) 95% 60% / 0.25);
}
.dash-apps .tile:focus { outline: none; }
.dash-apps .tile:focus-visible {
  outline: 2px solid hsl(var(--h) 100% 80%);
  outline-offset: 3px;
  border-color: hsl(var(--h) 95% 74% / 0.7);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.10), 0 0 0 5px hsl(var(--h) 95% 60% / 0.22), 0 0 26px hsl(var(--h) 95% 60% / 0.32);
}

/* monogram: glass pane + neon-rimmed gradient letter (SVG, styled here) */
.dash-apps .mono {
  width: 3.3rem;
  height: 3.3rem;
  flex-shrink: 0;
  overflow: visible;
  filter: drop-shadow(0 0 7px hsl(var(--h) 100% 62% / 0.45));
  transition: filter 0.18s ease, transform 0.18s ease;
}
.dash-apps .tile:hover .mono,
.dash-apps .tile:focus-visible .mono {
  filter: drop-shadow(0 0 11px hsl(var(--h) 100% 64% / 0.7));
  transform: scale(1.04);
}
.mono .pane-s0 { stop-color: hsl(var(--h) 90% 58%); stop-opacity: 0.50; }
.mono .pane-s1 { stop-color: hsl(var(--h2) 80% 28%); stop-opacity: 0.38; }
.mono .pane-rim {
  fill: none;
  stroke: hsl(var(--h) 100% 82%);
  stroke-opacity: 0.85;
  stroke-width: 1.5;
}
.mono .pane-sheen {
  fill: none;
  stroke: #ffffff;
  stroke-opacity: 0.32;
  stroke-width: 2;
  stroke-linecap: round;
}
.mono .glyph,
.mono .glyph-neon {
  font-family: "GN Fredoka", system-ui, sans-serif;
  font-weight: 700;
  font-size: 37px;
  stroke-linejoin: round;
  paint-order: stroke fill;
}
.mono .glyph-neon {
  fill: none;
  stroke: hsl(var(--h) 100% 60%);
  stroke-width: 6.5;
  stroke-opacity: 0.9;
}
.mono .glyph {
  stroke: #fff0f7;
  stroke-width: 2.8;
}
.mono .glyph-s0 { stop-color: hsl(var(--h) 100% 80%); }
.mono .glyph-s1 { stop-color: hsl(var(--h) 95% 58%); }
.mono .glyph-s2 { stop-color: hsl(var(--h2) 85% 50%); }

.dash-apps .meta {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  min-width: 0;
}
.dash-apps .name {
  font: 600 1.06rem/1.2 "GN Fredoka", system-ui, sans-serif;
  letter-spacing: 0.035em;
  background: linear-gradient(100deg, #ffffff 0%, hsl(var(--h) 100% 88%) 45%, hsl(var(--h2) 100% 80%) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 8px hsl(var(--h) 95% 62% / 0.35));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-bottom: 0.05em;
}
.dash-apps .host {
  font: 500 0.72rem/1.2 "GN Fredoka", system-ui, sans-serif;
  letter-spacing: 0.06em;
  color: rgba(200, 220, 228, 0.55);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.noscript {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 5;
}
.noscript img { width: 100%; height: 100%; object-fit: cover; }
.noscript p {
  position: absolute;
  right: var(--pad);
  bottom: var(--pad);
  margin: 0;
}
.noscript a {
  color: var(--muted);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-decoration: none;
  font-size: 0.82rem;
}

@media (prefers-reduced-motion: reduce) {
  .sign-btn, .dashboard, .dash-apps a, .dash-apps .tile, .dash-apps .mono { transition: none; }
  .dash-apps .tile:hover, .dash-apps .tile:active,
  .dash-apps .tile:hover .mono, .dash-apps .tile:focus-visible .mono { transform: none; }
}

@media (max-width: 700px) {
  .dashboard {
    width: 88%;
    height: 74%;
    border-radius: 24px;
    padding: 1.1rem 1.15rem;
  }
  /* mobile: compact vertical glass tiles, 3 across (2 on very narrow phones) */
  .dash-apps,
  .dash-apps[data-count="1"], .dash-apps[data-count="2"], .dash-apps[data-count="3"] {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.55rem;
  }
  .dash-apps .tile {
    flex-direction: column;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.7rem 0.4rem 0.6rem;
    border-radius: 18px;
    text-align: center;
  }
  .dash-apps .mono { width: 2.9rem; height: 2.9rem; }
  .dash-apps .meta { align-items: center; width: 100%; }
  .dash-apps .name {
    font-size: 0.8rem;
    letter-spacing: 0.01em;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.15;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }
  .dash-apps .tile { padding-left: 0.3rem; padding-right: 0.3rem; }
  .dash-apps .host { display: none; }
  .dash-head { grid-template-columns: 1fr; }
  .dash-title { font-size: 1.3rem; white-space: normal; }
  .dash-user { padding: 0.35rem 0 0; }
}

@media (max-width: 340px) {
  .dash-apps,
  .dash-apps[data-count="1"], .dash-apps[data-count="2"], .dash-apps[data-count="3"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* r4: optional perf HUD (?perf=1) */
.perf {
  position: fixed;
  left: 12px;
  top: 10px;
  z-index: 20;
  font: 12px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #bfe;
  background: rgba(0, 0, 0, 0.55);
  padding: 4px 8px;
  border-radius: 6px;
  pointer-events: none;
}

/* r4.2: "enable WebGPU" notice — top-centre, clear of the sign-in/out buttons (bottom corners)
   and the dashboard frame (centred, 68% tall). Shown only when WebGPU is not the active backend. */
.gpu-note {
  position: fixed;
  z-index: 15;
  top: clamp(10px, 2.2vh, 22px);
  left: 50%;
  transform: translate(-50%, -8px);
  width: min(560px, calc(100vw - 24px));
  max-height: 14vh;
  overflow: hidden;
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.62rem 0.6rem 0.62rem 0.9rem;
  border-radius: 16px;
  color: var(--muted-strong);
  font-size: 0.78rem;
  line-height: 1.38;
  letter-spacing: 0.02em;
  background: linear-gradient(135deg, rgba(10, 18, 28, 0.72), rgba(4, 6, 12, 0.66));
  border: 1px solid rgba(110, 224, 230, 0.28);
  box-shadow:
    0 0 0 1px rgba(240, 192, 122, 0.07),
    0 0 22px rgba(80, 200, 210, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    inset 0 0 18px rgba(80, 180, 200, 0.07);
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
  backdrop-filter: blur(10px) saturate(1.2);
  opacity: 0;
  transition: opacity 0.5s ease, transform 0.5s ease;
  pointer-events: auto;
  -webkit-user-select: text;
  user-select: text;
}
.gpu-note.is-in { opacity: 1; transform: translate(-50%, 0); }
.gpu-note.is-leaving { opacity: 0; transform: translate(-50%, -8px); transition-duration: 0.25s; }
.gpu-note p { margin: 0; }
.gpu-note-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  margin-top: 0.38rem;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 10px rgba(240, 192, 122, 0.8), 0 0 18px rgba(232, 154, 208, 0.45);
}
.gpu-note-body { flex: 1 1 auto; min-width: 0; }
.gpu-note-title {
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 0 14px rgba(110, 224, 230, 0.35);
}
.gpu-note-title strong { color: var(--teal); font-weight: 650; }
.gpu-note-sub { color: var(--muted); margin-top: 0.12rem !important; }
.gpu-note-hint { color: var(--muted-strong); margin-top: 0.22rem !important; }
.gpu-note code {
  font: 0.74rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 0.05rem 0.32rem;
  border-radius: 6px;
  color: var(--gold);
  background: rgba(240, 192, 122, 0.08);
  border: 1px solid rgba(240, 192, 122, 0.18);
  white-space: nowrap;
}
.gpu-note-close {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid rgba(110, 224, 230, 0.3);
  background: rgba(2, 6, 12, 0.6);
  color: var(--muted-strong);
  font: 16px/1 system-ui, sans-serif;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  transition: border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}
.gpu-note-close:hover,
.gpu-note-close:focus-visible {
  color: #fff;
  border-color: rgba(240, 192, 122, 0.7);
  box-shadow: 0 0 14px rgba(110, 224, 230, 0.3);
  outline: none;
}
@media (max-width: 700px) {
  .gpu-note { font-size: 0.72rem; max-height: 12vh; padding: 0.5rem 0.5rem 0.5rem 0.75rem; }
  .gpu-note-sub { display: none; }
  /* dashboard is 74% tall on mobile → keep the note in the top ~12% */
}
@media (max-height: 520px) {
  .gpu-note-sub { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .gpu-note, .gpu-note.is-leaving, .gpu-note-close { transition: none; }
}
/* Signed in: the flame frame hugs the top edge, so the note sits compact at the bottom
   centre, between the Sign out button (bottom-left) and the empty bottom-right corner. */
body.signed-in .gpu-note-sub { display: none; }
@media (min-width: 900px) {
  body.signed-in .gpu-note {
    top: auto;
    bottom: clamp(10px, 2.2vh, 22px);
    width: min(540px, calc(100vw - 2 * (var(--pad) + 150px)));
    transform: translate(-50%, 8px);
  }
  body.signed-in .gpu-note.is-in { transform: translate(-50%, 0); }
  body.signed-in .gpu-note.is-leaving { transform: translate(-50%, 8px); }
}
