/* theme.css: Cron To Timer. "Change-ticket desk": cool grey paper, ink, one deep teal accent,
   monospace for every crontab field, directive, filename and timestamp. Signature: the report
   sits in a perforated ticket (a row of punched holes along its top edge). Loaded after
   styles.css; the builder adds layout only, never colours, radii, shadows or font sizes.
   Contrast ratios (WCAG 2.x, approximate) are noted beside each text pair. */

:root {
  color-scheme: light dark;

  /* Palette (light) */
  --bg: #f3f5f6;
  --surface: #ffffff;
  --raised: #e9edef;
  --text: #172026;            /* ~16:1 on --surface, ~15:1 on --bg */
  --muted: #4a5560;           /* ~7.6:1 on --surface, ~7:1 on --bg, ~6.4:1 on --raised */
  --border: #d5dbdf;
  --border-strong: #87919a;   /* ~3.3:1 on --surface: input outlines (non-text) */
  --accent: #0f6b66;          /* ~6.3:1 with --on-accent */
  --accent-hover: #0b5753;
  --accent-active: #084541;
  --accent-text: #0f6b66;     /* ~6.3:1 on --surface, ~5.8:1 on --bg */
  --accent-tint: #dff0ee;
  --on-accent: #ffffff;
  --success: #1d6b3a;         /* ~6.4:1 on --surface, ~5.8:1 on --success-tint */
  --success-tint: #e5f3ea;
  --warning: #8a5300;         /* ~6.3:1 on --surface, ~5.6:1 on --warning-tint */
  --warning-edge: #d08a17;    /* edges only, never text */
  --warning-tint: #fbf0d9;
  --danger: #b42318;          /* ~6.5:1 on --surface, ~5.8:1 on --danger-tint */
  --danger-tint: #fdecea;
  --neutral-tint: #eceff1;    /* Unknown tile; --text on it ~14:1 */

  /* Type */
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --text-xs: 0.8125rem;   /* 13px caps labels */
  --text-sm: 0.9375rem;   /* 15px hints, errors, notes, report */
  --text-md: 1.0625rem;   /* 17px body */
  --text-lg: 1.3125rem;   /* 21px h2, verdict values */
  --text-2xl: clamp(1.75rem, 4.6vw, 2.5rem); /* h1 */

  /* Space */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;

  /* Radii and shadows */
  --r-s: 6px;
  --r-m: 10px;
  --r-l: 14px;
  --shadow-1: 0 1px 2px rgb(23 32 38 / 0.06), 0 2px 8px rgb(23 32 38 / 0.05);
  --shadow-2: 0 8px 28px rgb(23 32 38 / 0.16);

  /* Motion */
  --fast: 160ms;
  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);

  /* Template variables, mapped so its own rules follow the theme */
  --line: var(--border);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111517;
    --surface: #181d20;
    --raised: #21282c;
    --text: #e6eaec;            /* ~15:1 on --bg, ~14:1 on --surface */
    --muted: #a3adb4;           /* ~8:1 on --bg, ~7.3:1 on --surface, ~6.4:1 on --raised */
    --border: #2c3438;
    --border-strong: #66717a;   /* ~3.4:1 on --surface */
    --accent: #5fd0c4;          /* ~9:1 with --on-accent */
    --accent-hover: #7edbd1;
    --accent-active: #9ce4dc;
    --accent-text: #6fd6ca;     /* ~9.5:1 on --surface */
    --accent-tint: #14302d;
    --on-accent: #06201e;
    --success: #6fd394;         /* ~8.3:1 on --success-tint */
    --success-tint: #17291f;
    --warning: #f0b85a;         /* ~9:1 on --warning-tint */
    --warning-edge: #c98a26;
    --warning-tint: #2e2412;
    --danger: #ff8f85;          /* ~7.9:1 on --danger-tint */
    --danger-tint: #2f1a19;
    --neutral-tint: #262d32;    /* --text on it ~11:1 */
    --shadow-1: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow-2: 0 10px 32px rgb(0 0 0 / 0.55);
  }
}

/* ---------- Page ---------- */

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

header, main, footer { max-width: 60rem; padding-left: var(--s5); padding-right: var(--s5); }

header {
  padding-top: var(--s3);
  padding-bottom: var(--s3);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}
.brand::before {
  content: "";
  width: 24px;
  height: 24px;
  flex: none;
  background: url('./icons/favicon.svg') center / 24px 24px no-repeat;
}
header nav a {
  padding: 0 var(--s3);
  border-radius: var(--r-s);
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
  transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease);
}
header nav a:hover { background: var(--raised); color: var(--text); }
header nav a:active { background: var(--border); }

main { padding-top: var(--s6); padding-bottom: var(--s6); }

