/* ============================================================================
   PASSWORD BREACH — Brand System v1.0
   A KillShift browser game. Design tokens + shared components.

   Translated directly from the brand guidelines:
   - Charcoal, off-white, one signal green (§03 Color)
   - Space Grotesk / IBM Plex Mono / IBM Plex Sans (§04 Typography)
   - Thin borders, generous negative space, restrained motion (§01/§06)
   ========================================================================== */

/* ----- Design tokens ----------------------------------------------------- */
:root {
  /* Surfaces */
  --void:        #0d0f12;   /* page background */
  --surface:     #15181d;   /* cards */
  --panel:       #1c2027;   /* inset panels, empty slots */

  /* Text */
  --off-white:   #eceef1;   /* primary text */
  --body:        #c3c8cf;   /* body copy */
  --muted:       #939aa4;   /* labels, secondary */
  --faint:       #565c65;   /* disabled / dimmed */

  /* Status accents — reserved for meaning, never decoration */
  --access:      #5bbd93;   /* green  — grants */
  --access-lift: #7ed3ad;   /* green hover */
  --caution:     #d7a34a;   /* amber  — a cost */
  --denied:      #d15f52;   /* red    — denies */

  /* Lines */
  --line:        rgba(255,255,255,0.09);
  --line-soft:   rgba(255,255,255,0.07);
  --line-slot:   rgba(255,255,255,0.16);

  /* Accent washes */
  --access-wash: rgba(91,189,147,0.06);
  --access-edge: rgba(91,189,147,0.35);
  --caution-wash:rgba(215,163,74,0.06);
  --caution-edge:rgba(215,163,74,0.40);
  --denied-wash: rgba(209,95,82,0.06);
  --denied-edge: rgba(209,95,82,0.35);

  /* Type families */
  --font-display: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono:    'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --font-sans:    'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;

  /* Rhythm */
  --radius:      8px;
  --radius-lg:   14px;
  --radius-pill: 100px;
  --shell-max:   1120px;
  --pad-x:       40px;

  /* Motion */
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

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

/* The `hidden` attribute must always win, even over author display rules
   (grid/flex/inline-flex would otherwise override the UA `display:none`). */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--void);
  color: var(--off-white);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body { min-height: 100vh; }

::selection { background: var(--access); color: var(--void); }

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

a { color: var(--off-white); text-decoration: none; transition: color .16s var(--ease); }
a:hover { color: var(--access); }

/* Accessible focus — visible focus states (§17) */
:focus-visible {
  outline: 2px solid var(--access);
  outline-offset: 2px;
  border-radius: 4px;
}
:focus:not(:focus-visible) { outline: none; }

.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;
}

.skip-link {
  position: absolute; left: 50%; top: -60px; transform: translateX(-50%);
  background: var(--access); color: var(--void); padding: 10px 18px;
  border-radius: var(--radius); font-family: var(--font-display); font-weight: 600;
  z-index: 100; transition: top .18s var(--ease);
}
.skip-link:focus { top: 12px; color: var(--void); }

/* ----- Keyframes (subtle, functional — respects reduced-motion) ---------- */
@keyframes blink { 0%,49%{opacity:1} 50%,100%{opacity:0} }
@keyframes scan  { 0%{transform:translateY(0)} 100%{transform:translateY(14px)} }
@keyframes shake {
  0%,100%{transform:translateX(0)} 20%{transform:translateX(-6px)}
  40%{transform:translateX(6px)} 60%{transform:translateX(-4px)} 80%{transform:translateX(4px)}
}
@keyframes pulse-slot {
  0%{transform:scale(1)} 50%{transform:scale(1.06); border-color:var(--access)} 100%{transform:scale(1)}
}
@keyframes fade-up {
  from{opacity:0; transform:translateY(10px)} to{opacity:1; transform:translateY(0)}
}
@keyframes fill-in {
  from{opacity:0; transform:scale(0.8)} to{opacity:1; transform:scale(1)}
}
@keyframes rise {
  from{opacity:0; transform:translateY(24px)} to{opacity:1; transform:translateY(0)}
}

