/*
 * AI Healthcare Bullshit Bingo
 * Mobile-first · Vintage broadsheet × Swiss grid
 * bingo.tefhelth.se
 */

/* ── TOKENS ─────────────────────────────────────────────────────── */
:root {
  --ink:         #0f0f0f;
  --paper:       #f7f4ee;
  --accent:      #c8311a;
  --accent-dark: #9e2514;
  --green:       #1a6b3a;
  --green-light: #d4edd9;
  --muted:       #7a7167;
  --rule:        #ccc8be;
  --rule-light:  #e2ddd5;
  --card-bg:     #faf8f3;
  --marked-bg:   #fff3c4;
}

/* ── RESET ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── BODY (mobile baseline) ──────────────────────────────────────── */
body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
  padding: 14px 12px 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}

/* ── MASTHEAD ────────────────────────────────────────────────────── */
.masthead {
  width: 100%;
  max-width: 680px;
  border-top: 4px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  padding: 9px 0 8px;
  margin-bottom: 0;
  /* stacked on mobile */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.masthead-label {
  font-family: 'DM Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
}

/* ── TITLE BLOCK ─────────────────────────────────────────────────── */
.title-block {
  width: 100%;
  max-width: 680px;
  padding: 14px 0 12px;
  border-bottom: 1px solid var(--rule-light);
  margin-bottom: 14px;
}

.title-eyebrow {
  font-family: 'DM Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 7px;
}

h1 {
  font-family: 'DM Serif Display', serif;
  font-size: clamp(28px, 7.5vw, 50px);
  line-height: 1.03;
  letter-spacing: -0.015em;
  color: var(--ink);
}

h1 em {
  font-style: italic;
  color: var(--accent);
}

.subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
  max-width: 460px;
  line-height: 1.55;
}

/* ── CONTROLS ────────────────────────────────────────────────────── */
.controls {
  width: 100%;
  max-width: 680px;
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.btn {
  /* Mobile: equal-share, tall enough for thumbs */
  flex: 1;
  min-height: 44px;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 10px 12px;
  border: 1.5px solid var(--ink);
  background: transparent;
  cursor: pointer;
  color: var(--ink);
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover { background: var(--ink); color: var(--paper); }

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  flex: 1.4;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }

/* ── SCORE LINE ──────────────────────────────────────────────────── */
.score-line {
  width: 100%;
  max-width: 680px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.1em;
}

#score-count { color: var(--ink); font-weight: 500; }

#win-status {
  color: var(--green);
  font-weight: 500;
  letter-spacing: 0.18em;
}

/* ── GRID WRAPPER ────────────────────────────────────────────────── */
.grid-wrap {
  width: 100%;
  max-width: 680px;
  border: 2px solid var(--ink);
  /* Subtle offset shadow — reduced on mobile */
  box-shadow: 2px 2px 0 var(--ink);
}

/* ── COLUMN HEADERS ──────────────────────────────────────────────── */
.col-headers {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  border-bottom: 2px solid var(--ink);
  background: var(--ink);
}

.col-header {
  font-family: 'DM Serif Display', serif;
  font-size: clamp(17px, 4.8vw, 28px);
  text-align: center;
  /* Mobile: compact */
  padding: 8px 2px;
  color: var(--paper);
  border-right: 1px solid rgba(255, 255, 255, 0.09);
  letter-spacing: 0.02em;
  line-height: 1;
}

.col-header:last-child { border-right: none; }

/* ── GRID CELLS ──────────────────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
}

.cell {
  position: relative;
  /* Mobile: 64px is enough for 2-3 lines at 9px with padding */
  min-height: 64px;
  padding: 6px 4px;
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: var(--card-bg);
  transition: background 0.1s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overflow: hidden;
}

.cell:nth-child(5n) { border-right: none; }
.cell:nth-last-child(-n+5) { border-bottom: none; }

.cell:hover:not(.free-space) { background: #ece8d8; }

.cell:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  z-index: 1;
}

/* ── CELL STATES ─────────────────────────────────────────────────── */
.cell.marked { background: var(--marked-bg); }

.cell.win-cell {
  background: var(--green-light) !important;
  border-color: var(--green);
}

.cell.free-space {
  background: var(--ink);
  cursor: default;
}

.cell.free-space:hover { background: var(--ink); }

/* ── CELL TEXT ───────────────────────────────────────────────────── */
.cell-text {
  /* Fluid type: 9px at 375 → 11px at 480+ */
  font-size: clamp(8.5px, 2.45vw, 11px);
  line-height: 1.32;
  text-align: center;
  color: var(--ink);
  font-weight: 500;
  position: relative;
  z-index: 1;
  transition: opacity 0.15s;
  overflow-wrap: break-word;
}

