/* =========================================================================
   DecorPalette — style.css
   Modern SaaS UI · light/dark themes · accessible · responsive
   ========================================================================= */

:root {
  color-scheme: light dark;

  /* Brand */
  --brand: #0e7c66;
  --brand-strong: #0a5f4e;
  --brand-contrast: #ffffff;

  /* Neutrals (light theme) */
  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-2: #f0ece4;
  --border: #e2ddd2;
  --text: #17201d;
  --text-muted: #56605c;
  --focus: #0e7c66;

  /* Radii & shadow */
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
  --shadow: 0 1px 2px rgba(16, 24, 20, .06), 0 8px 24px rgba(16, 24, 20, .08);
  --shadow-lg: 0 12px 40px rgba(16, 24, 20, .14);

  /* Fluid type scale */
  --step--1: clamp(.82rem, .78rem + .2vw, .9rem);
  --step-0: clamp(1rem, .95rem + .25vw, 1.08rem);
  --step-1: clamp(1.2rem, 1.1rem + .5vw, 1.4rem);
  --step-2: clamp(1.5rem, 1.3rem + 1vw, 2rem);
  --step-3: clamp(2rem, 1.6rem + 2vw, 3rem);
  --step-4: clamp(2.5rem, 1.9rem + 3vw, 4rem);

  --wrap: 1120px;
  --gap: clamp(1rem, .6rem + 2vw, 2rem);
}

:root[data-theme="dark"],
:root[data-theme="auto"] {
  /* auto falls back to media query below */
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #0b0d10;
    --surface: #14181d;
    --surface-2: #1b2027;
    --border: #2a313a;
    --text: #eef1f4;
    --text-muted: #a4adb6;
    --brand: #2bb596;
    --brand-strong: #1f9c80;
    --focus: #4fd3b4;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.5);
    --shadow-lg: 0 16px 48px rgba(0,0,0,.6);
  }
}

:root[data-theme="dark"] {
  --bg: #0b0d10;
  --surface: #14181d;
  --surface-2: #1b2027;
  --border: #2a313a;
  --text: #eef1f4;
  --text-muted: #a4adb6;
  --brand: #2bb596;
  --brand-strong: #1f9c80;
  --focus: #4fd3b4;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.5);
  --shadow-lg: 0 16px 48px rgba(0,0,0,.6);
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: var(--step-0);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { line-height: 1.15; letter-spacing: -.02em; margin: 0 0 .5em; }
h1 { font-size: var(--step-4); }
h2 { font-size: var(--step-3); }
h3 { font-size: var(--step-1); }
p { margin: 0 0 1rem; }

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

code, kbd {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: .9em;
}
kbd {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 6px; padding: .1em .45em; box-shadow: 0 1px 0 var(--border);
}
code { background: var(--surface-2); border-radius: 6px; padding: .1em .4em; }

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

.wrap { width: min(100% - 2.5rem, var(--wrap)); margin-inline: auto; }

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

.skip-link {
  position: absolute; left: .75rem; top: -3rem;
  background: var(--brand); color: var(--brand-contrast);
  padding: .6rem 1rem; border-radius: var(--radius-sm);
  z-index: 100; transition: top .15s ease;
}
.skip-link:focus { top: .75rem; }

/* ------------------------------------------------------ Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font: inherit; font-weight: 600; cursor: pointer;
  padding: .7rem 1.2rem; border-radius: var(--radius-sm);
  border: 1px solid transparent; text-decoration: none;
  transition: transform .12s ease, background .15s ease, border-color .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: var(--brand-contrast); }
.btn-primary:hover { background: var(--brand-strong); color: #fff; }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand-strong); }

/* ------------------------------------------------------ Header */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 1.5rem; padding: .7rem 0; }
.brand { display: inline-flex; align-items: center; gap: .55rem; color: var(--text); text-decoration: none; font-weight: 700; }
.brand-mark { color: var(--brand); }
.brand-name { font-size: 1.1rem; letter-spacing: -.02em; }

