/* ---------------------------------------------------------------------
   Design tokens
   Palette drawn from the paper's own materials: patterns photographed
   on 35mm slides, projected in blue-black mimeograph-era academic print.
   ------------------------------------------------------------------- */
:root {
  --paper:      #EFF1EF;
  --paper-raised: #FAFBFA;
  --ink:        #14171A;
  --ink-soft:   #4A5058;
  --line:       #C9CDC8;
  --line-soft:  #DEE1DC;
  --blue:       #2C4E9E;   /* mimeograph / duplicating ink */
  --blue-deep:  #1D3572;
  --red:        #A4373A;   /* grading-pen red, for confusion/error */
  --green:      #3E7350;   /* correct / success */
  --amber:      #B9791C;   /* timing / in-progress */

  --serif: 'Source Serif 4', Georgia, serif;
  --sans:  'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono:  'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;

  --radius: 3px;
  --shadow: 0 1px 2px rgba(20,23,26,0.06), 0 6px 20px rgba(20,23,26,0.05);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  position: relative;
}

.grid-veil {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    repeating-linear-gradient(0deg, rgba(20,23,26,0.035) 0 1px, transparent 1px 96px),
    repeating-linear-gradient(90deg, rgba(20,23,26,0.035) 0 1px, transparent 1px 96px);
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; color: var(--ink); margin: 0 0 .5em; letter-spacing: -0.01em; }
h1 { font-size: 2.1rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
.eyebrow {
  font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.12em;
  font-size: 0.72rem; color: var(--blue-deep); font-weight: 600;
}

/* -------------------------------------------------------------- header */
.site-header {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 32px; border-bottom: 1px solid var(--line);
  background: var(--paper-raised);
  flex-wrap: wrap; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark { display: inline-flex; border-bottom: 2px solid var(--ink-soft); padding-bottom: 3px; }
.sq { width: 7px; height: 16px; display: inline-block; }
.sq.b { background: var(--ink); }
.sq.w { background: var(--paper-raised); border-top: 1px solid var(--line); border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-title { font-family: var(--serif); font-weight: 700; font-size: 1.25rem; }
.brand-sub { font-family: var(--mono); font-size: 0.68rem; color: var(--ink-soft); }
.site-nav { display: flex; gap: 22px; align-items: center; }
.site-nav a {
  font-family: var(--mono); font-size: 0.82rem; color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.site-nav a:hover { color: var(--blue); text-decoration: none; }
.site-nav a.nav-report { color: var(--blue); font-weight: 600; }

.site-main { position: relative; z-index: 1; max-width: 980px; margin: 0 auto; padding: 48px 28px 80px; }

.site-footer {
  position: relative; z-index: 1; border-top: 1px solid var(--line); padding: 24px 32px 40px;
  color: var(--ink-soft); font-size: 0.85rem; max-width: 980px; margin: 0 auto;
}

/* --------------------------------------------------------------- misc */
.card {
  background: var(--paper-raised); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 28px; margin-bottom: 24px;
}
.lede { font-size: 1.12rem; color: var(--ink-soft); max-width: 62ch; }

.btn {
  font-family: var(--mono); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em;
  border: 1px solid var(--ink); background: var(--ink); color: var(--paper-raised);
  padding: 13px 26px; border-radius: var(--radius); cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px; transition: transform .12s ease, background .12s ease;
}
.btn:hover { background: var(--blue-deep); border-color: var(--blue-deep); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.secondary { background: transparent; color: var(--ink); }
.btn.secondary:hover { background: var(--line-soft); color: var(--ink); }
.btn.danger { background: var(--red); border-color: var(--red); }
.btn.big { padding: 17px 34px; font-size: 0.95rem; }

.pill {
  display: inline-block; font-family: var(--mono); font-size: 0.72rem;
  padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--ink-soft); background: var(--paper);
}
.pill.blue { color: var(--blue-deep); border-color: var(--blue); background: #E7EBF7; }
.pill.green { color: var(--green); border-color: var(--green); background: #E7F1EA; }
.pill.red { color: var(--red); border-color: var(--red); background: #F6E9E9; }

/* ------------------------------------------------------------ pattern
   Rendered exactly as the paper describes: "a horizontal linear
   arrangement of three black and four white squares ... along the
   bottom edge of the pattern there is a thin grey line". */
.pattern-strip {
  display: inline-flex; border-bottom: 3px solid var(--line);
  padding-bottom: 4px;
}
.pattern-strip .cell { width: 15px; height: 34px; }
.pattern-strip .cell.B { background: var(--ink); }
.pattern-strip .cell.W { background: var(--paper-raised); border-top: 1px solid var(--line-soft); }
.pattern-strip.small .cell { width: 9px; height: 20px; }
.pattern-strip.large .cell { width: 22px; height: 50px; }

.pattern-card {
  display: inline-flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 14px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--paper-raised); cursor: pointer; transition: border-color .1s, box-shadow .1s, transform .06s;
  user-select: none;
}
.pattern-card:hover { border-color: var(--blue); box-shadow: var(--shadow); }
.pattern-card:active { transform: translateY(1px); }
.pattern-card.chosen { border-color: var(--green); background: #EFF6F1; }
.pattern-card.wrong { border-color: var(--red); background: #F8EEEE; }
.pattern-card.selected { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue) inset; }
.pattern-card.disabled { opacity: 0.35; pointer-events: none; }
.pattern-card .pattern-id { font-family: var(--mono); font-size: 0.68rem; color: var(--ink-soft); }

.pattern-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 18px;
  margin: 20px 0;
}

/* ---------------------------------------------------------- timers etc */
.stopwatch {
  font-family: var(--mono); font-size: 3rem; font-weight: 600; color: var(--amber);
  letter-spacing: -0.02em;
}
.progress-track {
  height: 6px; background: var(--line-soft); border-radius: 999px; overflow: hidden; margin: 10px 0 22px;
}
.progress-fill { height: 100%; background: var(--blue); transition: width .2s ease; }

.stage {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  min-height: 300px; justify-content: center; gap: 18px;
}

.step-list { display: flex; flex-direction: column; gap: 10px; margin: 18px 0 28px; }
.step-list li { display: flex; gap: 12px; align-items: baseline; }
.step-num { font-family: var(--mono); color: var(--blue); font-weight: 600; min-width: 1.4em; }

table.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.data-table th, table.data-table td {
  padding: 8px 10px; border-bottom: 1px solid var(--line-soft); text-align: left;
}
table.data-table th { font-family: var(--mono); font-size: 0.7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); }
table.data-table td.num { font-family: var(--mono); text-align: right; }
table.data-table tr:hover { background: var(--paper); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin: 20px 0; }
.stat-box { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; background: var(--paper-raised); }
.stat-value { font-family: var(--mono); font-size: 1.7rem; color: var(--blue-deep); font-weight: 600; }
.stat-label { font-size: 0.78rem; color: var(--ink-soft); margin-top: 4px; }

.callout {
  border-left: 3px solid var(--blue); background: #E7EBF7; padding: 14px 18px;
  border-radius: 0 var(--radius) var(--radius) 0; margin: 18px 0; font-size: 0.94rem;
}
.callout.warn { border-color: var(--amber); background: #F7EFE1; }

.ordering-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ordering-list li {
  display: flex; align-items: center; gap: 14px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper-raised);
}
.ordering-list .rank-num { font-family: var(--mono); color: var(--blue); width: 2em; }

textarea.desc-input {
  width: 100%; min-height: 110px; font-family: var(--sans); font-size: 1rem;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--paper-raised); resize: vertical;
}
textarea.desc-input:focus, input:focus { outline: 2px solid var(--blue); outline-offset: 1px; }

.two-col { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 36px; align-items: start; }
@media (max-width: 800px) { .two-col { grid-template-columns: 1fr; } }

.center { text-align: center; }
.muted { color: var(--ink-soft); }
.mt-24 { margin-top: 24px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
