/* See /docs/building/master-prompt.md */

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

:root {
  --paper: #f5efe4;
  --card: #fbf8f2;
  --inset: #f0e9dc;
  --ink: #2a221c;
  --ink-soft: #4a4038;
  --muted: #6b6055;
  --muted-2: #8a7f72;
  --placeholder: #b9ad9d;
  --accent: #c2562f;
  --accent-soft: rgba(194, 86, 47, 0.12);
  --accent-shadow: rgba(194, 86, 47, 0.3);
  --correct: #3f7a4f;
  --wrong: #b23a2e;
  --wrong-bg: rgba(178, 58, 46, 0.13);
  --border: rgba(42, 34, 28, 0.09);
  --border-soft: rgba(42, 34, 28, 0.06);
  --badge-dot: #5a8a52;
  --shadow-tool: 0 24px 60px -28px rgba(42, 34, 28, 0.28), inset 0 2px 0 rgba(255, 255, 255, 0.6);
  --shadow-cta: 0 10px 24px -10px #c2562f;
  --shadow-key: 0 4px 10px -4px rgba(42, 34, 28, 0.22);
  --font: 'DM Sans', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
}

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
}

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

.noscript {
  padding: 1rem;
  text-align: center;
  background: #fff3cd;
}

/* Floating keycaps */
.key-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.key-float {
  position: absolute;
  left: var(--x);
  top: var(--y);
  --r: 0deg;
  transform: rotate(var(--r));
  font-family: var(--mono);
  font-size: clamp(1.25rem, 2.5vw, 1.75rem);
  font-weight: 600;
  color: var(--ink);
  opacity: 0.85;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.4em 0.6em;
  box-shadow: var(--shadow-key);
  animation: key-drift 6s ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}

.key-float:nth-child(1) { --delay: 0s; }
.key-float:nth-child(2) { --delay: 1.2s; }
.key-float:nth-child(3) { --delay: 2.4s; }
.key-float:nth-child(4) { --delay: 3.6s; }

@keyframes key-drift {
  0%, 100% { transform: rotate(var(--r)) translateY(0); }
  50% { transform: rotate(var(--r)) translateY(-10px); }
}

/* Hero */
.hero {
  position: relative;
  z-index: 1;
  padding: 1.25rem 1.5rem 2.5rem;
  max-width: 880px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink);
  text-decoration: none;
}

.brand span { color: var(--accent); }

.nav-link {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.nav-link:hover { text-decoration: underline; }

.hero-inner { max-width: 640px; }

.eyebrow {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--accent);
  margin: 0 0 0.75rem;
}

h1 {
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  font-weight: 700;
  line-height: 1.1;
  margin: 0 0 1rem;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.lead {
  font-size: 1.12rem;
  line-height: 1.6;
  color: var(--ink-soft);
  margin: 0 0 1.25rem;
  max-width: 52ch;
}

.trust-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.trust-row span {
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.4rem 0.85rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
}

.trust-row span::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--badge-dot);
  margin-right: 0.4rem;
  vertical-align: middle;
}

/* Main */
main {
  position: relative;
  z-index: 1;
  max-width: 880px;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
}

/* Tool */
.tool-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 1.5rem 1.5rem 1.75rem;
  box-shadow: var(--shadow-tool);
  margin-bottom: 4.5rem;
}

.tool-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.duration-pills {
  display: flex;
  gap: 0.35rem;
  background: var(--inset);
  padding: 0.25rem;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
}

.pill {
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.45rem 1rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.pill:hover:not(:disabled) { color: var(--ink); }

.pill.is-active {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-cta);
}

.pill:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.restart-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.restart-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  text-align: center;
  padding: 1rem 0.5rem;
  background: var(--inset);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
}

.stat-card--timer {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.timer-ring {
  --pct: 100;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--pct) * 1%), var(--border) 0);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.timer-ring::after {
  content: '';
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: var(--inset);
}

.timer-num {
  position: relative;
  z-index: 1;
  font-family: var(--mono);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ink);
}

.stat-value {
  display: block;
  font-family: var(--mono);
  font-size: 2rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
}

.stat-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-top: 0.25rem;
}

.typing-card {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #fff;
  min-height: 160px;
  cursor: text;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.typing-card--active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.typing-card--done {
  opacity: 0.85;
}

.typing-card--done .typing-input {
  pointer-events: none;
}

.start-hint {
  position: absolute;
  top: -0.65rem;
  left: 1rem;
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.7rem;
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  z-index: 4;
  max-width: calc(100% - 2rem);
}

.passage-wrap {
  padding: 1.75rem 1.25rem 1.25rem;
  max-height: 170px;
  overflow-y: auto;
}

.passage {
  font-family: var(--mono);
  font-size: 1.4rem;
  line-height: 2.05;
  word-break: break-word;
}

.char { color: var(--placeholder); }

.char--correct { color: var(--correct); }

.char--wrong {
  color: var(--wrong);
  background: var(--wrong-bg);
}

.char--current {
  color: var(--ink);
  background: var(--accent-soft);
  border-left: 2px solid var(--accent);
  animation: cursor-blink 1s step-end infinite;
}

@keyframes cursor-blink {
  50% { border-left-color: transparent; }
}

.typing-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  border: none;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  z-index: 3;
  font-size: 16px;
}

