/*
 * Password Game styles.
 *
 * Dark, full-width, one display family (Bricolage Grotesque). The loud thing
 * is the heat scale: every score is a filled bar coloured from cold steel
 * blue to burning red, because "how close was that guess" is the whole game.
 */

:root {
  --bg: #0c1a21;
  --bg-deep: #08131a;
  --surface: #122630;
  --surface-2: #183341;
  --line: #22404d;
  --text: #e9f0f2;
  --text-soft: #a9bcc3;
  --text-faint: #6f8790;
  --accent: #7fe0cf;
  --accent-ink: #0b2a26;

  --cold: #4f86c2;
  --cool: #35b3a3;
  --warm: #ecbd3a;
  --hot: #ff7a2f;
  --burning: #ff3d3a;

  --font: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --gutter: clamp(1rem, 4vw, 3.5rem);
  --wide: 84rem;
}

* { box-sizing: border-box; }

html {
  background: var(--bg);
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font: 400 1.0625rem/1.5 var(--font);
  font-feature-settings: "tnum";
  background:
    radial-gradient(60rem 30rem at 85% -10%, rgba(255, 122, 47, 0.14), transparent 60%),
    radial-gradient(40rem 26rem at -10% 10%, rgba(79, 134, 194, 0.16), transparent 60%),
    var(--bg);
}

a { color: var(--accent); text-underline-offset: 0.15em; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 3px solid var(--warm);
  outline-offset: 3px;
}

h1, h2, h3 {
  margin: 0;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-variation-settings: "opsz" 96;
}
h1 { font-size: clamp(2.6rem, 6vw, 4.5rem); }
h2 { font-size: 1.35rem; font-weight: 600; letter-spacing: -0.01em; color: var(--text-soft); margin-bottom: 1rem; }
h3 { font-size: 1.15rem; font-weight: 600; }

p { margin: 0 0 1rem; }

.hint { color: var(--text-soft); font-size: 0.95rem; }

code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9em;
  padding: 0.05em 0.35em;
  border-radius: 4px;
  background: var(--surface-2);
}

/* Header ----------------------------------------------------------------- */

.site-header {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 0.9rem var(--gutter);
  border-bottom: 1px solid var(--line);
  background: rgba(8, 19, 26, 0.7);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}
.brand::before {
  content: "";
  display: inline-block;
  width: 0.7em;
  height: 0.7em;
  margin-right: 0.5em;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cold), var(--warm) 55%, var(--burning));
  vertical-align: -0.02em;
}

.site-nav { display: flex; gap: 0.25rem; }
.site-nav a {
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  color: var(--text-soft);
  text-decoration: none;
  font-weight: 600;
}
.site-nav a:hover { color: var(--text); background: var(--surface); }
.site-nav a.is-current { color: var(--accent-ink); background: var(--accent); }

.site-user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--text-soft);
}
.site-user-name { font-weight: 600; color: var(--text); }

.link-button { margin: 0; }
.link-button-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-faint);
  font: inherit;
  cursor: pointer;
}
.link-button-button:hover { color: var(--text); text-decoration: underline; }

/* Flash ------------------------------------------------------------------ */

.flash-wrap { padding: 1rem var(--gutter) 0; }
.flash {
  margin: 0 0 0.5rem;
  padding: 0.7rem 1rem;
  border-radius: 8px;
  border-left: 5px solid;
  background: var(--surface);
  font-weight: 600;
}
.flash.notice { border-color: var(--accent); }
.flash.alert { border-color: var(--burning); }

/* Page shells ------------------------------------------------------------ */

.page { padding: 2rem var(--gutter) 5rem; }
.page-narrow { max-width: 34rem; margin: 0 auto; padding-top: 4rem; }
.page-narrow h1 { font-size: clamp(2.2rem, 5vw, 3rem); margin-bottom: 1.5rem; }

/* Hero ------------------------------------------------------------------- */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 2rem 4rem;
  align-items: end;
  padding: 1.5rem 0 2.5rem;
  border-bottom: 1px solid var(--line);
}
.hero-empty { grid-template-columns: 1fr; }

.hero-mode { margin: 0.5rem 0 0; color: var(--text-faint); }

.hero-status {
  margin: 1rem 0 0;
  font-size: 1.15rem;
  color: var(--text-soft);
}
.hero-status strong { color: var(--text); }

.pill {
  display: inline-block;
  margin-right: 0.5rem;
  padding: 0.15rem 0.7rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
}
.pill-safe { background: rgba(53, 179, 163, 0.18); color: var(--accent); }
.pill-cracked { background: rgba(255, 61, 58, 0.18); color: var(--burning); }

