/* University-Coursework, published site.
   The motif is the grid: a battleship board, a confusion matrix and a
   correlation heatmap are the same object. Colours come from the heatmap
   ramp; hit/miss/ship are the ones GrilleNavaleGraphique actually paints. */

:root {
  --paper:   #F4F6F9;
  --surface: #FFFFFF;
  --sunken:  #ECEFF4;
  --ink:     #0F1B2A;
  --muted:   #5A6B80;
  --line:    #D7DEE7;

  --teal:    #10707E;
  --teal-lo: #E3F0F2;
  --gold:    #B4820E;

  --hit:     #C63B3B;
  --miss:    #4A6FA5;
  --ship:    #3B8557;

  /* sequential and monotonic in lightness, so the parity lattice reads as
     structure instead of noise; warm, to stay clear of the red hits and
     blue misses painted over it */
  --ramp-0: #E7ECF2;
  --ramp-1: #EFE8D6;
  --ramp-2: #E4D3A6;
  --ramp-3: #D3B568;
  --ramp-4: #BC9331;
  --ramp-5: #8C6A10;

  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Fira Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;

  --w: 1080px;
  --r: 4px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:   #0B131E;
    --surface: #121D2A;
    --sunken:  #0F1926;
    --ink:     #E7EEF6;
    --muted:   #93A5BA;
    --line:    #23334699;

    --teal:    #4FC3D0;
    --teal-lo: #14313A;
    --gold:    #E0B93F;

    --hit:     #E0605F;
    --miss:    #7CA0D4;
    --ship:    #5EB07E;

    --ramp-0: #1B2735;
    --ramp-1: #23261F;
    --ramp-2: #3F3820;
    --ramp-3: #654F1F;
    --ramp-4: #96742A;
    --ramp-5: #D6AA36;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: var(--w); margin: 0 auto; padding: 0 24px; }

/* ---------- type ---------- */

h1, h2, h3 { line-height: 1.15; letter-spacing: -0.02em; font-weight: 700; }
h1 { font-size: clamp(2rem, 5vw, 3.1rem); margin: 0 0 .4em; letter-spacing: -0.035em; }
h2 { font-size: clamp(1.35rem, 2.6vw, 1.75rem); margin: 2.6rem 0 .9rem; }
h3 { font-size: 1.05rem; margin: 1.8rem 0 .5rem; }

.eyebrow {
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 .7rem;
}

.lede { font-size: 1.12rem; color: var(--muted); max-width: 62ch; }
p { max-width: 72ch; }

a { color: var(--teal); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

code, .num { font-family: var(--mono); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- chrome ---------- */

.site-head {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky; top: 0; z-index: 20;
}
.site-head .wrap {
  display: flex; align-items: center; gap: 1rem;
  min-height: 56px; flex-wrap: wrap;
}
.site-head a { text-decoration: none; }
.brand { font-weight: 700; letter-spacing: -0.02em; color: var(--ink); }
.crumbs { font-family: var(--mono); font-size: .8rem; color: var(--muted); }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--teal); }
.crumbs .sep { opacity: .5; padding: 0 .35rem; }
.site-head .spacer { flex: 1; }
.site-head .repo { font-family: var(--mono); font-size: .8rem; }

.site-foot {
  margin-top: 4rem; border-top: 1px solid var(--line);
  padding: 1.6rem 0 3rem; color: var(--muted); font-size: .88rem;
}

/* ---------- hero ---------- */

.hero { padding: 3.2rem 0 1rem; }
.hero-grid {
  display: grid; gap: 2.5rem;
  grid-template-columns: minmax(0, 1fr) minmax(0, 420px);
  align-items: center;
}
@media (max-width: 820px) { .hero-grid { grid-template-columns: 1fr; } }

/* ---------- stat strip: every number names its source ---------- */

.stats { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line);
         border-radius: var(--r); overflow: hidden; grid-template-columns: repeat(3, 1fr); margin: 2.5rem 0; }
@media (max-width: 700px) { .stats { grid-template-columns: 1fr; } }
.stat { background: var(--surface); padding: 1.1rem 1.2rem; }
.stat .v { font-family: var(--mono); font-size: 1.7rem; font-weight: 600; letter-spacing: -0.03em;
           font-variant-numeric: tabular-nums; display: block; }