.site-nav { margin-left: auto; }
.site-nav ul { display: flex; gap: 1.25rem; list-style: none; margin: 0; padding: 0; }
.site-nav a { color: var(--text-muted); text-decoration: none; font-weight: 500; font-size: var(--step--1); }
.site-nav a:hover { color: var(--text); }

.theme-toggle {
  display: inline-flex; align-items: center; gap: .45rem;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: 999px; padding: .45rem .8rem; cursor: pointer; font: inherit; font-size: var(--step--1);
}
.theme-toggle:hover { border-color: var(--brand); }
.theme-toggle-icon {
  width: 14px; height: 14px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #ffd479, var(--brand));
}

/* ------------------------------------------------------ Hero */
.hero { padding: clamp(3rem, 2rem + 6vw, 6rem) 0 clamp(2rem, 1rem + 4vw, 4rem); }
.eyebrow {
  text-transform: uppercase; letter-spacing: .12em; font-size: var(--step--1);
  font-weight: 700; color: var(--brand-strong); margin-bottom: 1rem;
}
.hero h1 { max-width: 16ch; }
.lede { font-size: var(--step-1); color: var(--text-muted); max-width: 62ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin: 1.75rem 0; }

.hero-stats { display: flex; flex-wrap: wrap; gap: clamp(1.5rem, 4vw, 3rem); margin: 2rem 0 0; padding: 0; }
.hero-stats div { border-left: 3px solid var(--brand); padding-left: .85rem; }
.hero-stats dt { color: var(--text-muted); font-size: var(--step--1); }
.hero-stats dd { margin: 0; font-size: var(--step-2); font-weight: 700; letter-spacing: -.02em; }

/* ------------------------------------------------- Section shells */
section { padding: clamp(2.5rem, 1.5rem + 4vw, 4.5rem) 0; }
.section-head { max-width: 60ch; margin-bottom: 2rem; }
.section-head p { color: var(--text-muted); margin: 0; }

.generator, .library { background: var(--surface-2); border-block: 1px solid var(--border); }

/* ------------------------------------------------- Controls */
.controls {
  display: grid; gap: 1.25rem; align-items: end;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow);
}
.field { display: flex; flex-direction: column; gap: .45rem; }
.field label { font-weight: 600; font-size: var(--step--1); }
.field select, .field input[type="text"] {
  font: inherit; padding: .6rem .75rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text); width: 100%;
}
.field input[type="range"] { accent-color: var(--brand); width: 100%; }

.color-input { display: flex; gap: .5rem; align-items: center; }
.color-input input[type="color"] {
  inline-size: 46px; block-size: 42px; padding: 0; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: none; cursor: pointer; flex: none;
}
.color-input input[type="text"] { text-transform: uppercase; }

.field-actions { display: flex; flex-wrap: wrap; gap: .6rem; grid-column: 1 / -1; }