/* Results */
.results-panel {
  margin-top: 1.5rem;
  padding: 1.4rem;
  background: var(--inset);
  border: 1px solid var(--border);
  border-radius: 18px;
}

.results-headline {
  text-align: center;
  margin-bottom: 1.25rem;
}

.result-big {
  display: block;
  font-family: var(--mono);
  font-size: 3.4rem;
  font-weight: 600;
  color: var(--accent);
  line-height: 1;
}

.result-acc-line {
  display: block;
  margin-top: 0.35rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.result-acc-line span {
  font-family: var(--mono);
  color: var(--ink);
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.65rem;
}

.result-stat {
  text-align: center;
  padding: 0.75rem 0.5rem;
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--border-soft);
}

.result-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.result-stat strong {
  font-family: var(--mono);
  font-size: 1.15rem;
  font-weight: 600;
}

.tier-verdict {
  text-align: center;
  margin: 1rem 0 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.try-again-btn {
  display: block;
  margin: 1.25rem auto 0;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.7rem 1.75rem;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  box-shadow: var(--shadow-cta);
}

.try-again-btn:hover { filter: brightness(1.05); }

.history-block {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.history-block h3 {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
  color: var(--muted);
}

.history-list { display: flex; flex-direction: column; gap: 0.4rem; }

.history-empty {
  font-size: 0.85rem;
  color: var(--muted-2);
  margin: 0;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 0.75rem;
  background: var(--inset);
  border-radius: 10px;
  font-size: 0.85rem;
}

.history-wpm {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--accent);
}

.history-meta { color: var(--muted); }

/* SEO sections */
.section {
  margin-bottom: 4.5rem;
}

.section h2 {
  font-size: clamp(1.6rem, 3.5vw, 2.1rem);
  font-weight: 700;
  margin: 0 0 0.75rem;
  letter-spacing: -0.02em;
}

.section-intro {
  color: var(--muted);
  margin: 0 0 1.5rem;
  max-width: 58ch;
  font-size: 0.98rem;
  line-height: 1.65;
}

.formula-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.formula-card {
  padding: 1.4rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
}

.formula-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.formula-card h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 0.35rem;
}

.formula {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--accent);
  margin: 0 0 0.5rem;
}

.formula-card p:last-child {
  font-size: 0.92rem;
  color: var(--muted);
  margin: 0;
  line-height: 1.55;
}

.bench-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--card);
}

.bench-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.bench-table th,
.bench-table td {
  padding: 0.85rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
}

.bench-table th {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--inset);
}

.bench-table tr:last-child td { border-bottom: none; }

.bench-table tr.row-expert td {
  background: var(--accent-soft);
}

.bench-table tr.row-expert .tier {
  color: var(--accent);
  font-weight: 700;
}

.tier {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  background: var(--inset);
  color: var(--ink-soft);
}

.tips-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.tip-card {
  padding: 1.4rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
}

.tip-num {
  display: block;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.tip-card h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 0.4rem;
}

.tip-card p {
  font-size: 0.92rem;
  color: var(--muted);
  margin: 0;
  line-height: 1.55;
}

.tools-block .eyebrow { margin-bottom: 0.35rem; }

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.tool-card {
  display: block;
  padding: 1.25rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.tool-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-key);
}

.tool-icon {
  font-size: 1.25rem;
  display: block;
  margin-bottom: 0.5rem;
}

.tool-card strong {
  display: block;
  font-size: 0.95rem;
  margin-bottom: 0.35rem;
}

.tool-card p {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
}

.faq.section {
  max-width: 760px;
}

.faq-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.faq-list details {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0;
}

.faq-list summary {
  padding: 1rem 1.25rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.faq-list summary::-webkit-details-marker { display: none; }

.faq-list details[open] summary {
  border-bottom: 1px solid var(--border-soft);
}

.faq-list p {
  padding: 1rem 1.25rem 1rem;
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.55;
}

.legal-note {
  margin-top: 1.5rem;
  padding: 1rem 1.15rem;
  background: var(--inset);
  border: 1px solid var(--border);
  border-radius: 14px;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.55;
}

.app-footer {
  text-align: center;
  padding: 2rem 0 1rem;
  font-size: 0.85rem;
  color: var(--muted-2);
}

.app-footer a {
  color: var(--muted-2);
  text-decoration: none;
}

.app-footer a:hover { color: var(--accent); }

@media (max-width: 720px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }

  .stat-card--timer {
    grid-column: span 2;
    flex-direction: row;
    gap: 1rem;
    padding: 0.75rem;
  }

  .formula-grid,
  .tips-grid { grid-template-columns: 1fr; }

  .results-grid { grid-template-columns: repeat(2, 1fr); }

  .passage { font-size: 1.15rem; line-height: 1.9; }
}

@media (max-width: 480px) {
  .tool-section { padding: 1rem; }
  .result-big { font-size: 2.75rem; }
}