h1 {
  font-size: var(--text-2xl);
  line-height: 1.12;
  letter-spacing: -0.02em;
  margin: 0 0 var(--s3);
  max-width: 34ch;
}
.lede { font-size: 1.125rem; color: var(--muted); max-width: 62ch; margin: 0 0 var(--s6); }

h2 {
  font-size: var(--text-lg);
  line-height: 1.3;
  letter-spacing: -0.01em;
  margin: var(--s7) 0 var(--s3);
}
h3 { font-size: var(--text-md); margin: var(--s5) 0 var(--s1); }
main > p, main > ol, main > ul, .example > p { max-width: 68ch; }
main li + li { margin-top: var(--s2); }

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

code, kbd, samp, pre, .mono { font-family: var(--font-mono); }
code, kbd, samp { font-size: 0.92em; }
:not(pre) > code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--raised);
  overflow-wrap: anywhere;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px var(--accent-tint);
}

/* ---------- Tool panel ---------- */

.tool {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-l);
  box-shadow: var(--shadow-1);
  padding: var(--s5);
}

.group-head { margin: 0 0 var(--s3); }
.group-head span {
  display: block;
  padding-bottom: var(--s2);
  border-bottom: 2px solid var(--text);
  font: 700 var(--text-xs)/1.4 var(--font-mono);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text);
}
.group-head.after { margin-top: var(--s2); }
.group-head.after span { border-bottom-color: var(--accent); }

.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: var(--s5);
}
.unit { min-width: 0; }

.field { display: flex; flex-direction: column; min-width: 0; margin: 0 0 var(--s3); }
.field.name { margin-bottom: 0; }
.field label {
  font-weight: 650;
  font-size: var(--text-md);
  margin-bottom: var(--s1);
}
.field .hint {
  font-size: var(--text-sm);
  color: var(--muted);
  margin: 0 0 var(--s2);
}
.field textarea, .field input[type="text"] {
  width: 100%;
  padding: var(--s3);
  font: 0.9375rem/1.55 var(--font-mono);
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-m);
  tab-size: 4;
  transition: border-color var(--fast) var(--ease), background-color var(--fast) var(--ease);
}
.field input[type="text"] { min-height: 44px; padding-top: var(--s2); padding-bottom: var(--s2); }
.field textarea { min-height: 6rem; resize: vertical; }
.unit .field textarea { min-height: 15rem; }
.field textarea::placeholder, .field input::placeholder { color: var(--muted); opacity: 1; }
.field textarea:hover, .field input[type="text"]:hover { border-color: var(--text); }
.field textarea:focus-visible, .field input[type="text"]:focus-visible { background: var(--surface); border-color: var(--accent); }

/* Field error: one line reserved so nothing jumps when it appears. */
.field-error {
  min-height: 1.5em;
  margin: var(--s1) 0 0;
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--danger);
  font-weight: 600;
}
.field-error:not(:empty)::before {
  content: "!";
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: var(--s2);
  vertical-align: -2px;
  border-radius: 50%;
  background: var(--danger);
  color: var(--surface); /* ~6.5:1 light, ~7.5:1 dark */
  font: 800 11px/16px var(--font-ui);
  text-align: center;
}
.field.invalid textarea, .field.invalid input[type="text"],
.field textarea[aria-invalid="true"], .field input[aria-invalid="true"] {
  border-color: var(--danger);
  border-width: 2px;
  padding-left: calc(var(--s3) - 1px);
  padding-right: calc(var(--s3) - 1px);
  background: var(--danger-tint);
}

/* ---------- Buttons ---------- */

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s3);
  margin: var(--s3) 0 0;
}
.actions button, .btn {
  min-height: 44px;
  padding: 0 var(--s5);
  border-radius: var(--r-m);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color var(--fast) var(--ease), border-color var(--fast) var(--ease), color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.actions button:active:not(:disabled), .btn:active { transform: translateY(1px); }

/* Primary: Compare. The only filled button on the page. */
.actions .primary, #compare {
  min-height: 48px;
  min-width: 10rem;
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow-1);
}
.actions .primary:hover, #compare:hover { background: var(--accent-hover); }
.actions .primary:active, #compare:active { background: var(--accent-active); }

/* Secondary: Copy report. Fixed width so "Copied" does not shift the row. */
.actions .secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
#copy { min-width: 9.5rem; }
.actions .secondary:hover:not(:disabled) { background: var(--raised); border-color: var(--text); }
.actions .secondary:active:not(:disabled) { background: var(--border); }
.actions button:disabled {
  cursor: not-allowed;
  background: var(--raised);
  border-color: var(--border);
  color: var(--muted);
  box-shadow: none;
}