/* ------------------------------------------------- Swatches */
.swatches {
  list-style: none; margin: 1.75rem 0 0; padding: 0;
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.swatch {
  border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border);
  background: var(--surface); box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.swatch-color { block-size: clamp(110px, 22vw, 150px); position: relative; }
.swatch-lock {
  position: absolute; top: .6rem; right: .6rem;
  inline-size: 34px; block-size: 34px; border-radius: 50%;
  border: none; cursor: pointer; display: grid; place-items: center;
  background: rgba(255,255,255,.85); color: #17201d; font-size: 15px; line-height: 1;
}
.swatch-lock[aria-pressed="true"] { background: var(--brand); color: #fff; }
.swatch-meta { padding: .75rem .85rem; display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.swatch-hex { font-family: ui-monospace, monospace; font-weight: 600; letter-spacing: .02em; }
.swatch-copy {
  font: inherit; font-size: var(--step--1); cursor: pointer; color: var(--text-muted);
  background: none; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .3rem .55rem;
}
.swatch-copy:hover { color: var(--brand-strong); border-color: var(--brand); }

.status { margin-top: 1rem; min-height: 1.5em; color: var(--text-muted); font-size: var(--step--1); }

/* ------------------------------------------------- Contrast */
.contrast-grid { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); align-items: start; }
.contrast-result {
  grid-column: 1 / -1; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow);
  display: grid; gap: 1rem; grid-template-columns: auto 1fr; align-items: center;
}
.contrast-ratio { font-size: var(--step-3); font-weight: 800; margin: 0; letter-spacing: -.03em; }
.contrast-unit { font-size: var(--step-1); color: var(--text-muted); }
.contrast-preview { border-radius: var(--radius-sm); padding: 1rem 1.25rem; border: 1px solid var(--border); }
.preview-large { font-size: var(--step-1); font-weight: 700; margin: 0 0 .25rem; }
.preview-small { margin: 0; font-size: var(--step--1); }
.contrast-grades { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .6rem; list-style: none; margin: 0; padding: 0; }
.grade { display: inline-flex; align-items: center; gap: .4rem; padding: .35rem .7rem; border-radius: 999px; font-size: var(--step--1); font-weight: 600; border: 1px solid var(--border); }
.grade.pass { background: color-mix(in srgb, var(--brand) 15%, var(--surface)); color: var(--brand-strong); border-color: var(--brand); }
.grade.fail { background: color-mix(in srgb, #d94a4a 12%, var(--surface)); color: #b23434; border-color: #d94a4a; }

/* ------------------------------------------------- Library */
.saved-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.saved-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.saved-strip { display: flex; block-size: 60px; }
.saved-strip span { flex: 1; }
.saved-actions { display: flex; gap: .5rem; padding: .75rem; }
.saved-actions button { font: inherit; font-size: var(--step--1); cursor: pointer; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: var(--radius-sm); padding: .4rem .7rem; }
.saved-actions button:hover { border-color: var(--brand); color: var(--brand-strong); }
.empty-state { color: var(--text-muted); }

/* ------------------------------------------------- Prose / content */
.prose { max-width: 74ch; }
.content .prose, .faq .prose, .author .prose { margin-inline: auto; }
.prose h3 { margin-top: 2rem; }
.prose ul { padding-left: 1.25rem; }
.prose li { margin-bottom: .4rem; }

/* FAQ */
.faq-list { display: grid; gap: .75rem; }
.faq details {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .25rem 1rem;
}
.faq summary { cursor: pointer; font-weight: 600; padding: .75rem 0; }
.faq summary::marker { color: var(--brand); }
.faq details[open] summary { border-bottom: 1px solid var(--border); margin-bottom: .5rem; }

/* Author */
.author-card { display: flex; gap: 1.25rem; align-items: flex-start; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); }
.author-avatar { inline-size: 56px; block-size: 56px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; flex: none; }
.author-links { color: var(--text-muted); font-size: var(--step--1); }

/* ------------------------------------------------- Footer */
.site-footer { background: var(--surface); border-top: 1px solid var(--border); padding-block: 3rem 1.5rem; }
.footer-grid { display: grid; gap: 2rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.site-footer h2 { font-size: var(--step-0); margin-bottom: .75rem; }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.site-footer a { color: var(--text-muted); text-decoration: none; font-size: var(--step--1); }
.site-footer a:hover { color: var(--brand-strong); }
.muted { color: var(--text-muted); font-size: var(--step--1); }
.footer-legal { margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }

/* ------------------------------------------------- Motion */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ------------------------------------------------- Responsive */
@media (max-width: 720px) {
  .site-nav { display: none; }
  .contrast-result { grid-template-columns: 1fr; text-align: center; }
  .theme-toggle-label { display: none; }
}

/* ------------------------------------------------- Print */
@media print {
  .site-header, .theme-toggle, .hero-actions, .field-actions, .site-footer nav, .skip-link { display: none !important; }
  body { background: #fff; color: #000; }
  .swatch, .controls, .contrast-result { box-shadow: none; border: 1px solid #999; }
  a { text-decoration: underline; }
}