/* ----- Layout scaffolding ------------------------------------------------ */
.shell { max-width: var(--shell-max); margin: 0 auto; padding: 0 var(--pad-x); }

.rule { border: none; border-top: 1px solid var(--line); margin: 0; }

/* ----- Navigation -------------------------------------------------------- */
.nav {
  max-width: var(--shell-max); margin: 0 auto;
  padding: 24px var(--pad-x);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand-lockup { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 34px; height: 34px; border: 1.5px solid var(--access); border-radius: 7px;
  display: grid; place-items: center; flex: none;
  font-family: var(--font-mono); font-size: 19px; color: var(--access); font-weight: 600;
  line-height: 0; padding-bottom: 7px;
}
.brand-word { font-family: var(--font-display); font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.nav-links { display: flex; align-items: center; gap: 32px; font-family: var(--font-mono); font-size: 13px; letter-spacing: 0.06em; }
.nav-links a { color: var(--muted); }
.nav-links a:hover, .nav-links a.is-active { color: var(--access); }
.nav-cta {
  font-family: var(--font-display); font-weight: 600; font-size: 14px;
  background: var(--access); color: var(--void) !important; padding: 9px 18px;
  border-radius: var(--radius); letter-spacing: 0;
}
.nav-cta:hover { background: var(--access-lift); }
/* Account slot holds the name chip + SIGN OUT; it's a single flex child of the
   nav, so it needs its own gap or the chip's rounded background overlaps the
   SIGN OUT link sitting immediately after it. */
.nav-account { display: inline-flex; align-items: center; gap: 22px; }
.nav-toggle { display: none; }

/* ----- Eyebrow / classification labels ----------------------------------- */
.eyebrow {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.2em;
  color: var(--muted); text-transform: uppercase;
}
.eyebrow--accent { color: var(--access); }

.status-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--access); box-shadow: 0 0 8px var(--access);
}

.pill {
  display: inline-flex; align-items: center; gap: 9px;
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.2em; color: var(--muted);
  border: 1px solid rgba(255,255,255,0.12); border-radius: var(--radius-pill); padding: 7px 15px;
}

/* ----- Headings ---------------------------------------------------------- */
.display {
  font-family: var(--font-display); font-weight: 700; letter-spacing: -0.03em;
  line-height: 1.02; margin: 0;
}
.h2 { font-family: var(--font-display); font-weight: 600; font-size: 34px; letter-spacing: -0.02em; margin: 0; }
.h3 { font-family: var(--font-display); font-weight: 600; font-size: 19px; margin: 0; }
.lede { color: var(--body); font-size: 17px; line-height: 1.6; }
.muted { color: var(--muted); }

/* ----- Buttons ----------------------------------------------------------- */
.btn {
  all: unset; box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; text-align: center; cursor: pointer; border-radius: var(--radius);
  font-family: var(--font-display); font-weight: 600; font-size: 15px;
  padding: 13px 22px; min-height: 44px; transition: background .16s var(--ease), border-color .16s var(--ease), color .16s var(--ease), transform .08s var(--ease);
  user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }

.btn--primary { background: var(--access); color: var(--void); }
.btn--primary:hover { background: var(--access-lift); }

.btn--ghost { border: 1px solid var(--line-slot); color: var(--off-white); }
.btn--ghost:hover { border-color: var(--access); color: var(--access); }

.btn--caution {
  border: 1px solid var(--caution-edge); color: var(--caution);
  font-family: var(--font-mono); font-weight: 500; font-size: 13px; letter-spacing: 0.08em;
}
.btn--caution:hover { background: var(--caution-wash); }

.btn--quiet {
  border: 1px solid var(--line-slot); color: var(--muted);
  font-family: var(--font-mono); font-weight: 500; font-size: 13px; letter-spacing: 0.08em;
}
.btn--quiet:hover { color: var(--off-white); }