/* Quiet: Load the worked example, Clear. */
.actions .quiet {
  background: transparent;
  color: var(--accent-text);
  padding: 0 var(--s3);
}
.actions .quiet:hover { background: var(--accent-tint); }
.actions .quiet:active { background: var(--raised); }
.actions .quiet.push, #clear { margin-left: auto; color: var(--muted); }
.actions .quiet.push:hover, #clear:hover { color: var(--text); background: var(--raised); }

.actions .kbd-hint { font-size: var(--text-xs); color: var(--muted); }
kbd {
  padding: 1px 5px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface);
  font-size: 0.85em;
}

/* ---------- Status line ---------- */

#status {
  min-height: 1.6em;
  margin: var(--s4) 0 0;
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--muted);
}
#status.error { color: var(--danger); }
#status.ok { color: var(--success); }

/* ---------- Output ---------- */

#output { min-height: 0; }
#output:empty { display: none; }
#output:not(:empty) {
  margin-top: var(--s4);
  padding-top: var(--s5);
  border-top: 1px solid var(--border);
}
#output > .verdicts, #output > .ticket, #output > .callout { animation: rise 180ms var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Empty state */
.empty-state {
  display: flex;
  gap: var(--s4);
  align-items: flex-start;
  padding: var(--s5);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-m);
  color: var(--muted);
  background: var(--bg);
}
.empty-state strong { display: block; color: var(--text); margin-bottom: var(--s1); }
.empty-state p { margin: 0; max-width: 60ch; }
/* A small drawn clock, the brand's face in outline. */
.empty-mark {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background:
    linear-gradient(var(--muted), var(--muted)) 13px 6px / 2px 9px no-repeat,
    linear-gradient(var(--muted), var(--muted)) 13px 13px / 8px 2px no-repeat;
}

/* Verdict tiles: the two answers, biggest type in the panel. */
.verdicts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s3);
  margin: 0 0 var(--s4);
}
.verdict {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--s1);
  min-height: 7.5rem;
  padding: var(--s4) var(--s4) var(--s4) calc(var(--s4) + 4px);
  padding-right: calc(var(--s4) + 32px);
  border: 1px solid var(--border);
  border-radius: var(--r-m);
  background: var(--surface);
  box-shadow: inset 5px 0 0 var(--border-strong);
  min-width: 0;
}
.verdict .k {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}
.verdict .v {
  font-size: var(--text-lg);
  font-weight: 750;
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.verdict .d {
  font-size: var(--text-sm);
  color: var(--text);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
/* Icon: a 24px disc top-right, with a drawn mark. */
.verdict::before {
  content: "";
  position: absolute;
  top: var(--s4);
  right: var(--s4);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--muted);
}
.verdict::after {
  position: absolute;
  top: var(--s4);
  right: var(--s4);
  width: 24px;
  height: 24px;
  color: var(--surface);
  font: 800 15px/24px var(--font-ui);
  text-align: center;
}
.verdict.match, .verdict.unchanged { background: var(--success-tint); border-color: transparent; box-shadow: inset 5px 0 0 var(--success); }
.verdict.match .v, .verdict.unchanged .v { color: var(--success); }
.verdict.match::before, .verdict.unchanged::before { background: var(--success); }
.verdict.match::after, .verdict.unchanged::after {
  content: "";
  top: calc(var(--s4) + 5px);
  right: calc(var(--s4) + 9px);
  width: 6px;
  height: 11px;
  border: solid var(--surface);
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
}
.verdict.different { background: var(--danger-tint); border-color: transparent; box-shadow: inset 5px 0 0 var(--danger); }
.verdict.different .v { color: var(--danger); }
.verdict.different::before { background: var(--danger); }
.verdict.different::after {
  content: "";
  top: calc(var(--s4) + 6px);
  right: calc(var(--s4) + 6px);
  width: 12px;
  height: 12px;
  background:
    linear-gradient(45deg, transparent 42%, var(--surface) 42% 58%, transparent 58%),
    linear-gradient(-45deg, transparent 42%, var(--surface) 42% 58%, transparent 58%);
}
.verdict.changed { background: var(--warning-tint); border-color: transparent; box-shadow: inset 5px 0 0 var(--warning-edge); }
.verdict.changed .v { color: var(--warning); }
.verdict.changed::before { background: var(--warning); }
.verdict.changed::after { content: "!"; }
.verdict.unknown {
  background: var(--neutral-tint);
  box-shadow: inset 5px 0 0 var(--border-strong);
}
.verdict.unknown .v { color: var(--text); }
.verdict.unknown::before { background: var(--muted); }
.verdict.unknown::after { content: "?"; }

/* Callouts: root warning, timing flags, worked-example note. */
.callout {
  margin: 0 0 var(--s3);
  padding: var(--s3) var(--s4);
  border-radius: var(--r-m);
  background: var(--raised);
  box-shadow: inset 4px 0 0 var(--border-strong);
  font-size: var(--text-sm);
  max-width: none;
}
.callout.warn { background: var(--warning-tint); box-shadow: inset 4px 0 0 var(--warning-edge); }
.callout strong { color: var(--text); }

/* Signature: the perforated ticket that holds the Markdown report. */
/* The ticket is --bg paper on the white panel; its top edge is punched with half-circle holes
   in the panel's own colour (--ticket-hole), so they read as cut-outs. */
.ticket {
  --ticket-hole: var(--surface);
  position: relative;
  margin: var(--s4) 0 0;
  padding-top: 8px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-top: 0;
  border-radius: 0 0 var(--r-m) var(--r-m);
  overflow: hidden;
}
.ticket::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 8px;
  background:
    radial-gradient(circle at 8px 0, var(--ticket-hole) 5px, var(--border-strong) 5px 6px, transparent 6.5px) 0 0 / 16px 8px repeat-x,
    linear-gradient(var(--border-strong), var(--border-strong)) 0 0 / 100% 1px no-repeat;
}
.ticket-head, .ticket pre { position: relative; }
.ticket-head {
  display: flex;
  justify-content: space-between;
  gap: var(--s3);
  padding: var(--s2) var(--s4);
  border-bottom: 1px dashed var(--border);
  background: var(--raised);
  font: 700 var(--text-xs)/1.5 var(--font-mono);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}
