/* Rapid Automation Software — shared design system.
   Tokens first, then layout, components, and the four countdown presets. */

:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --sunk: #eeeeeb;
  --ink: #1a1a17;
  --muted: #5f5f57;
  --hairline: #e2e2dc;
  --accent: #b8420f;
  --accent-ink: #a63b0c;
  --on-accent: #ffffff;
  --danger: #b3261e;
  --focus: #1a73e8;
  --radius: 10px;
  --maxw: 1080px;
  --shadow: 0 1px 2px rgba(20, 20, 15, .06), 0 12px 30px -16px rgba(20, 20, 15, .18);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14141a;
    --surface: #1c1c24;
    --sunk: #24242e;
    --ink: #ececf2;
    --muted: #9a9aa6;
    --hairline: #2f2f3a;
    --accent: #ec7345;
    --accent-ink: #f0855c;
    --on-accent: #1a1109;
    --danger: #f0857e;
    --focus: #6aa9ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 16px 36px -18px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.wrap.narrow { max-width: 640px; }

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

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 3px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--surface);
  padding: 10px 16px;
  z-index: 10;
}
.skip-link:focus { left: 8px; top: 8px; }

/* ---------- header / footer ---------- */
.site-header {
  border-bottom: 1px solid var(--hairline);
  background: var(--surface);
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 60px;
  gap: 16px;
}
.brand {
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
}
.site-nav a {
  font-size: .92rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--muted);
}
.site-nav a:hover { color: var(--ink); }

.site-main { flex: 1 0 auto; padding: 48px 0 72px; }

.site-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--hairline);
  padding: 24px 0;
  color: var(--muted);
  font-size: .85rem;
}
.site-footer p { margin: 0; }

/* ---------- typography ---------- */
h1 {
  font-size: clamp(1.7rem, 4vw, 2.4rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
  text-wrap: balance;
}
.lede { font-size: 1.05rem; color: var(--muted); margin: 0 0 28px; }
.hint { font-size: .85rem; color: var(--muted); margin: 6px 0 0; }
.optional { color: var(--muted); font-weight: 400; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 600;
  font-size: .95rem;
  line-height: 1;
  padding: 12px 20px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .12s, border-color .12s, transform .12s;
}
.btn:active { transform: translateY(1px); }
@media (prefers-reduced-motion: reduce) { .btn:active { transform: none; } }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-ink); }
.btn-ghost { background: transparent; border-color: var(--hairline); color: var(--ink); }
.btn-ghost:hover { background: var(--sunk); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: var(--on-accent); }
.btn[disabled] { opacity: .55; pointer-events: none; }

/* ---------- forms ---------- */
.form { margin-top: 8px; }
.field { margin-bottom: 20px; border: 0; padding: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 480px) { .field-row { grid-template-columns: 1fr; } }

label, legend {
  display: block;
  font-weight: 600;
  font-size: .9rem;
  margin-bottom: 6px;
}
input[type="text"],
input[type="date"],
input[type="time"],
select,
textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 11px 12px;
}
textarea { resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  border-color: var(--focus);
  outline-offset: 0;
}
.field.invalid input,
.field.invalid select,
.field.invalid textarea { border-color: var(--danger); }

.error { color: var(--danger); font-size: .84rem; margin: 6px 0 0; min-height: 0; }
.error:empty { display: none; }
.form-error {
  color: var(--danger);
  font-size: .9rem;
  margin: 0 0 16px;
  padding: 10px 12px;
  border: 1px solid var(--danger);
  border-radius: var(--radius);
}
.form-error:empty { display: none; }

.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 8px; }