.hero-action {
  padding: 1.25rem 1.5rem;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.guess-form { margin: 0; }
.guess-form label { margin-bottom: 0.6rem; }
.guess-form-row { display: flex; gap: 0.6rem; }
.guess-form-row input[type="text"] {
  flex: 1;
  max-width: none;
  font-size: 1.35rem;
  font-weight: 600;
  padding: 0.7rem 0.9rem;
}
.guess-form-row input[type="submit"] { margin: 0; font-size: 1.1rem; padding: 0.7rem 1.5rem; }

.hero-done { margin: 0; font-size: 1.1rem; color: var(--text-soft); }
.hero-done strong { display: block; color: var(--text); font-size: 1.3rem; margin-bottom: 0.2rem; }

/* Forms ------------------------------------------------------------------ */

form { margin: 0 0 1.5rem; }
form div { margin-bottom: 1.1rem; }

select {
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-deep);
  color: var(--text);
  font: inherit;
}

label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 600;
  color: var(--text-soft);
}

input[type="text"],
input[type="email"],
input[type="password"] {
  width: 100%;
  max-width: 26rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-deep);
  color: var(--text);
  font: inherit;
}
input::placeholder { color: var(--text-faint); }
input:focus-visible { border-color: var(--accent); outline-color: var(--accent); }

input[type="submit"],
.button,
button.button {
  display: inline-block;
  margin-top: 0.25rem;
  padding: 0.65rem 1.3rem;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
input[type="submit"]:hover, .button:hover, button.button:hover { filter: brightness(1.1); }
.button-big { font-size: 1.15rem; padding: 0.85rem 1.6rem; }
.button-danger { background: var(--burning); color: #fff; }

.errors {
  margin: 0 0 1.25rem;
  padding: 0.7rem 1rem 0.7rem 2rem;
  border-left: 5px solid var(--burning);
  border-radius: 8px;
  background: var(--surface);
}

/* Feed layout ------------------------------------------------------------ */

.feed-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 20rem;
  gap: 2.5rem 4rem;
  padding-top: 2.5rem;
}

.feed-aside {
  position: sticky;
  top: 5.5rem;
  align-self: start;
  padding: 1.25rem 1.5rem;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text-soft);
  font-size: 0.95rem;
}
.feed-aside h2 { font-size: 1.1rem; color: var(--text); margin-bottom: 0.6rem; }


.legend {
  list-style: none;
  margin: 0;
  padding: 0.9rem 0 0;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
}
.legend li { display: flex; align-items: center; gap: 0.4rem; margin: 0; color: var(--band); font-weight: 600; }
.legend-swatch { width: 1.6rem; height: 0.5rem; border-radius: 999px; background: var(--band); }

.feed-empty { color: var(--text-faint); padding: 2rem 0; }

/* A guess ---------------------------------------------------------------- */

