/* ========================================================================
   Anoptic Games — main stylesheet
   Dark, high-contrast, angular. Mono for headings/terminal/links, sans body.
   All hide-then-reveal styling is gated behind html.js (set by boot.js) so
   the no-JS page is complete and readable.
   ======================================================================== */

/* ---- fonts ---- */

@font-face {
  font-family: "Inter";
  src: url("/fonts/inter-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("/fonts/inter-latin-600-normal.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/jetbrains-mono-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/jetbrains-mono-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ---- tokens ---- */

:root {
  --bg: #0a0a0a;
  --fg: #e6e6e6;
  --fg-dim: #8a8a8a;
  --fg-faint: #555;
  --line: #262626;
  --blip-friendly: #c0c0c0;
  --blip-enemy: #4a4a4a;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
}

/* ---- reset-ish base ---- */

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

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

img {
  max-width: 100%;
  display: block;
}

main {
  flex: 1;
  width: 100%;
}

/* ---- headings: mono, terminal caret ---- */

h1,
h2,
h3 {
  font-family: var(--font-mono);
  line-height: 1.25;
  margin: 0;
}

h1 {
  font-size: clamp(1.7rem, 4.5vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--fg);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Blinking block caret on major headings. Drawn with currentColor so it
   never depends on a glyph existing in the font. */
.caret::after {
  content: "";
  display: inline-block;
  width: 0.48em;
  height: 0.95em;
  margin-left: 0.18em;
  background: currentColor;
  vertical-align: baseline;
  transform: translateY(0.12em);
  animation: caret-blink 1.1s step-end infinite;
}

@keyframes caret-blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

/* ---- links: mono, hairline underline, inverted hover ---- */

a {
  font-family: var(--font-mono);
  color: var(--fg);
  text-decoration: none;
  border-bottom: 1px solid var(--fg-faint);
  padding: 0 0.15em;
  margin: 0 -0.15em;
}

a:hover,
a:focus-visible {
  background: var(--fg);
  color: var(--bg);
  border-bottom-color: var(--fg);
  outline: none;
}

/* ---- header / footer ---- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--line);
}

.site-logo {
  border-bottom: none;
  margin: 0;
  padding: 0;
  line-height: 0;
}

.site-logo:hover,
.site-logo:focus-visible {
  background: transparent;
  outline: 1px solid var(--fg);
  outline-offset: 4px;
}

.site-wordmark {
  font-size: 0.95rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  border-bottom: none;
  padding: 0.2em 0.4em;
  margin: 0;
}

.site-footer {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--fg-faint);
  text-align: center;
  padding: 2.2rem 1.5rem;
  margin-top: 4rem;
  border-top: 1px solid var(--line);
}

.site-footer p {
  margin: 0;
}

/* ---- page layout ---- */

.page {
  max-width: 46rem;
  margin: 0 auto;
  padding: 3.2rem 1.5rem 0;
}

.page-head .subtitle {
  font-family: var(--font-mono);
  color: var(--fg-dim);
  font-size: 1rem;
  margin: 0.6rem 0 0;
}

.page section {
  margin-top: 3.4rem;
}

.block {
  margin-top: 1.8rem;
  padding-left: 1.25rem;
  border-left: 1px solid var(--line);
}

.block p {
  margin: 0.9rem 0 0;
  max-width: 62ch;
}

.block h3 {
  margin-bottom: 1.1rem;
}

/* ---- landing ---- */

.landing {
  max-width: 46rem;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: min(70vh, 46rem);
}

.hook {
  font-weight: 700;
}

.hook-line {
  display: block;
}

.hook-line + .hook-line {
  margin-top: 0.3em;
}

.index {
  margin-top: 3.2rem;
  font-family: var(--font-mono);
}

.index ul {
  list-style: none;
  margin: 0.8rem 0 0;
  padding: 0 0 0 1.4rem;
  border-left: 1px solid var(--line);
}

.index-solo {
  margin-top: 1.6rem;
  padding-left: 0;
  border-left: none;
}

.index ul.index-solo {
  padding-left: 0;
  border-left: none;
}

.index li {
  margin: 0.7rem 0;
}

.index-head {
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--fg-dim);
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.index a {
  display: inline-block;
  font-size: 1.1rem;
}

/* Hidden until the prompt is answered (hook-done). visibility keeps the
   not-yet-revealed links out of hit-testing and tab order; the yes/no
   prompt is the accessible path to revealing them. */
.js .index {
  visibility: hidden;
}

.js .index .index-head,
.js .index a {
  opacity: 0;
  transform: translateY(5px);
}

.js .index ul {
  border-left-color: transparent;
}

.js .hook-done .index {
  visibility: visible;
}

.js .hook-done .index .index-head,
.js .hook-done .index a {
  opacity: 1;
  transform: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
  transition-delay: calc(var(--i, 0) * 90ms);
}

.js .hook-done .index ul {
  border-left-color: var(--line);
  transition: border-left-color 0.35s ease 0.15s;
}

/* Safety valve: if hook.js ever fails to run, the index still appears. */
.js .index {
  animation: index-safety 0s 8s forwards;
}

.js .index .index-head,
.js .index a {
  animation: reveal-safety 0.4s ease 8s forwards;
}

.js .index ul {
  animation: border-safety 0.4s ease 8s forwards;
}

@keyframes index-safety {
  to {
    visibility: visible;
  }
}

@keyframes reveal-safety {
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes border-safety {
  to {
    border-left-color: var(--line);
  }
}

/* yes/no prompt after the hook question */
.hook-prompt {
  margin-top: 1.8rem;
  font-family: var(--font-mono);
  opacity: 0;
  transition: opacity 0.4s ease;
}

.hook-prompt.is-shown {
  opacity: 1;
}

.hook-answer {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--fg-faint);
  padding: 0.45rem 0.95rem;
  margin-right: 0.9rem;
  cursor: pointer;
}

.hook-answer::before {
  content: "[ ";
  color: var(--fg-faint);
}

.hook-answer::after {
  content: " ]";
  color: var(--fg-faint);
}

.hook-answer:hover,
.hook-answer:focus-visible {
  color: var(--bg);
  background: var(--fg);
  border-color: var(--fg);
  outline: none;
}

.hook-answer:hover::before,
.hook-answer:hover::after,
.hook-answer:focus-visible::before,
.hook-answer:focus-visible::after {
  color: var(--bg);
}

.hook-prompt.answered-no .hook-answer {
  display: none;
}

.hook-quip {
  display: inline-block;
  font-size: 1.05rem;
  color: var(--fg-dim);
}

/* Floating skip/replay toggle */
.hook-toggle {
  position: fixed;
  right: 1.1rem;
  bottom: 1.1rem;
  z-index: 50;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  color: var(--fg-dim);
  background: rgba(10, 10, 10, 0.9);
  border: 1px solid var(--line);
  padding: 0.5rem 0.85rem;
  cursor: pointer;
}

.hook-toggle::before {
  content: "[ ";
  color: var(--fg-faint);
}

.hook-toggle::after {
  content: " ]";
  color: var(--fg-faint);
}

.hook-toggle:hover,
.hook-toggle:focus-visible {
  color: var(--bg);
  background: var(--fg);
  border-color: var(--fg);
  outline: none;
}

.hook-toggle:hover::before,
.hook-toggle:hover::after,
.hook-toggle:focus-visible::before,
.hook-toggle:focus-visible::after {
  color: var(--bg);
}

/* ---- line-by-line reveal (scroll) ---- */

.js [data-reveal] {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.45s ease, transform 0.45s ease;
}

.js [data-reveal].is-revealed {
  opacity: 1;
  transform: none;
}

/* ---- tooltip ---- */

.tt {
  position: fixed;
  z-index: 100;
  pointer-events: none;
  top: 0;
  left: 0;
}

.tt-bg {
  position: absolute;
  inset: 0;
  background: #000;
  opacity: 0;
}

.tt svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  display: block;
}

.tt svg path {
  fill: none;
  stroke: var(--fg);
  stroke-width: 1.5;
}

.tt-lines {
  position: relative;
  padding: 0.55rem 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--fg);
  white-space: nowrap;
}

.tt-lines > span {
  display: block;
  opacity: 0;
}

.tt.tt-glitch {
  animation: tt-glitch 0.14s step-end both;
}

@keyframes tt-glitch {
  0% {
    transform: translate(-3px, 2px);
    clip-path: inset(8% 0 52% 0);
  }
  33% {
    transform: translate(3px, -2px);
    clip-path: inset(55% 0 6% 0);
  }
  66% {
    transform: translate(-2px, -1px);
    clip-path: inset(28% 0 34% 0);
  }
  100% {
    transform: none;
    clip-path: none;
  }
}

/* ---- tactical grid (Tactics page) ---- */

.tacgrid-host {
  position: relative;
  padding: 1.4rem 1.4rem 1.4rem 1.25rem;
}

.tacgrid-host canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.tacgrid-host .block-body {
  position: relative;
  z-index: 1;
}

/* ---- 404 ---- */

.notfound .block {
  border-left: none;
  padding-left: 0;
}

/* ---- utilities ---- */

.vh {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 200;
  background: var(--bg);
  padding: 0.6rem 1rem;
  border: 1px solid var(--fg);
}

.skip-link:focus {
  left: 0.5rem;
  top: 0.5rem;
}

/* ---- reduced motion: everything static, everything visible ---- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  .caret::after {
    opacity: 0.6;
  }

  .js [data-reveal],
  .js .index .index-head,
  .js .index a {
    opacity: 1;
    transform: none;
  }

  .js .index {
    visibility: visible;
  }

  .js .index ul {
    border-left-color: var(--line);
  }
}