.cell.marked .cell-text { opacity: 0.3; }

.cell.free-space .cell-text {
  color: var(--paper);
  font-family: 'DM Serif Display', serif;
  font-style: italic;
  font-size: clamp(11px, 3.2vw, 15px);
  font-weight: 400;
  opacity: 1;
}

/* ── STAMP ───────────────────────────────────────────────────────── */
.stamp {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-9deg) scale(0);
  font-size: clamp(28px, 7.5vw, 46px);
  color: var(--accent);
  font-weight: 900;
  font-family: 'Inter', sans-serif;
  line-height: 1;
  pointer-events: none;
  /* Ink-press effect: slight blur + shadow */
  opacity: 0.72;
  filter: blur(0.5px);
  text-shadow:
    0 0 3px rgba(200, 49, 26, 0.3),
    1px 1px 0 rgba(158, 37, 20, 0.2);
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cell.marked .stamp {
  transform: translate(-50%, -50%) rotate(-9deg) scale(1);
}

/* ── BINGO BANNER ────────────────────────────────────────────────── */
.bingo-banner {
  display: none;
  width: 100%;
  max-width: 680px;
  margin-top: 18px;
  background: var(--accent);
  color: #fff;
  padding: 16px 16px 14px;
  font-family: 'DM Serif Display', serif;
  font-size: clamp(30px, 8.5vw, 44px);
  text-align: center;
  letter-spacing: 0.06em;
  box-shadow: 2px 2px 0 var(--accent-dark);
}

.bingo-banner.visible {
  display: block;
  animation: stamp-in 0.38s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* Typographic ornament above the BINGO word */
.bingo-banner::before {
  content: '◆  ◆  ◆';
  display: block;
  font-family: 'DM Mono', monospace;
  font-size: 7px;
  letter-spacing: 0.5em;
  opacity: 0.55;
  margin-bottom: 10px;
}

.bingo-banner span {
  display: block;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.82;
  margin-top: 10px;
  line-height: 1.55;
}

@keyframes stamp-in {
  from { transform: scale(1.07) rotate(-1.5deg); opacity: 0; }
  to   { transform: scale(1)    rotate(0deg);    opacity: 1; }
}

/* ── FOOTER ──────────────────────────────────────────────────────── */
.footer {
  width: 100%;
  max-width: 680px;
  margin-top: 16px;
  border-top: 1px solid var(--rule);
  padding-top: 10px;
  /* Stacked on mobile */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-family: 'DM Mono', monospace;
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: center;
}

/* ── TABLET 480px+ ───────────────────────────────────────────────── */
@media (min-width: 480px) {
  body { padding: 20px 16px 60px; }

  .masthead {
    flex-direction: row;
    justify-content: space-between;
    align-items: baseline;
  }

  .masthead-label { font-size: 10px; text-align: left; }

  .title-block { padding: 18px 0 14px; margin-bottom: 18px; }
  .title-eyebrow { font-size: 10px; }
  .subtitle { font-size: 13px; }

  .controls { gap: 10px; }
  .btn { flex: none; padding: 10px 20px; min-height: 40px; }
  .btn-primary { flex: none; }

  .col-header { padding: 10px 2px; }

  .cell { min-height: 80px; padding: 8px 6px; }

  .grid-wrap { box-shadow: 3px 3px 0 var(--ink); }

  .bingo-banner {
    padding: 20px 24px 18px;
    box-shadow: 3px 3px 0 var(--accent-dark);
  }

  .footer {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    text-align: left;
    font-size: 10px;
  }
}

/* ── DESKTOP 680px+ ──────────────────────────────────────────────── */
@media (min-width: 680px) {
  body { padding: 32px 24px 80px; }

  .masthead { padding: 12px 0 10px; }
  .masthead-label { letter-spacing: 0.18em; }

  .title-block { padding: 20px 0 16px; margin-bottom: 22px; }

  /* Subtle left-border on subtitle at desktop — editorial sidebar feel */
  .subtitle {
    padding-left: 14px;
    border-left: 2px solid var(--rule-light);
    margin-top: 10px;
  }

  .btn { font-size: 11px; padding: 9px 22px; }

  .score-line { font-size: 11px; margin-bottom: 14px; }

  .col-header { padding: 12px 4px; }

  .cell { min-height: 104px; padding: 10px 8px; }

  .grid-wrap { box-shadow: 5px 5px 0 var(--ink); }

  .bingo-banner {
    margin-top: 26px;
    padding: 22px 32px 20px;
    box-shadow: 5px 5px 0 var(--accent-dark);
  }

  .bingo-banner span { font-size: 11px; }

  .footer { margin-top: 22px; font-size: 10px; padding-top: 12px; }
}
