/* Consto Challenge – shared styles.
   Palette, type and logo rules from the Consto profile manual (manual.consto.no):
   red #E33A2D / #C73336 / #F6997E, black, grey #5F6062, white; secondaries beige, teal, mint.
   Calibri is the manual's screen font (Neo Sans for print); Roboto, self-hosted, is the fallback the manual site uses.
   Headings are set in capitals, as the manual asks.
   Layout: white (or near-black) page, red top line, logo on a clean band, content in a 1040px measure. */
@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url(../assets/fonts/roboto-variable.woff2) format("woff2");
}

:root {
  --red: #E33A2D;
  --red-dark: #C73336;
  --red-light: #F6997E;
  --teal: #649A98;
  --mint: #AECDC6;
  --forest: #2C3E37;

  /* theme tokens, light values */
  --bg: #FFFFFF;
  --fg: #000000;
  --muted: #5F6062;
  --line: #EAE5DB;
  --line-strong: #000000;
  --panel: rgba(255, 255, 255, .9);
  --button-bg: #000000;
  --button-fg: #FFFFFF;
  --sky: #FFFFFF;
  --skyline: #E4F0EE;
  --skyline-line: #AECDC6;
  --ground: #EAE5DB;
  --decor-filter: none;
  --decor-opacity: .6;
  --show-light: block;
  --show-dark: none;
  --footer-bg: #000000;
  --footer-fg: #FFFFFF;
  --footer-muted: #AECDC6;

  --font: Calibri, Carlito, "Neo Sans W1G", "Neo Sans", Roboto, Arial, sans-serif;
  --gutter-l: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));
  --measure: 1040px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F0F10; --fg: #FFFFFF; --muted: #B9BABD; --line: #2A2B2E; --line-strong: #FFFFFF;
    --panel: rgba(15, 15, 16, .9); --button-bg: #FFFFFF; --button-fg: #000000;
    --sky: #0F0F10; --skyline: #1B2422; --skyline-line: #3A5450; --ground: #232426;
    --decor-filter: invert(1); --decor-opacity: .35; --show-light: none; --show-dark: block;
    --footer-bg: #000000; --footer-fg: #FFFFFF; --footer-muted: #AECDC6;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F0F10; --fg: #FFFFFF; --muted: #B9BABD; --line: #2A2B2E; --line-strong: #FFFFFF;
  --panel: rgba(15, 15, 16, .9); --button-bg: #FFFFFF; --button-fg: #000000;
  --sky: #0F0F10; --skyline: #1B2422; --skyline-line: #3A5450; --ground: #232426;
  --decor-filter: invert(1); --decor-opacity: .35; --show-light: none; --show-dark: block;
  --footer-bg: #000000; --footer-fg: #FFFFFF; --footer-muted: #AECDC6;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; }
[hidden] { display: none !important; }
a { color: inherit; }
h1, h2, h3 {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: .04em;
  line-height: 1.1;
  font-weight: 700;
  text-wrap: balance;
}
h1 { font-size: clamp(2.5rem, 7vw, 4.5rem); }
p { margin: 0; }
:focus-visible { outline: 3px solid var(--red); outline-offset: 3px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.inner {
  width: 100%;
  max-width: var(--measure);
  margin-inline: auto;
  padding-left: var(--gutter-l);
  padding-right: var(--gutter-r);
}

/* Header: logo on a clean band with clear space of at least one "C" on all sides.
   Light theme shows the black/red logo on white; dark theme the white/red logo on black, both allowed by the manual. */
.topline { height: 6px; background: var(--red); }
.site-header .inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding-block: 22px;
}
.logo { display: inline-block; line-height: 0; padding: 4px 0; }
.logo img { height: 36px; width: auto; }
.logo .logo-light { display: var(--show-light); }
.logo .logo-dark { display: var(--show-dark); }
.nav { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; justify-content: flex-end; }
.nav a {
  text-transform: uppercase;
  letter-spacing: .1em;
  font-weight: 700;
  font-size: .875rem;
  text-decoration: none;
  border-bottom: 2px solid transparent;
}
.nav a:hover, .nav a[aria-current] { border-bottom-color: var(--red); }
@media (max-width: 560px) {
  .site-header .inner { flex-direction: column; align-items: flex-start; gap: 14px; padding-block: 18px; }
  .nav { justify-content: flex-start; }
}
/* Theme switch: a bare icon that cycles auto, light and dark. */
.theme-toggle {
  background: transparent;
  color: var(--fg);
  border: 0;
  padding: 6px;
  margin: -6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  line-height: 0;
  border-radius: 50%;
  transition: color .15s ease;
  /* The links keep a 2px underline slot and their capitals sit above the line box centre;
     lift the icon so it centres on the letters rather than on the link box. */
  position: relative;
  top: -3px;
}
.theme-toggle:hover { color: var(--red); }
.theme-toggle svg { width: 22px; height: 22px; fill: currentColor; }