/* ---------- theme picker ---------- */
.themes .theme-options { display: flex; flex-wrap: wrap; gap: 10px; }
.theme-swatch {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 500;
  min-width: 84px;
}
.theme-swatch input { position: absolute; opacity: 0; }
/* selection ring picks up the swatch's own colour, not the page accent */
.theme-swatch:has(input:checked) {
  border-color: var(--preset-accent, var(--accent));
  box-shadow: 0 0 0 1px var(--preset-accent, var(--accent));
}
.theme-swatch:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.theme-chip {
  width: 100%;
  height: 34px;
  border-radius: 6px;
  background: var(--preset-accent, var(--accent));
  border: 1px solid rgba(0, 0, 0, .12);
}
.theme-name { font-size: .8rem; text-transform: capitalize; color: var(--muted); }
.theme-swatch[data-preset="default"]  { --preset-accent: #b8420f; }
.theme-swatch[data-preset="midnight"] { --preset-accent: #6366f1; }
.theme-swatch[data-preset="sunrise"]  { --preset-accent: #f97316; }
.theme-swatch[data-preset="forest"]   { --preset-accent: #15803d; }

/* ---------- created / manage confirmation ---------- */
.created-banner {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 40px auto 0;
  max-width: 520px;
  text-align: left;
  box-shadow: var(--shadow);
}
.created-banner h2 { font-size: 1rem; margin: 0 0 6px; }
.created-banner p { margin: 0 0 10px; font-size: .9rem; color: var(--muted); }
.copy-row { display: flex; gap: 8px; flex-wrap: wrap; }
.copy-row input { flex: 1; min-width: 220px; font-family: var(--mono); font-size: .85rem; }

/* ---------- countdown page ---------- */
.page-countdown .site-main { display: flex; align-items: center; }
.countdown-stage {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 0 20px;
  text-align: center;
  color: var(--stage-ink, var(--ink));
}
.countdown-eyebrow {
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: .18em;
  font-size: .78rem;
  color: var(--stage-accent, var(--accent-ink));
  margin: 0 0 10px;
}
.countdown-name {
  font-size: clamp(1.8rem, 5vw, 3rem);
  margin: 0 0 28px;
}
.countdown-clock {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: clamp(6px, 2vw, 18px);
  font-variant-numeric: tabular-nums;
}
.countdown-clock .unit { display: flex; flex-direction: column; align-items: center; }
.countdown-clock .num {
  font-family: var(--mono);
  font-weight: 600;
  font-size: clamp(2.4rem, 11vw, 5.5rem);
  line-height: 1;
  color: var(--stage-accent, var(--accent));
}
.countdown-clock .lbl {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--muted);
  margin-top: 8px;
}
.countdown-clock .sep {
  font-family: var(--mono);
  font-size: clamp(1.6rem, 7vw, 3.4rem);
  line-height: 1;
  color: var(--muted);
  align-self: flex-start;
  /* nudge the colon toward the optical centre of the digits */
  transform: translateY(0.35em);
}
.countdown-when {
  margin: 28px 0 0;
  font-size: .95rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.countdown-desc {
  margin: 20px auto 0;
  max-width: 52ch;
  color: var(--stage-ink, var(--ink));
}
.countdown-actions {
  margin-top: 32px;
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.countdown-make {
  margin: 22px 0 0;
  font-size: .9rem;
}
.countdown-make a {
  color: var(--muted);
  text-decoration: none;
}
.countdown-make a:hover { color: var(--stage-ink, var(--ink)); text-decoration: underline; }
.countdown-stage.is-elapsed .countdown-clock .num { color: var(--muted); }

/* ---------- countdown presets ----------
   Scoped to :root so the tokens only re-theme the page, never a descendant
   that happens to carry data-preset (e.g. the theme swatches on the form). */
:root[data-preset="midnight"] {
  --bg: #0b1020;
  --surface: #141a2e;
  --sunk: #1b2238;
  --ink: #e7ebf7;
  --muted: #98a2c0;
  --hairline: #263050;
  --accent: #818cf8;
  --accent-ink: #a5b0ff;
  --on-accent: #0b1020;
  --stage-accent: #a5b4fc;
  color-scheme: dark;
}
:root[data-preset="sunrise"] {
  --bg: #fff6ee;
  --surface: #ffffff;
  --sunk: #ffe9d7;
  --ink: #3a2415;
  --muted: #8a6b52;
  --hairline: #f3d8c1;
  --accent: #ea580c;
  --accent-ink: #c2410c;
  --on-accent: #ffffff;
  --stage-accent: #ea580c;
  color-scheme: light;
}
:root[data-preset="forest"] {
  --bg: #f0f6f1;
  --surface: #ffffff;
  --sunk: #dcebe0;
  --ink: #16281c;
  --muted: #4d6b56;
  --hairline: #cbe0d1;
  --accent: #15803d;
  --accent-ink: #166534;
  --on-accent: #ffffff;
  --stage-accent: #15803d;
  color-scheme: light;
}

/* ---------- error page ---------- */
.error-block { text-align: center; padding-top: 32px; }
.error-code {
  font-family: var(--mono);
  font-size: 3rem;
  font-weight: 600;
  color: var(--accent);
  margin: 0;
}

/* ---------- home page ---------- */
.eyebrow {
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: .16em;
  font-size: .74rem;
  color: var(--accent-ink);
  margin: 0 0 14px;
}
.section-heading {
  font-size: 1rem;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  margin: 0 0 20px;
}

.page-home .site-main { padding: 0 0 64px; }

.home-hero {
  padding: 72px 0 56px;
  border-bottom: 1px solid var(--hairline);
  background: var(--surface);
}
.home-hero h1 {
  font-size: clamp(2rem, 5.5vw, 3.1rem);
  max-width: 16ch;
}
.home-hero .lede { max-width: 52ch; }

.home-tools { padding: 56px 0 8px; }

.tool-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.tool-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
/* the title link stretches to cover the whole card */
.tool-link { color: inherit; text-decoration: none; }
.tool-link::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}
.tool-link:focus-visible { outline: none; }
.tool-card:has(.tool-link:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.tool-card:hover:not(.is-soon) { border-color: var(--accent); }
.tool-icon { font-size: 1.7rem; line-height: 1; }
.tool-name { font-weight: 600; font-size: 1.05rem; }
.tool-desc { color: var(--muted); font-size: .92rem; }
.tool-cta {
  margin-top: 6px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--accent-ink);
}
.tool-cta.soon {
  align-self: flex-start;
  font-weight: 500;
  color: var(--muted);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.tool-card.is-soon { opacity: .78; box-shadow: none; }

.home-about { padding: 48px 0 0; }
.home-about p { color: var(--muted); max-width: 64ch; }
.home-about p + p { margin-top: 12px; }
