@font-face {
  font-family: "IBM Plex Mono";
  src: url("./fonts/ibm-plex-mono-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("./fonts/ibm-plex-mono-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #e4d2a8;
  --ink: #1f1a14;
  --ribbon: #9c2f1f;
  --rule: #c4b07a;
  --ready: #2f5d50;
  --hold: #a15c12;
  --gutter: 28px;
  --font: "IBM Plex Mono", ui-monospace, monospace;
}

[data-theme="dusk"] {
  color-scheme: dark;
  --paper: #241f1a;
  --ink: #e6d7b8;
  --ribbon: #e07a5f;
  --rule: #4a4034;
  --ready: #8fbb9a;
  --hold: #e0a84b;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 0.8125rem;
  letter-spacing: 0.04em;
  line-height: 1.4;
}

.shell {
  display: grid;
  grid-template-columns: var(--gutter) 1fr;
  min-height: 100vh;
}

.gutter {
  background:
    radial-gradient(circle at 50% 18px, var(--paper) 0 5px, transparent 6px),
    radial-gradient(circle at 50% 54px, var(--paper) 0 5px, transparent 6px),
    radial-gradient(circle at 50% 90px, var(--paper) 0 5px, transparent 6px),
    linear-gradient(var(--rule), var(--rule));
  background-size: 100% 36px;
  border-right: 1px solid var(--rule);
}

.main {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

header {
  align-items: center;
  border-bottom: 1px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  justify-content: space-between;
  padding: 0.75rem 1rem;
}

.wordmark {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: lowercase;
}

.meta {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
}

.rank-line {
  font-weight: 700;
}

.xp-track {
  background: var(--rule);
  height: 3px;
  margin-top: 0.25rem;
  position: relative;
  width: min(220px, 40vw);
}

.xp-fill {
  background: var(--ribbon);
  height: 100%;
  transition: width 0.25s ease;
  width: 0;
}

.mode-switch {
  display: inline-flex;
  gap: 0;
}

.mode-switch button,
.btn,
.theme-btn {
  align-items: center;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  justify-content: center;
  letter-spacing: inherit;
  min-height: 44px;
  min-width: 44px;
  padding: 0.35rem 0.75rem;
  text-decoration: none;
}

.mode-switch button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
}

.mode-switch button:focus-visible,
.btn:focus-visible,
.theme-btn:focus-visible,
.stage-input:focus-visible {
  outline: 2px solid var(--ribbon);
  outline-offset: 2px;
}

.stage-wrap {
  display: grid;
  flex: 1;
  padding: 1rem;
  place-items: center;
}

.stage {
  border: 1px solid var(--rule);
  min-height: 280px;
  padding: 1.25rem 1rem 2.5rem;
  position: relative;
  width: min(100%, 960px);
}

.stage:focus {
  outline: 2px solid var(--ribbon);
  outline-offset: -2px;
}

.stage-label {
  font-weight: 400;
  margin: 0 0 1rem;
  opacity: 0.85;
}

.prompt {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.35;
  margin: 0 0 1rem;
  word-break: break-word;
}

.hint {
  font-size: 0.8125rem;
  margin: 0 0 0.75rem;
  opacity: 0.75;
}

.stage-input {
  background: transparent;
  border: 0;
  caret-color: var(--ink);
  color: var(--ink);
  font: inherit;
  font-size: clamp(1.1rem, 2.5vw, 1.5rem);
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.35;
  min-height: 2rem;
  outline: none;
  padding: 0;
  width: 100%;
}

.stage-input::placeholder {
  color: color-mix(in srgb, var(--ink) 45%, transparent);
}

.typed-line {
  font-size: clamp(1.1rem, 2.5vw, 1.5rem);
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.35;
  min-height: 2rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.typed-line .ok {
  color: var(--ready);
}

.typed-line .bad {
  color: var(--ribbon);
  text-decoration: line-through;
}

.caret {
  animation: blink 1s step-end infinite;
  background: var(--ink);
  display: inline-block;
  height: 1.1em;
  vertical-align: text-bottom;
  width: 1ch;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

.key-capture {
  font-size: clamp(1.1rem, 2.5vw, 1.5rem);
  font-weight: 700;
  min-height: 2rem;
}

.key-step {
  color: var(--ready);
}

.key-step.pending {
  color: color-mix(in srgb, var(--ink) 50%, transparent);
}

.key-step.bad {
  color: var(--ribbon);
  text-decoration: line-through;
}

footer {
  align-items: center;
  border-top: 1px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  justify-content: space-between;
  padding: 0.75rem 1rem;
}

.footer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.status {
  color: var(--hold);
  font-weight: 700;
}

.site-footer {
  border-top: 1px solid var(--rule);
  font-size: 0.75rem;
  opacity: 0.85;
  overflow-wrap: anywhere;
  padding: 0.75rem 1rem;
}

.site-footer a {
  color: var(--ink);
}


.hidden {
  display: none !important;
}

.sr-live {
  border: 0;
  clip: rect(0 0 0 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

@media (max-width: 640px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .gutter {
    display: none;
  }

  .stage {
    background:
      radial-gradient(circle at 18px 50%, var(--paper) 0 4px, transparent 5px),
      radial-gradient(circle at 54px 50%, var(--paper) 0 4px, transparent 5px),
      radial-gradient(circle at 90px 50%, var(--paper) 0 4px, transparent 5px),
      linear-gradient(90deg, var(--rule), var(--rule));
    background-size: 36px 10px;
    background-repeat: repeat-x;
    background-position: top;
    border-top: 10px solid transparent;
  }
}

@media (prefers-reduced-motion: reduce) {
  .caret {
    animation: none;
  }

  .xp-fill {
    transition: none;
  }
}
