/* ==========================================================================
   Speech & Reading Time Calculator — Design System
   "Manuscript & Stopwatch": cool paper background, ink-charcoal text, a deep
   teal accent (typewriter ribbon / stopwatch face), tabular monospace for
   every computed number. Tokens first, then base, then components. Every
   page — homepage and every generated long-tail page — shares this file.
   ========================================================================== */

:root {
  /* Color */
  --color-bg: #F2F3F5;
  --color-surface: #FFFFFF;
  --color-text: #1B1F24;
  --color-text-muted: #626B76;
  --color-accent: #146464;
  --color-accent-hover: #0F4F4F;
  --color-result-bg: #E9F1F1;
  --color-result-border: #146464;
  --color-success: #2F7D4F;
  --color-error: #C23B3B;
  --color-border: #DDE1E6;

  /* Header/footer/intro band sit on a dark ink surface, distinct from the
     light content/reading/ad areas which stay on --color-bg/--color-surface. */
  --color-ink: #14171B;
  --color-ink-alt: #1F2329;
  --color-ink-text: #F2F3F5;
  --color-ink-text-muted: #9AA3AD;

  /* Type */
  --font-heading: 'Newsreader', Georgia, serif;
  --font-body: 'Public Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Space Mono', 'Courier New', monospace;

  --size-h1: 2.25rem;
  --size-h2: 1.5rem;
  --size-h3: 1.125rem;
  --size-body: 1rem;
  --size-caption: 0.875rem;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 16px;
  --space-4: 24px;
  --space-5: 32px;
  --space-6: 48px;

  /* Shape */
  --radius-control: 6px;
  --radius-card: 10px;

  /* Minimum clearance between an ad slot and the nearest interactive
     control (input/button), per AdSense placement guidance. */
  --space-ad-clearance: 150px;

  /* Motion */
  --transition-fast: 150ms ease;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--size-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-heading);
  font-optical-sizing: auto;
  line-height: 1.2;
  margin: 0 0 var(--space-3);
  color: var(--color-text);
}

h1, h2 { font-weight: 600; }
h3 { font-weight: 500; }

h1 { font-size: var(--size-h1); }
h2 { font-size: var(--size-h2); }
h3 { font-size: var(--size-h3); }

p {
  margin: 0 0 var(--space-3);
}

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

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

small, .caption {
  font-size: var(--size-caption);
  color: var(--color-text-muted);
}

img { max-width: 100%; height: auto; }

/* Focus visibility everywhere — non-negotiable for accessibility */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

/* ==========================================================================
   Layout shell — header/footer are solid dark ink bands bookending the
   lighter page column.
   ========================================================================== */

.site-header {
  background: var(--color-ink);
}

