/* ─────────────────────────────────────────────────────────────────────────────
   x³⁵⁸ Base — reset, typography, graph-paper background, utilities
   Requires: tokens.css loaded first
──────────────────────────────────────────────────────────────────────────── */

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

html {
  /* Safe area for iPhone notch / Android cutout */
  padding-top:    env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  scroll-padding-top: env(safe-area-inset-top, 0px);
}

body {
  margin: 0;
  padding: 0;
  font: 16px/1.5 var(--f-ui);
  color: var(--ink);

  /* Graph paper background */
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 22px 22px;
  background-position: -1px -1px;
}

/* ── Typography ─────────────────────────────────────────────────────────── */

h1 { font: 700 clamp(2.4rem, 9vw, 3.4rem)/1 var(--f-hand); margin: 4px 0 12px; text-wrap: balance; color: var(--biro); }
h2 { font: 700 1.9rem/1.1 var(--f-hand); margin: 0 0 10px; text-wrap: balance; }
h3 { font: 700 1.2rem/1.2 var(--f-ui); margin: 0 0 8px; }
p  { margin: 0 0 12px; }

/* ── Card ───────────────────────────────────────────────────────────────── */

.card {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 6px;
  padding: 18px;
  box-shadow: var(--shadow);
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.btn {
  font: 600 1rem var(--f-ui);
  padding: 12px 22px;
  min-height: 48px;
  border-radius: 6px;
  border: 1.5px solid var(--pen);
  background: var(--pen);
  color: var(--pen-fg);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: opacity 0.15s, transform 0.1s;
}
.btn:active    { transform: scale(0.97); }
.btn:disabled  { opacity: 0.4; cursor: not-allowed; }
.btn.ghost     { background: transparent; color: var(--pen); }
.btn.danger    { background: var(--red); border-color: var(--red); color: #fff; }
.btn.full      { width: 100%; justify-content: center; }

/* ── SVG icons ───────────────────────────────────────────────────────────── */

.ic {
  width: 24px;
  height: 24px;
  fill: currentColor;
  flex-shrink: 0;
  pointer-events: none;
}
.ic-sm { width: 18px; height: 18px; }
.ic-lg { width: 32px; height: 32px; }

/* ── Progress squares (battle) ───────────────────────────────────────────── */

.sq      { width: 16px; height: 16px; border: 1.5px solid var(--line); background: var(--card); border-radius: 2px; }
.sq.done { background: var(--pen-soft); border-color: var(--pen); }
.sq.ok   { background: var(--green);    border-color: var(--green); }
.sq.bad  { background: var(--red);      border-color: var(--red); }
.sq.cur  { border: 2.5px solid var(--pen); }

/* ── Focus / a11y ────────────────────────────────────────────────────────── */

button:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--pen);
  outline-offset: 2px;
}

/* ── Utilities ───────────────────────────────────────────────────────────── */

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

img { max-width: 100%; }

/* ── Math / formula ──────────────────────────────────────────────────────── */

.math { font-family: var(--f-math); }