/* Hero on the front page, with the Consto decor element behind it */
.hero { position: relative; overflow: hidden; background: var(--bg); border-top: 1px solid var(--line); }
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url(../assets/consto-dekor.jpg) center / cover no-repeat;
  opacity: var(--decor-opacity);
  filter: var(--decor-filter);
}
.hero .inner { position: relative; padding-block: 72px 64px; display: grid; gap: 16px; }
.hero .lead { max-width: 34rem; font-size: 1.25rem; color: var(--muted); }
.hero .lead strong { color: var(--fg); }

/* Game cards */
.games .inner {
  padding-block: 56px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 48px;
}
.game-card { display: grid; gap: 16px; align-content: start; min-width: 0; }
.game-card .shot {
  display: block;
  position: relative;
  aspect-ratio: 2 / 3;
  max-width: 100%;
  border: 2px solid var(--line-strong);
  background: var(--bg);
  overflow: hidden;
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.game-card .shot img { display: block; width: 100%; height: 100%; object-fit: cover; }
.game-card .shot::after {
  content: "Play";
  position: absolute;
  right: 0; bottom: 0;
  background: var(--button-bg);
  color: var(--button-fg);
  text-transform: uppercase;
  letter-spacing: .12em;
  font-weight: 700;
  font-size: .8rem;
  padding: 8px 14px;
  transition: background .2s ease, color .2s ease;
}
.game-card .shot:hover, .game-card .shot:focus-visible {
  border-color: var(--red);
  transform: translateY(-4px);
  box-shadow: 0 14px 28px rgba(0, 0, 0, .18);
}
.game-card .shot:hover::after, .game-card .shot:focus-visible::after { background: var(--red); color: #fff; }
.game-card h2 { font-size: 1.75rem; }
.game-card h2 a { text-decoration: none; }
.game-card h2 a:hover { color: var(--red); }
.game-card .desc { color: var(--muted); max-width: 32rem; }
.hs {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 16px;
  align-items: baseline;
  border-top: 2px solid var(--line-strong);
  padding-top: 12px;
}
.hs .label {
  grid-column: 1 / -1;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: .75rem;
  font-weight: 700;
  color: var(--muted);
}
.hs .value {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--red);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.hs .holder { color: var(--muted); font-size: .95rem; }

/* FAQ, written as plain questions and answers so people and answer engines can read them */
.faq { border-top: 1px solid var(--line); }
.faq .inner { padding-block: 48px 64px; display: grid; gap: 28px; }
.faq h2 { font-size: 1.5rem; }
.faq dl { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px 48px; }
.faq dt { font-weight: 700; margin-bottom: 6px; }
.faq dd { margin: 0; color: var(--muted); max-width: 36rem; }

/* Buttons */
.btn {
  display: inline-block;
  background: var(--button-bg);
  color: var(--button-fg);
  text-transform: uppercase;
  letter-spacing: .12em;
  font: inherit;
  font-weight: 700;
  font-size: .9rem;
  padding: 12px 26px;
  border: 2px solid var(--button-bg);
  text-decoration: none;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.btn:hover, .btn:focus-visible { background: var(--red); border-color: var(--red); color: #fff; }
.btn.secondary { background: transparent; color: var(--fg); border-color: var(--line-strong); }
.btn.secondary:hover, .btn.secondary:focus-visible { background: var(--line); color: var(--fg); border-color: var(--line-strong); }

/* Footer: white and grey on black, as the manual allows */
.site-footer { margin-top: auto; background: var(--footer-bg); color: var(--footer-fg); font-size: .875rem; border-top: 1px solid var(--line); }
.site-footer .inner {
  padding-block: 32px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px 32px;
  align-items: start;
}
.site-footer .brand { text-transform: uppercase; letter-spacing: .12em; font-weight: 700; margin-bottom: 6px; }
.site-footer .brand span { color: var(--red); }
.site-footer .muted { color: var(--footer-muted); }
.site-footer a { color: var(--footer-fg); text-decoration-color: var(--red); }
.site-footer a:hover { color: var(--red-light); }
.site-footer .slogan { font-style: italic; }
.site-footer nav { display: grid; gap: 6px; }

/* Game pages */
.game-head .inner {
  padding-block: 24px 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 24px;
}
.game-head h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); }
.game-head .tag { color: var(--muted); }
.game-layout .inner {
  padding-block: 24px 56px;
  display: grid;
  grid-template-columns: minmax(0, 480px) minmax(240px, 1fr);
  gap: 40px;
  align-items: start;
}
@media (max-width: 820px) { .game-layout .inner { grid-template-columns: 1fr; } }
.stage-wrap { min-width: 0; }
.stage {
  position: relative;
  width: 100%;
  max-width: 480px;
  aspect-ratio: 2 / 3;
  border: 2px solid var(--line-strong);
  background: var(--sky);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.stage canvas { display: block; width: 100%; height: 100%; }
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--panel);
  padding: 24px;
  text-align: center;
}
.panel { display: grid; gap: 16px; max-width: 320px; justify-items: center; }
.panel h2 { font-size: 1.75rem; }
.panel p { color: var(--muted); }
.panel .big { color: var(--red); }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: .75rem; font-weight: 700; color: var(--muted); }
.big {
  font-size: 4rem;
  font-weight: 700;
  color: var(--red);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
#hs-form { display: grid; gap: 8px; width: 100%; justify-items: center; }
#hs-form label { font-weight: 700; color: var(--fg); }
#hs-form input {
  font: inherit;
  font-size: 1.75rem;
  font-weight: 700;
  width: 100%;
  max-width: 9ch;
  text-align: center;
  padding: 6px 8px;
  text-indent: .2em;
  border: 2px solid var(--line-strong);
  background: var(--bg);
  color: var(--fg);
  text-transform: uppercase;
  letter-spacing: .2em;
}
#hs-form .error { color: var(--red); font-size: .9rem; }
.hint { color: var(--muted); font-size: .9rem; margin-top: 12px; }

