/* Oddsprig Countdown Timer — theme and layout.
   Mobile-first, accessible, self-hosted SIL OFL fonts only. Do not load a font CDN.
   Tokens follow the live image tools and the site theme toggle. Dark is the default.
   Scope lives under body.cd-tool so the shared header, Index menu and theme
   toggle keep their own styles. */

@font-face {
  font-family: "Source Serif 4";
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url("../fonts/source-serif-4-latin-wght-normal.woff2") format("woff2-variations"),
       url("../fonts/source-serif-4-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url("../fonts/source-sans-3-latin-wght-normal.woff2") format("woff2-variations"),
       url("../fonts/source-sans-3-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Source Sans 3";
  font-style: italic;
  font-weight: 200 900;
  font-display: swap;
  src: url("../fonts/source-sans-3-latin-wght-italic.woff2") format("woff2-variations"),
       url("../fonts/source-sans-3-latin-wght-italic.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root,
html[data-oddsprig-theme="dark"] {
  color-scheme: dark;
  --cd-bg: #152227;
  --cd-panel: #1c2d31;
  --cd-soft: #24383c;
  --cd-ink: #edf2e9;
  --cd-muted: #b9c9c8;
  --cd-line: #38494b;
  --cd-lime: #c8e6a0;
  --cd-lime-hover: #ddf1bf;
  --cd-gold: #e5ce8e;
  --cd-focus: #e5ce8e;
  --cd-accent: #c8e6a0;
  --cd-accent-ink: #152227;
  --cd-danger: #f3b98e;
  --cd-serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --cd-sans: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
  --cd-radius: 15px;
  --cd-radius-sm: 9px;
  --cd-gutter: 16px;
  --cd-content: 1502px;
}

html[data-oddsprig-theme="light"] {
  color-scheme: light;
  --cd-bg: #eeece4;
  --cd-panel: #f4f0e6;
  --cd-soft: #e2ebed;
  --cd-ink: #20383e;
  --cd-muted: #50686c;
  --cd-line: #a1b3af;
  --cd-lime: #256358;
  --cd-lime-hover: #2e7769;
  --cd-gold: #9a5018;
  --cd-focus: #9a5018;
  --cd-accent: #256358;
  --cd-accent-ink: #eeece4;
  --cd-danger: #8a3410;
}

@media (min-width: 650px) {
  :root,
  html[data-oddsprig-theme="light"],
  html[data-oddsprig-theme="dark"] { --cd-gutter: 32px; }
}

@media (min-width: 651px) {
  body.cd-tool.oddsprig-shared-shell { --cd-gutter: 48px; }
}

body.cd-tool {
  margin: 0;
  min-width: 0;
  background: var(--cd-bg);
  color: var(--cd-ink);
  font: 16px/1.55 var(--cd-sans);
  overflow-wrap: break-word;
}

body.cd-tool *,
body.cd-tool *::before,
body.cd-tool *::after { box-sizing: border-box; }

body.cd-tool img,
body.cd-tool svg,
body.cd-tool canvas { max-width: 100%; }

body.cd-tool h1,
body.cd-tool h2,
body.cd-tool h3,
body.cd-tool p { margin: 0; }

body.cd-tool h1,
body.cd-tool h2 {
  font-family: var(--cd-serif);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

body.cd-tool a { color: var(--cd-accent); text-underline-offset: 0.2em; }
body.cd-tool a:hover { color: var(--cd-gold); }

body.cd-tool :focus-visible {
  outline: 3px solid var(--cd-focus);
  outline-offset: 3px;
}

body.cd-tool button,
body.cd-tool .cd-button,
body.cd-tool select,
body.cd-tool textarea,
body.cd-tool input:not([type="range"]):not([type="color"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]) {
  font: inherit;
  color: var(--cd-ink);
  background: var(--cd-soft);
  border: 1px solid var(--cd-line);
  border-radius: var(--cd-radius-sm);
  padding: 8px 12px;
}

body.cd-tool button,
body.cd-tool .cd-button,
body.cd-tool select { cursor: pointer; }

body.cd-tool button,
body.cd-tool .cd-button,
body.cd-tool select,
body.cd-tool input[type="checkbox"],
body.cd-tool input[type="color"] {
  min-height: 44px;
  touch-action: manipulation;
}

body.cd-tool button:hover:not(:disabled),
body.cd-tool .cd-button:hover { border-color: var(--cd-lime); }

body.cd-tool button:disabled { opacity: 0.45; cursor: default; }

body.cd-tool .cd-primary,
body.cd-tool button.cd-primary {
  background: var(--cd-lime);
  color: var(--cd-accent-ink);
  border-color: var(--cd-lime);
  font-weight: 750;
}

body.cd-tool .cd-primary:hover:not(:disabled) {
  background: var(--cd-lime-hover);
  border-color: var(--cd-lime-hover);
}

body.cd-tool [hidden] { display: none !important; }

body.cd-tool input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}

.cd-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.cd-skip {
  position: absolute;
  top: -100px;
  left: 1rem;
  z-index: 100;
  min-height: 44px;
  padding: 0.6rem 1rem;
  background: var(--cd-lime);
  color: var(--cd-accent-ink);
  font-weight: 650;
  text-decoration: none;
}
.cd-skip:focus { top: 0.5rem; }

/* Fallback nav when /navigation.css is not on this host */
body.cd-tool .oddsprig-nav-header {
  background: #152227;
  color: #edf2e9;
  border-bottom: 1px solid #38494b;
}
body.cd-tool .oddsprig-nav-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: calc(100% - var(--cd-gutter));
  max-width: var(--cd-content);
  margin-inline: auto;
  padding: 12px 0;
}
body.cd-tool .oddsprig-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: inherit;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.04em;
}
body.cd-tool .oddsprig-logo { width: 32px; height: 32px; }
body.cd-tool .oddsprig-main-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
}
body.cd-tool .oddsprig-main-nav a { color: #c8e6a0; text-decoration: none; }
body.cd-tool .oddsprig-main-nav a[aria-current="page"] { color: #e5ce8e; }

body.cd-tool.oddsprig-shared-shell main#main,
body.cd-tool:not(.oddsprig-shared-shell) main#main,
body.cd-licenses main#main {
  box-sizing: border-box;
  width: calc(100% - var(--cd-gutter));
  max-width: var(--cd-content);
  margin-inline: auto;
  padding: 24px 0 48px;
}

.cd-intro { margin-bottom: 16px; }
.cd-intro h1 { font-size: clamp(1.65rem, 3vw, 2.15rem); }
.cd-eyebrow {
  margin: 0 0 6px;
  color: var(--cd-gold);
  font-size: 0.69rem;
  font-weight: 650;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}
.cd-explainer {
  max-width: 85ch;
  margin: 0.4rem 0 0;
  color: var(--cd-muted);
}
.cd-trust {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}
.cd-trust li {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 4px 10px;
  border: 1px solid var(--cd-line);
  border-radius: 999px;
  background: var(--cd-panel);
  font-size: 0.8125rem;
  font-weight: 650;
}

.cd-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.cd-panel {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--cd-line);
  border-radius: var(--cd-radius);
  background: var(--cd-panel);
}

.cd-panel h2 { font-size: 1.25rem; margin-bottom: 12px; }

.cd-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 16px;
}