.stat .k { font-size: .9rem; color: var(--ink); display: block; margin-top: .15rem; }
.stat .src { font-family: var(--mono); font-size: .7rem; color: var(--muted); margin-top: .5rem; display: block;
             overflow-wrap: anywhere; }

/* ---------- cards / index ---------- */

.cards { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); margin: 1.2rem 0; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 1.05rem 1.15rem; display: block; text-decoration: none; color: inherit;
  transition: border-color .12s, transform .12s;
}
a.card:hover { border-color: var(--teal); transform: translateY(-2px); }
.card .t { font-weight: 650; display: block; margin-bottom: .25rem; }
.card .d { color: var(--muted); font-size: .9rem; }
.card .tag { font-family: var(--mono); font-size: .68rem; letter-spacing: .1em; text-transform: uppercase;
             color: var(--teal); display: block; margin-bottom: .45rem; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 1.3rem 1.4rem; }
.panel.quiet { background: var(--sunken); }

/* a caveat is content, not an afterthought */
.caveat { border-left: 3px solid var(--gold); background: var(--sunken); padding: .9rem 1.1rem;
          border-radius: 0 var(--r) var(--r) 0; margin: 1.3rem 0; font-size: .93rem; }
.caveat h3 { margin: 0 0 .4rem; font-size: .95rem; }
.caveat ul { margin: .4rem 0 0; padding-left: 1.1rem; }
.caveat li { margin: .3rem 0; }

/* ---------- tables ---------- */

.tw { overflow-x: auto; margin: 1rem 0; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: .5rem .7rem; border-bottom: 1px solid var(--line); }
th { font-family: var(--mono); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase;
     color: var(--muted); font-weight: 500; }
td.n, th.n { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--sunken); }

/* ---------- board ---------- */

.board { display: grid; gap: 2px; aspect-ratio: 1; width: 100%; }
.cell {
  border-radius: 2px; background: var(--ramp-0); position: relative;
  display: grid; place-items: center; font-family: var(--mono); font-size: .62rem;
  transition: background .18s;
}
.cell.miss { background: var(--miss); }
.cell.hit  { background: var(--hit); }
.cell.sunk { background: var(--hit); opacity: .55; }
.cell.next { outline: 2px solid var(--gold); outline-offset: 1px; z-index: 2; }
.cell .s { position: absolute; inset: 0; border: 1.5px solid var(--ship); border-radius: 2px; pointer-events: none; }

.legend { display: flex; flex-wrap: wrap; gap: .9rem; font-size: .82rem; color: var(--muted); margin-top: .8rem; }
.legend i { width: .8rem; height: .8rem; border-radius: 2px; display: inline-block; vertical-align: -1px; margin-right: .32rem; }

.controls { display: flex; align-items: center; gap: .8rem; margin-top: 1rem; flex-wrap: wrap; }
button {
  font: inherit; font-size: .9rem; padding: .4rem .95rem; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer;
}
button:hover { border-color: var(--teal); color: var(--teal); }
/* paper, not white: the accent is dark in light mode and bright in dark mode,
   so a fixed white label loses contrast in one of them */
button[aria-pressed="true"] { background: var(--teal); border-color: var(--teal); color: var(--paper); }
input[type=range] { flex: 1; min-width: 140px; accent-color: var(--teal); }
select { font: inherit; font-size: .9rem; padding: .35rem .5rem; border-radius: var(--r);
         border: 1px solid var(--line); background: var(--surface); color: var(--ink); }

.race { display: grid; gap: 1.6rem; grid-template-columns: 1fr 1fr; }
@media (max-width: 700px) { .race { grid-template-columns: 1fr; } }
.race h3 { display: flex; justify-content: space-between; align-items: baseline; margin-top: 0; }
.race .count { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 400; }

/* ---------- charts ---------- */

figure { margin: 1.4rem 0; }
figcaption { color: var(--muted); font-size: .84rem; margin-top: .6rem; max-width: 72ch; }
svg { display: block; width: 100%; height: auto; overflow: visible; }
svg.matrix { max-width: 540px; }
svg text { font-family: var(--mono); font-size: 11px; fill: var(--muted); }
svg text.val { fill: var(--ink); }
svg .bar { fill: var(--teal); }
svg .bar.alt { fill: var(--gold); }
svg .err { stroke: var(--ink); stroke-width: 1.2; opacity: .6; }
svg .grid-line { stroke: var(--line); stroke-width: 1; }

:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; border-radius: 2px; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