.btn--block { width: 100%; }

/* ----- Cards ------------------------------------------------------------- */
.card {
  border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface);
}
.card--flat { border-radius: var(--radius); }

/* ----- Password slots ---------------------------------------------------- */
/* The board wraps between words, never inside one: each word is a nowrap
   `.word` group, and the wider column-gap is the space between words. */
.slots { display: flex; column-gap: 22px; row-gap: 7px; flex-wrap: wrap; justify-content: center; align-items: flex-start; }
.word { display: inline-flex; gap: 7px; flex-wrap: nowrap; }
.slot {
  width: 34px; height: 46px; border: 1px solid var(--line-slot); border-radius: 5px;
  display: grid; place-items: center; background: var(--panel);
  font-family: var(--font-mono); font-size: 20px; color: var(--off-white);
}
.slot--filled { background: transparent; }
.slot--revealed { background: transparent; color: var(--access); border-color: var(--access-edge); }
.slot--active { border-color: var(--access); background: var(--access-wash); }
.slot .caret {
  width: 2px; height: 22px; background: var(--access); animation: blink 1.1s step-end infinite;
}
.slot--correct { animation: fill-in .32s var(--ease) both; border-color: var(--access-edge); color: var(--access); background: transparent; }
/* A letter a guess placed correctly — filled green and kept in the box. */
.slot--confirmed { color: var(--access); border-color: var(--access-edge); background: var(--access-wash); }

/* ----- Intelligence panel ------------------------------------------------ */
.intel { display: flex; flex-direction: column; }
.intel-label {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.16em; color: var(--muted);
  margin-bottom: 10px;
}
.clue {
  display: flex; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line-soft); font-size: 14px;
}
.clue-no { font-family: var(--font-mono); color: var(--access); font-size: 12px; flex: none; padding-top: 1px; }
.clue-text { color: var(--body); }
.clue--fresh { animation: fade-up .3s var(--ease) both; }
.clue--strong .clue-no { color: var(--caution); }
.clue--strong .clue-text { color: var(--off-white); }

/* ----- Guess input ------------------------------------------------------- */
.guess-row { display: flex; gap: 10px; }
.guess-field {
  flex: 1; min-width: 0; border: 1px solid var(--line-slot); border-radius: var(--radius);
  background: var(--void); padding: 13px 14px; color: var(--off-white);
  font-family: var(--font-mono); font-size: 15px; letter-spacing: 0.12em; text-transform: uppercase;
}
.guess-field::placeholder { color: var(--muted); letter-spacing: 0.12em; }
.guess-field:focus { border-color: var(--access); outline: none; }
.guess-field.is-shake { animation: shake .4s var(--ease); border-color: var(--denied); }

/* ----- Status line & chips ---------------------------------------------- */
.metaline {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.14em; color: var(--muted);
}
.tag {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.14em;
  border-radius: var(--radius-pill); padding: 6px 14px; display: inline-flex; align-items: center; gap: 8px;
}
.tag--granted { color: var(--access); border: 1px solid var(--access-edge); }
.tag--cost    { color: var(--caution); border: 1px solid var(--caution-edge); }
.tag--denied  { color: var(--denied);  border: 1px solid var(--denied-edge); }

.prev-guesses { display: flex; flex-direction: column; gap: 8px; }
/* Each previous attempt is a row of per-letter tiles, coloured by feedback:
   green = right letter/right place, red = in the word but wrong place,
   neutral = not in the word. */
.prev-guess { display: inline-flex; column-gap: 14px; row-gap: 4px; flex-wrap: wrap; align-items: flex-start; }
.prev-guess .word { gap: 4px; }
.pl {
  width: 24px; height: 28px; display: grid; place-items: center;
  font-family: var(--font-mono); font-size: 13px; font-weight: 600;
  border: 1px solid var(--line-slot); border-radius: 4px; color: var(--muted);
  text-transform: uppercase;
}
.pl--correct { color: var(--access); border-color: var(--access-edge); background: var(--access-wash); }
.pl--present { color: var(--denied); border-color: var(--denied-edge); background: var(--denied-wash); }
.pl--absent  { color: var(--muted); border-color: var(--line-slot); background: transparent; }

