/* ============================================================================
   The look every page of this app shares.

   Plain on purpose: warm paper, dark ink, hard edges and 2px rules, the way
   the datatypes games are built, in a light theme. One face for reading and
   one for anything that is actual Python.

   Color has three jobs and no others: amber is what you are acting on, green
   is right, red is wrong. Right and wrong always carry a word or a mark as
   well, so nothing depends on telling two colors apart.
   ========================================================================= */

/* Both faces are variable files, so one file covers every weight. They are
   local: the app has to work with nothing fetched from anywhere else. */
@font-face {
  font-family: 'Atkinson Hyperlegible Next';
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url('../fonts/atkinson-hyperlegible-next-latin.woff2') format('woff2');
}

@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url('../fonts/jetbrains-mono-latin.woff2') format('woff2');
}

:root {
  --paper:    #f5f1e8;
  --panel:    #fffdf8;
  --panel-lo: #ece6d8;
  --rule:     #cdc4b1;
  --rule-hot: #8f8573;
  --ink:      #1f1b16;
  --dim:      #5d5648;
  --dimmer:   #7a7262;

  --amber:      #b86e00;
  --amber-fill: #ffdc8f;
  --green:      #1c6b2a;
  --green-fill: #dcefd9;
  --red:        #b3261e;
  --red-fill:   #fbe2df;

  --console:     #1f1b16;
  --console-ink: #f3ecdc;

  --mono: 'JetBrains Mono', 'Cascadia Mono', Consolas, 'Courier New', monospace;
  --read: 'Atkinson Hyperlegible Next', 'Segoe UI', Verdana, sans-serif;
}

* { box-sizing: border-box; }

/* JetBrains Mono ships code ligatures, and they are wrong here. It draws <=
   as one glyph, != as another. A student who sees that in a line of Python
   has been shown a character Python does not have and cannot type. Turned
   off at the root so it is off everywhere the face is used. */
html {
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "clig" 0, "calt" 0, "dlig" 0;
}
/* A box to type in and a button do not inherit that: the browser's own style
   sheet sets `font` on them, which turns the ligatures back on. So it is
   said again for them, or a typed >= is drawn as one glyph in the box. */
input, button, textarea, select {
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "clig" 0, "calt" 0, "dlig" 0;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--read);
  font-size: 18px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

code, pre, .code { font-family: var(--mono); }

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

.shell {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 20px 72px;
}

.masthead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  border-bottom: 2px solid var(--rule-hot);
  padding-bottom: 12px;
  margin-bottom: 22px;
}

.masthead h1 {
  font-size: clamp(1.4rem, 4vw, 1.9rem);
  font-weight: 700;
  line-height: 1.1;
  margin: 0;
}

.masthead .sub {
  color: var(--dim);
  font-size: 0.95rem;
  margin-top: 4px;
}

.backlink {
  color: var(--dim);
  font-size: 0.95rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.backlink:hover { color: var(--ink); }

.panel {
  background: var(--panel);
  border: 2px solid var(--rule);
  padding: 22px;
}

.stack { display: grid; gap: 16px; min-width: 0; }
.stack > * { min-width: 0; }

/* ------------------------------------------------------------------ buttons */

.btn {
  font-family: var(--read);
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  background: var(--panel);
  border: 2px solid var(--rule-hot);
  padding: 9px 20px;
  cursor: pointer;
  position: relative;
  top: 0;
  box-shadow: 0 3px 0 0 var(--rule);
  transition: top 70ms, box-shadow 70ms, background 120ms;
  text-decoration: none;
  display: inline-block;
  line-height: 1.3;
}

.btn:hover { background: var(--panel-lo); }
.btn:active { top: 3px; box-shadow: 0 0 0 0 var(--rule); }

.btn.primary {
  background: var(--ink);
  color: var(--panel);
  border-color: var(--ink);
  box-shadow: 0 3px 0 0 var(--rule-hot);
}
.btn.primary:hover { background: #3a342b; }

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

/* -------------------------------------------------------------------- focus */

/* Every control is restyled, so the ring is drawn the same way on all of
   them: thick, amber, outside the control. */
:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------- utilities */

.hidden { display: none !important; }
.muted { color: var(--dim); }

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

/* --------------------------------------------------------- right and wrong */

/* A mark and a word, for anything said to be right, wrong or cleared. */
.marked { display: inline-flex; align-items: baseline; gap: 6px; font-weight: 700; }
.marked.right { color: var(--green); }
.marked.wrong { color: var(--red); }
.marked .mark { font-family: 'Segoe UI Symbol', 'Apple Symbols', 'DejaVu Sans', sans-serif; }

/* ------------------------------------------------------------ storage note */

/* One line, on every page, when the browser will not keep anything. It is
   information and not an error, so it is ink on paper with a heavy edge. */
.storage-note {
  margin: 0 0 16px;
  padding: 10px 14px;
  background: var(--panel-lo);
  border-left: 6px solid var(--ink);
  font-weight: 700;
}
.stack > .storage-note { margin-bottom: 0; }

@media (max-width: 768px) {
  body { font-size: 17px; }
  .shell { padding: 16px 14px 56px; }
  .panel { padding: 16px 14px; }
}
