/* 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.
   Type is Inter (variable, self-hosted), the Consto web-app standard (CS-UI-002); the manual's print faces are not web fonts.
   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: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url(../assets/fonts/inter-latin-wght-normal.woff2) format('woff2');
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url(../assets/fonts/inter-latin-ext-wght-normal.woff2) format('woff2');
  unicode-range:
    U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}

: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, 0.9);
  --button-bg: #000000;
  --button-fg: #ffffff;
  --sky: #ffffff;
  --skyline: #e4f0ee;
  --skyline-line: #aecdc6;
  --ground: #eae5db;
  --decor-filter: none;
  --decor-opacity: 0.6;
  --show-light: block;
  --show-dark: none;
  --footer-bg: #000000;
  --footer-fg: #ffffff;
  --footer-muted: #aecdc6;

  --font: 'Inter', system-ui, 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, 0.9);
    --button-bg: #ffffff;
    --button-fg: #000000;
    --sky: #0f0f10;
    --skyline: #1b2422;
    --skyline-line: #3a5450;
    --ground: #232426;
    --decor-filter: invert(1);
    --decor-opacity: 0.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, 0.9);
  --button-bg: #ffffff;
  --button-fg: #000000;
  --sky: #0f0f10;
  --skyline: #1b2422;
  --skyline-line: #3a5450;
  --ground: #232426;
  --decor-filter: invert(1);
  --decor-opacity: 0.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: 0.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: 0.1em;
  font-weight: 700;
  font-size: 0.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 0.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 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.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: 0.12em;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 8px 14px;
  transition:
    background 0.2s ease,
    color 0.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, 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: 0.12em;
  font-size: 0.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: 0.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: 0.12em;
  font: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 12px 26px;
  border: 2px solid var(--button-bg);
  text-decoration: none;
  cursor: pointer;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.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: 0.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: 0.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%;
}
/* Below the stage: the hint and the sound on/off button. */
.stage-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 480px;
  margin-top: 12px;
}
.stage-tools .hint {
  margin-top: 0;
}
.audio-toggle {
  flex: none;
  width: 40px;
  height: 40px;
  border: 2px solid var(--line-strong);
  border-radius: 50%;
  background: transparent;
  color: var(--fg);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.audio-toggle:hover {
  color: var(--red);
  border-color: var(--red);
}
.audio-toggle svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}
.audio-toggle[aria-pressed='true'] {
  color: var(--muted);
  border-color: var(--muted);
}
.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: 0.14em;
  font-size: 0.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: 0.2em;
  border: 2px solid var(--line-strong);
  background: var(--bg);
  color: var(--fg);
  text-transform: uppercase;
  letter-spacing: 0.2em;
}
#hs-form .error {
  color: var(--red);
  font-size: 0.9rem;
}
.hint {
  color: var(--muted);
  font-size: 0.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: 0.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: 0.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, 0.35);
}
.sw-soil {
  background: #a47a55;
}
.sw-clay {
  background: #7a5540;
}
.sw-rock {
  background: #5f6062;
}
.sw-boulder {
  background: #2c3e37;
  border-radius: 50%;
}
.sw-pipe {
  background: #649a98;
}
.sw-fuel {
  background: #e33a2d;
}
.sw-brick {
  background: #c73336;
}
.sw-copper {
  background: #c9803f;
}
.sw-gold {
  background: #e0b23b;
}
.sw-sign {
  background: #fff;
  border: 2px solid #e33a2d;
}

/* 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;
  }
}
