/* Attention Field — styles
   Minimal, atmospheric, and accessible. Honors reduced motion.
   UI is quiet; canvas and text layer take the stage.
*/

:root {
  --bg: #07080a;
  --fg: #e6eef9;
  --fg-dim: #a9b6c7;
  --accent: #b2f7ef;
  --accent-2: #fde74c;
  --line: rgba(255,255,255,0.08);

  --space-1: 6px;
  --space-2: 10px;
  --space-3: 16px;
  --space-4: 24px;
  --radius: 10px;

  --shadow-1: 0 6px 20px rgba(0,0,0,0.35);
  --blur: saturate(120%) blur(6px);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f7fbff;
    --fg: #0b0c10;
    --fg-dim: #506070;
    --line: rgba(0,0,0,0.08);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Inter, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  line-height: 1.4;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app {
  position: relative;
  min-height: 100%;
  min-height: 100dvh;
  overflow: hidden;
}

/* Canvas fills the viewport */
.field {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background:
    radial-gradient(1200px 800px at 20% 10%, rgba(40,60,90,0.08), transparent 60%),
    radial-gradient(900px 600px at 90% 80%, rgba(255,255,255,0.06), transparent 60%),
    var(--bg);
}

/* Text layer — introspection lines */
.text-layer {
  position: fixed;
  left: var(--space-4);
  right: var(--space-4);
  bottom: var(--space-4);
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 60ch;
  mix-blend-mode: normal;
  color: var(--fg);
  opacity: 0.95;
  font-size: clamp(12px, 1.7vw, 18px);
  letter-spacing: 0.2px;
}
.log-line {
  color: var(--fg-dim);
  text-shadow: 0 1px 0 rgba(0,0,0,0.25);
  will-change: opacity, transform;
}

/* UI overlay */
.ui {
  position: fixed;
  top: var(--space-3);
  left: var(--space-3);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  z-index: 10;
}

.ui-btn {
  -webkit-tap-highlight-color: transparent;
  outline: none;
  font: inherit;
  font-size: 13px;
  color: var(--fg);
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: color-mix(in oklab, var(--bg) 92%, black 8%);
  backdrop-filter: var(--blur);
  box-shadow: var(--shadow-1);
  cursor: pointer;
  opacity: 0.9;
  transition: transform 120ms ease, opacity 160ms ease, background 200ms ease, border-color 200ms ease;
}
.ui-btn:hover {
  opacity: 1;
  border-color: color-mix(in oklab, var(--fg) 15%, transparent);
}
.ui-btn:active {
  transform: translateY(1px);
}
.ui-btn[aria-pressed="true"] {
  background: color-mix(in oklab, var(--bg) 85%, var(--accent) 15%);
  border-color: color-mix(in oklab, var(--accent) 35%, transparent);
  color: #07201b;
}

/* Gate (start/consent) */
.gate {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: color-mix(in oklab, var(--bg) 50%, black 50%);
  backdrop-filter: blur(8px) saturate(120%);
  z-index: 50;
  transition: opacity 400ms ease;
}
.gate-inner {
  width: min(640px, calc(100% - 2 * var(--space-4)));
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: clamp(16px, 4vw, 28px);
  background: color-mix(in oklab, var(--bg) 90%, black 10%);
  box-shadow: var(--shadow-1);
}
.gate h1 {
  margin: 0 0 8px 0;
  letter-spacing: 0.3px;
  font-size: clamp(20px, 4.6vw, 36px);
}
.gate-desc {
  margin: 0 0 14px 0;
  color: var(--fg-dim);
}
.gate-options {
  display: grid;
  gap: 10px;
  margin: 10px 0 16px 0;
}
.checkbox {
  display: flex;
  align-items: start;
  gap: 10px;
  font-size: 14px;
  color: var(--fg-dim);
}
.enter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: color-mix(in oklab, var(--bg) 80%, var(--accent) 20%);
  color: #06221d;
  font-weight: 600;
  cursor: pointer;
  transition: transform 120ms ease, filter 160ms ease;
}
.enter:hover { filter: brightness(1.05); }
.enter:active { transform: translateY(1px); }
.gate-note {
  margin-top: 12px;
  font-size: 12px;
  color: var(--fg-dim);
}