/* Touch pad for the digger */
.pad {
  display: grid;
  grid-template-columns: repeat(3, 60px);
  grid-template-rows: repeat(2, 60px);
  gap: 6px;
  justify-content: center;
  margin-top: 16px;
}
.pad button {
  font: inherit;
  font-size: 1.4rem;
  background: var(--button-bg);
  color: var(--button-fg);
  border: 0;
  cursor: pointer;
  touch-action: none;
}
.pad button.on, .pad button:active { background: var(--red); color: #fff; }
.pad button[data-dir="U"] { grid-column: 2; grid-row: 1; }
.pad button[data-dir="L"] { grid-column: 1; grid-row: 2; }
.pad button[data-dir="D"] { grid-column: 2; grid-row: 2; }
.pad button[data-dir="R"] { grid-column: 3; grid-row: 2; }

/* Side panel: how to play, leaderboard */
.aside { display: grid; gap: 32px; min-width: 0; }
.aside h2 { font-size: 1.1rem; border-bottom: 2px solid var(--line-strong); padding-bottom: 8px; margin-bottom: 12px; }
.howto { margin: 0; padding-left: 1.2em; display: grid; gap: 8px; color: var(--muted); }
.howto strong { color: var(--fg); }
kbd {
  font: inherit;
  font-size: .8em;
  border: 1px solid var(--muted);
  padding: 1px 7px;
  border-radius: 3px;
  color: var(--fg);
}
.board { list-style: none; margin: 0; padding: 0; }
.board li {
  display: grid;
  grid-template-columns: 2ch 1fr auto;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.board .rank { color: var(--muted); font-weight: 700; }
.board .name { letter-spacing: .1em; font-weight: 700; }
.board .score { font-weight: 700; color: var(--red); }
.board li.empty { grid-template-columns: 1fr; color: var(--muted); }
.legend { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; color: var(--muted); }
.legend li { display: grid; grid-template-columns: 22px 1fr; gap: 10px; align-items: center; }
.legend i { display: block; width: 18px; height: 18px; border: 1px solid rgba(127, 127, 127, .35); }

/* Text pages (privacy policy, 404) */
.prose .inner { padding-block: 40px 72px; display: grid; gap: 20px; max-width: calc(var(--measure) - 280px); margin-inline: auto; }
.prose h1 { font-size: clamp(2rem, 5vw, 3rem); }
.prose h2 { font-size: 1.25rem; margin-top: 16px; }
.prose p, .prose li { max-width: 65ch; }
.prose ul { margin: 0; padding-left: 1.2em; display: grid; gap: 8px; }
.prose .meta { color: var(--muted); }
.prose a { text-decoration-color: var(--red); }

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