.guess {
  padding: 1.4rem 1.6rem;
  margin-bottom: 1rem;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.guess-cracking {
  border-color: rgba(255, 61, 58, 0.5);
  box-shadow: inset 4px 0 0 var(--burning);
}

.guess-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.guess-line { margin: 0; font-size: 1.35rem; color: var(--text-soft); letter-spacing: -0.01em; }
.guess-who { font-weight: 700; color: var(--text); }
.guess-word { font-weight: 800; color: var(--text); }
.guess-when { color: var(--text-faint); font-size: 0.9rem; white-space: nowrap; }

.hits { list-style: none; margin: 0; padding: 0; }

.hit {
  display: grid;
  grid-template-columns: 1.5rem 9rem minmax(0, 1fr);
  gap: 0.5rem 1.25rem;
  align-items: center;
  padding: 0.55rem 0;
  border-top: 1px solid var(--line);
  margin: 0;
}
.hit:first-child { border-top: 0; }
.hit-rank { color: var(--text-faint); font-weight: 600; font-size: 0.9rem; }
.hit-player { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hit-cracked .hit-player { color: var(--burning); }


/* Score: the heat bar ---------------------------------------------------- */

.score {
  --band: var(--text-faint);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 2.6rem 4.2rem;
  align-items: center;
  gap: 0.6rem;
}
.score-bar {
  display: block;
  height: 0.6rem;
  border-radius: 999px;
  background: var(--bg-deep);
  overflow: hidden;
}
.score-fill {
  display: block;
  height: 100%;
  width: var(--pct, 0%);
  border-radius: inherit;
  background: var(--band);
  box-shadow: 0 0 12px color-mix(in srgb, var(--band) 60%, transparent);
}
.score-value { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.score-band { font-size: 0.85rem; font-weight: 600; color: var(--band); }

.score-cold, .legend .score-cold       { --band: var(--cold); }
.score-cool, .legend .score-cool       { --band: var(--cool); }
.score-warm, .legend .score-warm       { --band: var(--warm); }
.score-hot, .legend .score-hot         { --band: var(--hot); }
.score-burning, .legend .score-burning { --band: var(--burning); }

.cracked {
  margin: 1rem 0 0;
  padding: 0.7rem 1rem;
  border-radius: 8px;
  background: rgba(255, 61, 58, 0.12);
  color: var(--text);
}

/* Focus mode ------------------------------------------------------------- */

.focus-form { margin: 0 0 1rem; }
.focus-form label { margin-bottom: 0.4rem; }
.focus-form select { flex: 1; }
.feed-aside-focus { padding: 1rem; }
.feed-aside-focus .target { border: 0; padding: 0.25rem 0.5rem; background: transparent; }
.feed-aside-focus .target-head h2 { color: var(--warm); }
.focus-off { margin: 0.75rem 0 0 0.5rem; }

/* Targets ---------------------------------------------------------------- */

.targets { display: grid; grid-template-columns: repeat(auto-fill, minmax(22rem, 1fr)); gap: 1.5rem; margin-top: 2rem; }
.target { padding: 1.25rem 1.5rem; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.target-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 0.75rem; }
.target-head h2 { margin: 0; color: var(--text); font-size: 1.35rem; }
.target-count { color: var(--text-faint); font-size: 0.9rem; white-space: nowrap; }
.target-cracked { border-color: rgba(255, 61, 58, 0.5); }
.target-cracked .target-head h2 { color: var(--burning); }
.target-empty { color: var(--text-faint); margin: 0; }
.words { list-style: none; margin: 0; padding: 0; }
.word-row { display: grid; grid-template-columns: 7rem minmax(0, 1fr); gap: 0.75rem; align-items: center; padding: 0.4rem 0; border-top: 1px solid var(--line); margin: 0; }
.word-row:first-child { border-top: 0; }
.word-row .guess-word { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.word-by { grid-column: 2; color: var(--text-faint); font-size: 0.85rem; margin-top: -0.25rem; }

/* Tables and lists (leaderboard, seasons) -------------------------------- */

.board { display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: 2rem; margin-top: 2rem; }
.panel {
  padding: 1.25rem 1.5rem;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.panel h2 { color: var(--text); }
.panel p:last-child { margin-bottom: 0; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.55rem 0.75rem 0.55rem 0; text-align: left; border-top: 1px solid var(--line); }
thead th { border-top: 0; color: var(--text-faint); font-weight: 600; font-size: 0.9rem; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.ranking { list-style: none; margin: 0; padding: 0; counter-reset: rank; }
.ranking li {
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  padding: 0.55rem 0;
  border-top: 1px solid var(--line);
  counter-increment: rank;
}
.ranking li:first-child { border-top: 0; }
.ranking li::before { content: counter(rank); width: 1.5rem; color: var(--text-faint); font-weight: 600; }
.ranking .name { flex: 1; font-weight: 700; }
.ranking li:first-child .name { color: var(--warm); }
.ranking .count { color: var(--text-soft); }

ul, ol { padding-left: 1.25rem; }
li { margin-bottom: 0.35rem; }

.seasons-list { list-style: none; padding: 0; margin: 1.5rem 0 0; }
.seasons-list li {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.8rem 0;
  border-top: 1px solid var(--line);
}
.seasons-list a { font-weight: 700; font-size: 1.15rem; text-decoration: none; color: var(--text); }
.seasons-list a:hover { color: var(--accent); }
.seasons-list .meta { color: var(--text-soft); }

.season-actions { margin-top: 2rem; }

/* Responsive ------------------------------------------------------------- */

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; align-items: start; }
  .feed-layout { grid-template-columns: 1fr; }
  .feed-aside { position: static; }
  .hit { grid-template-columns: 1.5rem minmax(0, 1fr); }
  .hit .score { grid-column: 1 / -1; }
}

@media (max-width: 600px) {
  .site-header { flex-wrap: wrap; gap: 0.6rem 1rem; }
  .site-user { margin-left: 0; width: 100%; justify-content: space-between; }
  .guess { padding: 1rem; }
  .guess-line { font-size: 1.15rem; }
  .score { grid-template-columns: minmax(0, 1fr) 2.4rem 3.6rem; }
}

@media (prefers-reduced-motion: no-preference) {
  .score-fill { transition: width 500ms ease-out; }
}