.ticket-head .n { font-variant-numeric: tabular-nums; letter-spacing: 0; text-transform: none; font-weight: 500; }
.ticket pre, #report {
  margin: 0;
  padding: var(--s4);
  max-height: 32rem;
  overflow: auto;
  font: 0.9375rem/1.6 var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  user-select: text;
  tab-size: 4;
}
.ticket pre::selection, #report ::selection { background: var(--accent-tint); color: var(--text); }
#report:focus-visible { outline-offset: -2px; box-shadow: inset 0 0 0 5px var(--accent-tint); }

/* ---------- Worked example (reading section) ---------- */

.example {
  margin: var(--s4) 0 0;
  padding: var(--s5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-l);
}
.example .files { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--s3); margin: 0 0 var(--s4); }
.example figure { margin: 0; min-width: 0; }
.example figcaption {
  font: 700 var(--text-xs)/1.5 var(--font-mono);
  letter-spacing: 0.04em;
  margin-bottom: var(--s1);
  color: var(--text);
}
.example pre {
  margin: 0;
  padding: var(--s3);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-s);
  font-size: 0.875rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.example .callout { margin: 0; }

/* ---------- Template furniture: styled, never resized ---------- */

.ad-slot { background: var(--raised); border: 1px solid var(--border); }
.ad-label { color: var(--muted); opacity: 1; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 700; }
.house-card { background: var(--surface); border: 1px solid var(--border); transition: border-color var(--fast) var(--ease); }
.house-card:hover { border-color: var(--accent); }
.house-card strong { color: var(--accent-text); }
.house-card span { color: var(--muted); }

.consent {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-l);
  box-shadow: var(--shadow-2);
}
.consent button { border-color: var(--border-strong); border-radius: var(--r-m); font-weight: 600; transition: background-color var(--fast) var(--ease); }
.consent button:hover { background: var(--raised); }
.consent button:active { background: var(--border); }

footer {
  opacity: 1;
  color: var(--muted);
  border-top: 1px solid var(--border);
  margin-top: var(--s7);
  padding-top: var(--s5);
  padding-bottom: var(--s6);
  font-size: var(--text-sm);
}
footer a { color: var(--muted); }
footer a:hover { color: var(--text); }

/* ---------- Phone ---------- */

@media (max-width: 46rem) {
  header, main, footer { padding-left: var(--s4); padding-right: var(--s4); }
  main { padding-top: var(--s5); }
  .tool { padding: var(--s4); margin: 0 calc(-1 * var(--s2)); border-radius: var(--r-m); }
  .pair { grid-template-columns: 1fr; }
  .unit .field textarea { height: 11rem; min-height: 11rem; }
  .actions { gap: var(--s2); }
  .actions .primary, #compare { flex: 1 1 100%; }
  .actions .secondary, #copy, #example { flex: 1 1 auto; }
  .actions .quiet.push, #clear { margin-left: 0; }
  .actions .kbd-hint { display: none; }
  .verdicts { grid-template-columns: 1fr; }
  .verdict { min-height: 0; }
  .ticket pre, #report { font-size: 0.875rem; padding: var(--s3); }
  .example { padding: var(--s4); }
  .example .files { grid-template-columns: 1fr; }
}

/* ---------- Motion off ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  .actions button:active:not(:disabled), .btn:active { transform: none; }
}