/* ----- Scan line motif --------------------------------------------------- */
.scanbox {
  height: 52px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--void); overflow: hidden; position: relative;
}
.scanbox::before {
  content: ""; position: absolute; left: 0; right: 0; top: -14px; height: 14px;
  background: linear-gradient(var(--access), transparent); opacity: 0.5;
  animation: scan 2.4s ease-in-out infinite alternate;
}

/* ----- Toast / announcements -------------------------------------------- */
.toast-wrap {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 60; width: min(92vw, 420px);
}
.toast {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 16px; font-family: var(--font-mono); font-size: 13px; color: var(--off-white);
  box-shadow: 0 20px 50px -20px rgba(0,0,0,0.8); animation: fade-up .2s var(--ease) both;
  border-left: 3px solid var(--muted);
}
.toast--granted { border-left-color: var(--access); }
.toast--denied  { border-left-color: var(--denied); }
.toast--cost    { border-left-color: var(--caution); }

/* ----- Footer ------------------------------------------------------------ */
.footer { border-top: 1px solid var(--line); margin-top: 12px; }
.footer-inner {
  max-width: var(--shell-max); margin: 0 auto; padding: 32px var(--pad-x);
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px;
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em; color: var(--muted);
}
.footer-inner a { color: var(--muted); }
.footer-inner a:hover { color: var(--access); }
.footer-links { display: flex; gap: 26px; flex-wrap: wrap; }
.footer-brand { display: flex; align-items: center; gap: 10px; }
.footer-square { width: 8px; height: 8px; background: var(--access); border-radius: 1px; }
.footer-copy {
  max-width: var(--shell-max); margin: 0 auto; padding: 0 var(--pad-x) 32px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em; color: var(--faint);
}
.footer-copy a { color: var(--muted); }
.footer-copy a:hover { color: var(--access); }

/* ----- Modal / dialog ---------------------------------------------------- */
dialog.sheet {
  border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface);
  color: var(--off-white); padding: 0; max-width: 460px; width: calc(100vw - 32px);
}
dialog.sheet::backdrop { background: rgba(5,6,8,0.72); backdrop-filter: blur(2px); }
.sheet-body { padding: 28px 26px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }

/* ----- Utilities --------------------------------------------------------- */
.stack { display: grid; gap: 16px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grow { flex: 1; }
.mono { font-family: var(--font-mono); }
.center { text-align: center; }
.hidden { display: none !important; }

/* ----- Responsive: mobile-first primary target (§8.4) -------------------- */
@media (max-width: 780px) {
  :root { --pad-x: 20px; }
  .nav-links { display: none; }
  .nav-links.is-open {
    display: flex; position: absolute; left: 0; right: 0; top: 72px; z-index: 40;
    flex-direction: column; gap: 0; background: var(--surface); border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line); padding: 8px 20px;
  }
  .nav-links.is-open a { padding: 14px 0; border-bottom: 1px solid var(--line-soft); }
  .nav-links.is-open .nav-cta {
    align-self: stretch; text-align: center;
    border: none; padding: 13px 18px; margin: 4px 0 12px;
  }
  /* In the mobile dropdown the account slot stacks (chip above SIGN OUT). */
  .nav-links.is-open .nav-account { display: flex; flex-direction: column; align-items: stretch; gap: 0; }
  .nav-toggle {
    display: grid; place-items: center; width: 44px; height: 44px; cursor: pointer;
    background: none; border: 1px solid var(--line); border-radius: var(--radius); color: var(--off-white);
  }
  .h2 { font-size: 27px; }
  .footer-inner { flex-direction: column; align-items: flex-start; }
}

/* ----- Reduced motion (§8.6, §17) --------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .slot .caret { opacity: 1; }
}