.cd-presets button[aria-pressed="true"] {
  background: var(--cd-lime);
  color: var(--cd-accent-ink);
  border-color: var(--cd-lime);
  font-weight: 700;
}

.cd-birthday {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
  margin: 0 0 16px;
  padding: 12px;
  border: 1px dashed var(--cd-line);
  border-radius: var(--cd-radius-sm);
  background: var(--cd-soft);
}

.cd-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.cd-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cd-field-label {
  font-size: 0.8125rem;
  font-weight: 650;
  color: var(--cd-muted);
}

.cd-field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.cd-help, .cd-note {
  margin-top: 8px;
  color: var(--cd-muted);
  font-size: 0.875rem;
}

#cd-error {
  margin-top: 10px;
  color: var(--cd-danger);
  font-weight: 650;
}

#cd-status { margin-top: 8px; color: var(--cd-muted); font-size: 0.875rem; }

.cd-check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}
.cd-check input { width: 20px; height: 20px; accent-color: var(--cd-lime); }

.cd-color-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.cd-color-row input[type="color"] {
  width: 44px;
  height: 44px;
  padding: 2px;
  background: var(--cd-soft);
  border: 1px solid var(--cd-line);
  border-radius: var(--cd-radius-sm);
}

.cd-file-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.cd-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 12px;
  position: relative;
}

/* Preview */
.cd-preview-wrap { position: relative; }
#cd-preview {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: 280px;
  border-radius: var(--cd-radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 28px 16px 20px;
  color: #edf2e9;
}
#cd-bg-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
  pointer-events: none;
}
#cd-preview.cd-has-photo .cd-scrim,
#cd-preview.cd-has-wash .cd-scrim {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: rgb(0 0 0 / 0.45);
  pointer-events: none;
}
#cd-preview:not(.cd-has-photo):not(.cd-has-wash) .cd-scrim { display: none; }
#cd-confetti-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  pointer-events: none;
}
.cd-preview-inner { position: relative; z-index: 2; width: 100%; }

#cd-preview-title {
  font-family: var(--cd-serif);
  font-size: clamp(1.5rem, 3vw, 2.4rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  margin-bottom: 18px;
}

.cd-units {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 14px;
}
.cd-unit {
  min-width: 4.5rem;
  padding: 10px 8px;
  border-radius: 12px;
  background: rgb(0 0 0 / 0.28);
}
.cd-unit-value {
  display: block;
  font-variant-numeric: tabular-nums;
  font-weight: 750;
  font-size: clamp(1.8rem, 5vw, 3rem);
  line-height: 1;
  letter-spacing: 0.02em;
}
.cd-unit-label {
  display: block;
  margin-top: 6px;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.85;
}