.site-header__bar {
  max-width: 960px;
  margin: 0 auto;
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.site-logo {
  font-family: var(--font-heading);
  font-optical-sizing: auto;
  font-weight: 600;
  font-size: 1.25rem;
  color: var(--color-ink-text);
  text-decoration: none;
}

.site-logo:hover { color: #3FA5A5; }

.site-nav {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.site-nav a {
  color: var(--color-ink-text-muted);
  text-decoration: none;
  font-size: var(--size-caption);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.site-nav a:hover { color: #3FA5A5; }

main {
  max-width: 720px;
  margin: 0 auto;
  padding: var(--space-4);
}

.site-footer {
  background: var(--color-ink);
  margin-top: var(--space-6);
}

.site-footer__bar {
  max-width: 960px;
  margin: 0 auto;
  padding: var(--space-5) var(--space-4);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  justify-content: space-between;
  color: var(--color-ink-text-muted);
  font-size: var(--size-caption);
}

.site-footer a {
  color: var(--color-ink-text);
}

.site-footer a:hover { color: #3FA5A5; }

.footer-links {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  list-style: none;
  margin: 0;
  padding: 0;
}

/* ==========================================================================
   Intro band — a dark ink anchor beneath the header, holding the page's H1
   and a one-line summary. Bookends the page (dark header -> dark intro band
   -> light content/ads/tools -> dark footer) without darkening any
   reading-heavy or ad-bearing area.
   ========================================================================== */

.intro-band {
  background: var(--color-ink-alt);
}

.intro-band__inner {
  max-width: 720px;
  margin: 0 auto;
  padding: var(--space-5) var(--space-4);
}

.intro-band h1 {
  color: var(--color-ink-text);
  margin-bottom: var(--space-2);
}

.intro-band p {
  color: var(--color-ink-text-muted);
  margin: 0;
}

/* ==========================================================================
   Breadcrumbs
   ========================================================================== */

.breadcrumb {
  margin: var(--space-3) 0 var(--space-4);
}

.breadcrumb ol {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin: 0;
  padding: 0;
  font-size: var(--size-caption);
  color: var(--color-text-muted);
}

.breadcrumb li:not(:last-child)::after {
  content: "/";
  margin-left: var(--space-1);
  color: var(--color-border);
}

.breadcrumb a {
  color: var(--color-text-muted);
  text-decoration: none;
}

.breadcrumb a:hover { color: var(--color-accent); text-decoration: underline; }

.breadcrumb [aria-current="page"] {
  color: var(--color-text);
}

/* ==========================================================================
   Ad slots — kept visually distinct as placeholders, spaced away from
   interactive controls per AdSense placement guidance (~150px clearance).
   ========================================================================== */

.ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 90px;
  margin: var(--space-ad-clearance) 0;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-card);
  color: var(--color-text-muted);
  font-size: var(--size-caption);
  background: var(--color-surface);
}

/* First/last ad slot on a page never needs clearance from page edges,
   only from the interactive elements beside it. */
main > .ad-slot:first-child { margin-top: 0; }
main > .ad-slot:last-child { margin-bottom: 0; }

/* ==========================================================================
   Tool card — the visual focus of every calculator page
   ========================================================================== */

.tool-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: var(--space-4);
  margin: var(--space-4) 0 var(--space-5);
  box-shadow: 0 2px 12px rgba(20, 23, 27, 0.08);
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.field-row {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-3);
}

.field-row > .field-group {
  flex: 1 1 140px;
}

label {
  font-weight: 500;
  font-size: var(--size-caption);
  color: var(--color-text);
}

input[type="text"],
input[type="number"],
select,
textarea {
  font-family: var(--font-body);
  font-size: 1rem;
  padding: var(--space-2) var(--space-3);
  min-height: 44px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  color: var(--color-text);
  width: 100%;
}

textarea {
  min-height: 140px;
  resize: vertical;
  font-family: var(--font-body);
  line-height: 1.5;
}

input::placeholder, textarea::placeholder {
  color: var(--color-text-muted);
  opacity: 1;
}

.word-count-live {
  display: block;
  margin-top: var(--space-1);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--size-caption);
  color: var(--color-text-muted);
}

.word-count-live strong {
  color: var(--color-accent);
  font-weight: 700;
}

.field-divider {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-1) 0 var(--space-3);
  color: var(--color-text-muted);
  font-size: var(--size-caption);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field-divider::before,
.field-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

fieldset {
  border: none;
  padding: 0;
  margin: 0 0 var(--space-3);
}

legend {
  font-weight: 500;
  font-size: var(--size-caption);
  padding: 0;
  margin-bottom: var(--space-2);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 500;
  border-radius: var(--radius-control);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color var(--transition-fast), transform var(--transition-fast);
}

.btn-primary {
  background: var(--color-accent);
  color: #FFFFFF;
}

.btn-primary:hover { background: var(--color-accent-hover); }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  background: transparent;
  color: var(--color-accent);
  border-color: var(--color-border);
}

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

.error-message {
  margin-top: var(--space-2);
  color: var(--color-error);
  font-size: var(--size-caption);
  font-weight: 600;
}

.error-message[hidden] { display: none; }

/* ==========================================================================
   Lap sheet — the site's signature result display. Styled like a stopwatch
   lap-time log: a dashed tick rule along the top edge (stopwatch bezel
   marks), each row a "lap" with a pace-tier dot and a tabular monospace
   time reading right-aligned like a digital counter.
   ========================================================================== */

.result-box {
  position: relative;
  margin-top: var(--space-4);
  padding: var(--space-4);
  padding-top: calc(var(--space-4) + 6px);
  border-radius: var(--radius-control);
  background: var(--color-result-bg);
  border: 1px solid var(--color-result-border);
  overflow: hidden;
}

.result-box::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background-image: repeating-linear-gradient(
    90deg,
    var(--color-result-border) 0,
    var(--color-result-border) 2px,
    transparent 2px,
    transparent 10px
  );
  opacity: 0.85;
}

.result-box[hidden] { display: none; }

.result-box.is-updated {
  animation: result-highlight 400ms ease;
}

@keyframes result-highlight {
  from { background-color: #CFE4E4; }
  to { background-color: var(--color-result-bg); }
}

.result-headline {
  margin: 0 0 var(--space-3);
  font-size: 1.0625rem;
  color: var(--color-text);
}

.result-headline .headline-time {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--color-accent);
}

.lap-sheet {
  list-style: none;
  margin: 0;
  padding: 0;
}

.lap-sheet li {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  border-bottom: 1px dashed var(--color-border);
}

.lap-sheet li:last-child { border-bottom: none; }

.lap-dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--color-accent);
}

.lap-dot--slow { background: #7C8792; }
.lap-dot--fast { background: #3FA5A5; }

.lap-label {
  flex: 1 1 auto;
  min-width: 0;
}

.lap-label__name {
  display: block;
  font-weight: 500;
  color: var(--color-text);
}

.lap-label__note {
  display: block;
  font-size: var(--size-caption);
  color: var(--color-text-muted);
}

.lap-time {
  flex: none;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--color-accent);
  text-align: right;
}

.lap-time__range {
  display: block;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--size-caption);
  font-weight: 400;
  color: var(--color-text-muted);
  text-align: right;
}

.result-note {
  margin-top: var(--space-3);
  color: var(--color-text-muted);
  font-size: var(--size-caption);
  font-family: var(--font-body);
}

/* Content sections below the tool */
.content-section {
  margin-top: var(--space-6);
}

.content-section h2 {
  margin-bottom: var(--space-2);
}

.related-links ul {
  padding-left: var(--space-4);
}

.faq-item {
  margin-bottom: var(--space-4);
}

.faq-item h3 {
  margin-bottom: var(--space-1);
}

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

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* Responsive */
@media (max-width: 600px) {
  :root {
    --size-h1: 1.75rem;
    --size-h2: 1.25rem;
  }

  .field-row {
    flex-direction: column;
  }

  .field-row > .field-group {
    flex: 1 1 auto;
  }

  .site-header__bar {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }

  .lap-sheet li {
    flex-wrap: wrap;
  }

  .lap-time {
    margin-left: auto;
  }
}
