/* The ONLY stylesheet. Shared by index.html (the app) and ui.html (the styleguide). */

:root {
  /* Taste: Paper */
  --bg: #e9e7e1;
  --surface: #faf9f6;
  --text: #1a1a1a;
  --text-dim: #6b6b6b;
  --accent: #3b6ea5;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 16px;
  --space-4: 24px;
  --space-5: 32px;

  --radius: 6px;

  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --size-s: 13px;
  --size-m: 15px;
  --size-l: 20px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: var(--size-m) / 1.5 var(--font);
}

/* ── button ─────────────────────────────────────────────── */
.button {
  padding: var(--space-2) var(--space-3);
  border: 1px solid #0000001a;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.button:hover { border-color: #00000033; }
.button:active { border-color: var(--accent); }

/* ── icon button ────────────────────────────────────────── */
.icon-button {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid #0000001a;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  line-height: 1;
  cursor: pointer;
}
.icon-button:hover { border-color: #00000033; }

/* ── page number ────────────────────────────────────────── */
.page-number {
  min-width: 92px;
  text-align: center;
  color: var(--text-dim);
  font-size: var(--size-s);
  font-variant-numeric: tabular-nums;
}
.page-number input {
  width: 44px;
  padding: 2px var(--space-1);
  border: 1px solid #0000001a;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: right;
}

/* ── spinner ────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid #00000022;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── popup ──────────────────────────────────────────────── */
.popup {
  position: absolute;
  z-index: 20;
  width: 300px;
  max-width: calc(100vw - var(--space-4));
  padding: var(--space-3);
  border: 1px solid #0000001a;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 6px 24px #00000022;
}
.popup[hidden] { display: none; }
.popup-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}
.popup-word { font-size: var(--size-l); font-weight: 600; }
.popup-simple { margin-top: var(--space-2); }
.popup-rewrite {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid #0000001a;
  color: var(--text-dim);
  font-style: italic;
}
.popup-status { margin-top: var(--space-2); color: var(--text-dim); font-size: var(--size-s); }

/* ── empty state ────────────────────────────────────────── */
.empty-state {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.empty-state[hidden] { display: none; }

/* ── app layout (not a component) ───────────────────────── */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  height: 48px;
  border-bottom: 1px solid #0000001a;
  background: var(--surface);
  transition: opacity 150ms;
}
.toolbar[hidden] { display: none; }
.toolbar.is-faded { opacity: 0.15; }
.toolbar:hover { opacity: 1; }

.viewer {
  position: relative;
  width: max-content;
  margin: var(--space-4) auto;
}
.viewer canvas { display: block; box-shadow: 0 2px 12px #00000022; }

/* Invisible text sitting exactly on top of the canvas, so words are tappable. */
.text-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  line-height: 1;
  opacity: 0;
  cursor: text;
}
.text-layer span {
  position: absolute;
  transform-origin: 0 0;
  white-space: pre;
}

/* ── styleguide page only ───────────────────────────────── */
.guide { max-width: 720px; margin: var(--space-5) auto; padding: 0 var(--space-3); }
.guide section { margin-bottom: var(--space-5); }
.guide h2 { font-size: var(--size-m); color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; }
.guide .row { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.guide .swatch { width: 64px; height: 64px; border: 1px solid #0000001a; border-radius: var(--radius); }
.guide .demo { position: relative; height: 220px; background: var(--bg); border-radius: var(--radius); }