#cd-finished {
  font-family: var(--cd-serif);
  font-size: clamp(1.4rem, 3vw, 2rem);
  margin-top: 8px;
}
#cd-preview.is-finished .cd-units { display: none; }
#cd-preview:not(.is-finished) #cd-finished { display: none; }

#cd-target-label, #cd-warning {
  margin-top: 14px;
  font-size: 0.875rem;
  opacity: 0.9;
}

#cd-preview[data-theme="midnight"] { background: #101820; color: #e5ce8e; }
#cd-preview[data-theme="gold"] { background: #2a1c0e; color: #f3e0a8; }
#cd-preview[data-theme="forest"] { background: #122018; color: #c8e6a0; }
#cd-preview[data-theme="snow"] { background: #d7e4ee; color: #163040; }
#cd-preview[data-theme="snow"] .cd-unit { background: rgb(255 255 255 / 0.55); }
#cd-preview[data-theme="sunset"] { background: #3a1520; color: #f3b98e; }
#cd-preview[data-theme="contrast"] { background: #000; color: #fff; }
#cd-preview[data-theme="contrast"] .cd-unit { background: #111; border: 2px solid #fff; }

#cd-bg-wash {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

#cd-preview.cd-is-fullscreen {
  min-height: 100%;
  border-radius: 0;
  padding: 8vh 6vw;
}
#cd-preview.cd-is-fullscreen #cd-preview-title { font-size: clamp(2rem, 6vw, 5rem); }
#cd-preview.cd-is-fullscreen .cd-unit-value { font-size: clamp(2.5rem, 10vw, 7rem); }

.cd-preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.cd-share-fields { display: grid; gap: 10px; }
.cd-share-fields textarea,
.cd-share-fields input[readonly] { width: 100%; }
.cd-share-fields textarea { min-height: 96px; resize: vertical; font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 0.85rem; }

.cd-guide { margin-top: 24px; }
.cd-guide h2 { font-size: 1.4rem; margin-bottom: 10px; }
.cd-guide h3 { font-family: var(--cd-serif); font-size: 1.05rem; margin: 16px 0 6px; }
.cd-guide ol, .cd-guide p { max-width: 85ch; color: var(--cd-muted); }
.cd-guide ol { padding-left: 1.2rem; }
.cd-guide li { margin: 0.3rem 0; }

.cd-page-footer {
  margin-top: 36px;
  padding-top: 16px;
  border-top: 1px solid var(--cd-line);
  color: var(--cd-muted);
  font-size: 0.9rem;
}
.cd-page-footer p { margin: 6px 0; }
.cd-page-footer .wordmark {
  font-weight: 700;
  color: var(--cd-ink);
  text-decoration: none;
  letter-spacing: 0.04em;
}

@media (min-width: 600px) {
  .cd-field-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

@media (min-width: 851px) {
  .cd-workspace {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
    gap: 16px 20px;
  }
  .cd-form-panel { grid-column: 1; grid-row: 1 / span 2; }
  .cd-preview-panel {
    grid-column: 2;
    grid-row: 1;
    position: sticky;
    top: 15px;
  }
  .cd-share-panel { grid-column: 2; grid-row: 2; }
}

@media (prefers-reduced-motion: reduce) {
  body.cd-tool *,
  body.cd-tool *::before,
  body.cd-tool *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

@media (forced-colors: active) {
  .cd-panel,
  body.cd-tool button,
  body.cd-tool .cd-button,
  #cd-preview { border: 2px solid CanvasText; }
  body.cd-tool .cd-primary,
  body.cd-tool button[aria-pressed="true"] {
    background: Highlight;
    color: HighlightText;
  }
}

@media print {
  .cd-skip, .oddsprig-nav-header, .cd-form-panel, .cd-share-panel, .cd-guide, .cd-page-footer, .cd-preview-actions {
    display: none !important;
  }
  body.cd-tool, #cd-preview { background: #fff !important; color: #111 !important; }
  .cd-workspace { display: block; }
  .cd-preview-panel { position: static; }
}

@media (max-width: 650px) {
  body.cd-tool.oddsprig-shared-shell main#main,
  body.cd-tool:not(.oddsprig-shared-shell) main#main { padding: 16px 0 36px; }
  .cd-panel { padding: 16px; }
}

/* Standalone embed page */
body.cd-embed {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvb;
  background: #101820;
  color: #edf2e9;
  font: 16px/1.4 var(--cd-sans);
}
body.cd-embed #cd-preview {
  min-height: 100vh;
  min-height: 100dvb;
  border-radius: 0;
}
body.cd-embed .cd-embed-error {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
}
#cd-bg-wash {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#cd-preview.cd-on-light { color: #152227; }
#cd-preview.cd-on-light .cd-unit { background: rgb(255 255 255 / 0.5); }