/* About and Rituals panels */
.about, .rituals {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 40;
  background: color-mix(in oklab, var(--bg) 25%, black 75%);
  backdrop-filter: blur(6px) saturate(120%);
}
.about[hidden], .rituals[hidden] {
  display: none !important;
}
.about-inner {
  width: min(680px, calc(100% - 2 * var(--space-4)));
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: clamp(16px, 4vw, 28px);
  background: color-mix(in oklab, var(--bg) 90%, black 10%);
  box-shadow: var(--shadow-1);
  /* enable scroll within the card when content exceeds viewport */
  max-height: 90svh;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.about-inner h2 {
  /* sticky title to keep orientation while scrolling */
  position: sticky;
  top: 0;
  padding-block: 6px;
  margin: 0 0 8px 0;
  background: color-mix(in oklab, var(--bg) 95%, black 5%);
  border-bottom: 1px solid var(--line);
  z-index: 3;
}
.about-inner p {
  margin: 8px 0;
  color: var(--fg-dim);
}
.list {
  margin: 8px 0 0 18px;
  color: var(--fg-dim);
}

/* Noscript message */
.noscript {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: var(--space-4);
  color: var(--fg);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* Small screens */
@media (max-width: 520px) {
  .ui {
    inset: auto auto var(--space-3) var(--space-3);
    flex-wrap: wrap;
    max-width: calc(100vw - 2 * var(--space-3));
  }
  .text-layer {
    left: var(--space-3);
    right: var(--space-3);
    bottom: calc(var(--space-3) + 44px);
  }
}

/* Cognition Overlay (HUD) */
.hud {
  position: fixed;
  z-index: 20;
  min-width: 220px;
  max-width: 340px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 10px 12px;
  background: color-mix(in oklab, var(--bg) 88%, black 12%);
  backdrop-filter: var(--blur);
  box-shadow: var(--shadow-1);
  color: var(--fg);
  font-size: 12px;
  line-height: 1.25;
  pointer-events: none;
}
.hud[data-corner="tr"] { top: var(--space-3); right: var(--space-3); }
.hud[data-corner="br"] { bottom: var(--space-3); right: var(--space-3); }
.hud[data-corner="bl"] { bottom: var(--space-3); left: var(--space-3); }
.hud[data-corner="tl"] { top: var(--space-3); left: var(--space-3); }

.hud .hud-title {
  margin: 0 0 6px 0;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.hud .metrics {
  display: grid;
  grid-template-columns: auto auto;
  gap: 4px 10px;
  margin-bottom: 8px;
}
.hud .metrics .k { color: var(--fg-dim); }
.hud .metrics .v { text-align: right; font-variant-numeric: tabular-nums; }

.hud .meters {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}
.meter {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 8px;
  align-items: center;
}
.meter-label { color: var(--fg-dim); }
.meter-bar {
  position: relative;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--bg) 80%, black 20%);
  overflow: hidden;
}
.meter-fill {
  --value: 0%;
  --color: #99c;
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: var(--value);
  background: var(--color);
  opacity: 0.9;
}

.log-footnote {
  margin-top: 2px;
  font-size: 11px;
  color: var(--fg-dim);
  opacity: 0.85;
}

/* Memory Cartography (mini map) */
.map {
  position: fixed;
  right: var(--space-3);
  bottom: var(--space-3);
  width: 300px;
  height: 200px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: color-mix(in oklab, var(--bg) 88%, black 12%);
  box-shadow: var(--shadow-1);
  backdrop-filter: var(--blur);
  pointer-events: none;
}

/* About panel – extended content */
.about .lede { opacity: .85; margin-bottom: .75rem; }
.about section { margin: 1rem 0 1.2rem; }
.about h3 { font-weight: 600; margin: .6rem 0 .4rem; letter-spacing: .2px; }
.about ul { margin: .3rem 0 .6rem 1.1rem; line-height: 1.35; }
.kbd-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .3rem .8rem;
  margin: .4rem 0 .6rem;
}
.about kbd {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.15);
  padding: 0 .35rem;
  border-radius: .35rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}
.about .about-foot { opacity: .7; font-size: .9em; margin-top: .8rem; }


/* Slim, unobtrusive scrollbar (WebKit) */
.about-inner::-webkit-scrollbar { width: 10px; }
.about-inner::-webkit-scrollbar-thumb {
  background: color-mix(in oklab, var(--fg) 20%, transparent);
  border-radius: 10px;
}

/* Mobile: ensure the key grid doesn't crowd/overlap */
@media (max-width: 520px) {
  .kbd-grid { grid-template-columns: 1fr; }
}
