/*!
 * Lumen — a tiny, classless, responsive CSS framework
 * Just write semantic HTML. No classes needed.
 */

:root {
  --bg: light-dark(#fafaff, #0f0e1a);
  --surface: light-dark(#ffffff, #181729);
  --text: light-dark(#1c1b2e, #ecebf7);
  --muted: light-dark(#6b6a80, #9b9ab3);
  --border: light-dark(#e2e1f0, #2a2940);
  --accent: light-dark(#6d5dfc, #8b7dff);
  --accent-2: light-dark(#b25dfc, #d08bff);
  --accent-contrast: light-dark(#ffffff, #0f0e1a);
  --accent-soft: color-mix(in srgb, var(--accent) 15%, transparent);
  --danger: #e5484d;

  --radius: 6px;
  --shadow: 0 1px 2px light-dark(rgba(28, 27, 46, .05), rgba(0, 0, 0, .3)),
            0 8px 24px light-dark(rgba(28, 27, 46, .06), rgba(0, 0, 0, .35));
  --ease: .18s cubic-bezier(.4, 0, .2, 1);

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --space: 1rem;
  --width: 68rem;

  color-scheme: light dark;
}

/* Follows the system by default. Force a theme with <html data-theme="light|dark"> */
:root[data-theme=light] { color-scheme: light; }
:root[data-theme=dark] { color-scheme: dark; }

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
img, video, canvas, iframe { display: block; max-width: 100%; height: auto; }
svg { max-width: 100%; height: auto; vertical-align: middle; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- Base ---------- */
body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background:
    radial-gradient(60rem 30rem at 100% -10%, var(--accent-soft), transparent 60%),
    radial-gradient(50rem 28rem at -10% 0%, color-mix(in srgb, var(--accent-2) 8%, transparent), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

::selection { background: var(--accent); color: var(--accent-contrast); }

/* ---------- Layout ---------- */
body > header,
body > main,
body > footer,
body > nav {
  width: 100%;
  max-width: var(--width);
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 2rem);
}

body > header { padding-block: clamp(2rem, 6vw, 4rem) 1rem; }
body > main { flex: 1; padding-block: 1rem 3rem; }
body > footer {
  padding-block: 2rem;
  color: var(--muted);
  font-size: .9rem;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
  text-align: center;
}

main > * + * { margin-top: 1.25rem; }
section { margin-block: 2.5rem; }
section > * + * { margin-top: 1rem; }

/* A section containing articles becomes a responsive auto-fit grid */
section:has(> article) {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  gap: 1.25rem;
}
section:has(> article) > :not(article) { grid-column: 1 / -1; }
section:has(> article) > * + * { margin-top: 0; }

/* Cards */
article {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
article > * + * { margin-top: .75rem; }
section > article:hover { border-color: var(--accent); }

/* ---------- Nav ---------- */
nav ul {
  display: flex; flex-wrap: wrap; align-items: center; gap: .25rem;
  list-style: none; padding: 0;
}
/* A theme toggle inside a nav item is pushed to the far right */
nav li:has(> [data-theme-toggle]) { margin-left: auto; }
nav a {
  display: inline-block;
  padding: .4rem .85rem;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 500;
  text-decoration: none;
  transition: var(--ease);
}
nav a:hover, nav a[aria-current] { color: var(--accent); background: var(--accent-soft); }

/* ---------- Typography ---------- */
h1, h2, h3, h4, h5, h6 {
  font-weight: 750;
  line-height: 1.2;
  letter-spacing: -.02em;
  text-wrap: balance;
}
h1 {
  font-size: clamp(2.2rem, 1.6rem + 3vw, 3.6rem);
  letter-spacing: -.035em;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  width: fit-content;
  max-width: 100%;
}
h2 { font-size: clamp(1.6rem, 1.3rem + 1.4vw, 2.2rem); }
h3 { font-size: clamp(1.3rem, 1.15rem + .7vw, 1.6rem); }
h4 { font-size: 1.15rem; }
h5 { font-size: 1rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
h6 { font-size: .85rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }

* + h2, * + h3, * + h4 { margin-top: 1.75rem; }
header h1 + p, header p:first-of-type { font-size: 1.2rem; color: var(--muted); max-width: 40rem; }

p { max-width: 68ch; text-wrap: pretty; }
small { color: var(--muted); font-size: .875rem; }
strong, b { font-weight: 650; }

a {
  color: var(--accent);
  text-decoration-thickness: .08em;
  text-underline-offset: .2em;
  transition: color var(--ease);
}
a:hover { color: var(--accent-2); }

ul, ol { padding-left: 1.4rem; }
li::marker { color: var(--accent); }

blockquote {
  padding: .5rem 1.25rem;
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text);
}

hr { border: 0; height: 1px; background: var(--border); margin-block: 2rem; }

code, kbd, pre { font-family: var(--mono); font-size: .9em; }
code, kbd {
  background: var(--accent-soft);
  padding: .15em .4em;
  border-radius: 6px;
}
pre {
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}
pre code { background: none; padding: 0; }
mark { background: linear-gradient(transparent 55%, var(--accent-soft) 55%); color: inherit; }

/* ---------- Media ---------- */
img, video, iframe { border-radius: var(--radius); }
video, iframe, audio { width: 100%; }
iframe { border: 0; aspect-ratio: 16 / 9; height: auto; }
figure { display: grid; gap: .6rem; }
figure > :is(img, svg, video, iframe) { border: 1px solid var(--border); border-radius: var(--radius); }
figcaption { color: var(--muted); font-size: .875rem; text-align: center; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; vertical-align: top; padding: .7rem .9rem; border-bottom: 1px solid var(--border); }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); white-space: nowrap; }
/* Row headers: <th scope="row"> look like normal bold cells */
tbody th, tfoot th { font-size: inherit; text-transform: none; letter-spacing: 0; color: var(--text); font-weight: 650; white-space: normal; }
tbody tr:hover { background: var(--accent-soft); }
tfoot th, tfoot td { border-bottom: 0; border-top: 2px solid var(--border); }
/* Wide tables: wrap in <figure> and they scroll sideways on small screens */
figure:has(> table) { overflow-x: auto; }
figure > table { min-width: 42rem; }

/* ---------- Forms ---------- */
form { display: grid; gap: 1.1rem; }
fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem 1.25rem;
  display: grid;
  gap: .7rem;
}
legend { padding-inline: .5rem; font-weight: 650; font-size: .9rem; color: var(--muted); }

label { display: grid; gap: .4rem; font-weight: 550; font-size: .92rem; cursor: pointer; }

input:not([type=checkbox], [type=radio], [type=submit], [type=button], [type=reset], [type=range], [type=color], [type=file]),
select,
textarea {
  width: 100%;
  padding: .4rem .95rem;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  font-weight: 400;
  transition: border-color var(--ease), box-shadow var(--ease), background var(--ease);
}
textarea { min-height: 7.5rem; resize: vertical; line-height: 1.5; }
::placeholder { color: var(--muted); opacity: .7; }

input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
input:user-invalid, textarea:user-invalid, select:user-invalid { border-color: var(--danger); }
input:user-invalid:focus, textarea:user-invalid:focus { box-shadow: 0 0 0 4px rgba(229, 72, 77, .15); }
input:disabled, select:disabled, textarea:disabled { opacity: .55; cursor: not-allowed; background: var(--bg); }

/* Select */
select {
  appearance: none;
  padding-right: 2.5rem;
  cursor: pointer;
  /* Two gradients form a ▼ arrow, so it uses the live --accent color */
  background-image:
    linear-gradient(45deg, transparent 50%, var(--accent) 50%),
    linear-gradient(135deg, var(--accent) 50%, transparent 50%);
  background-size: .4rem .4rem, .4rem .4rem;
  background-repeat: no-repeat;
  background-position: right 1.4rem center, right 1rem center;
}

/* Checkbox & radio */
input[type=checkbox], input[type=radio] {
  appearance: none;
  flex: none;
  width: 1.2rem; height: 1.2rem;
  margin: 0;
  display: inline-grid;
  place-content: center;
  vertical-align: middle;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: var(--ease);
}
input[type=radio] { border-radius: 50%; }
input[type=checkbox]:hover, input[type=radio]:hover { border-color: var(--accent); }
input[type=checkbox]:focus-visible, input[type=radio]:focus-visible { box-shadow: 0 0 0 4px var(--accent-soft); outline: none; }

input[type=checkbox]:checked {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
}
input[type=checkbox]::after {
  content: "";
  width: .7rem; height: .7rem;
  background: var(--accent-contrast);
  clip-path: polygon(14% 52%, 0 66%, 38% 100%, 100% 20%, 86% 6%, 38% 72%);
  transform: scale(0);
  transition: transform var(--ease);
}
input[type=checkbox]:checked::after { transform: scale(1); }

input[type=radio]:checked { border-color: var(--accent); background: var(--surface); }
input[type=radio]::after {
  content: "";
  width: .65rem; height: .65rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  transform: scale(0);
  transition: transform var(--ease);
}
input[type=radio]:checked::after { transform: scale(1); }
input:disabled[type=checkbox], input:disabled[type=radio] { opacity: .5; cursor: not-allowed; }

/* A label that wraps a checkbox/radio lays out inline */
label:has(> input[type=checkbox]),
label:has(> input[type=radio]) {
  display: flex; align-items: center; gap: .65rem; font-weight: 450; font-size: 1rem;
}

/* Range */
input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=color] { width: 3rem; height: 2.4rem; border: 1.5px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 2px; cursor: pointer; }

/* File */
input[type=file] { width: 100%; font-size: .9rem; color: var(--muted); }
input[type=file]::file-selector-button {
  margin-right: .9rem; padding: .5rem 1rem;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; transition: var(--ease);
}
input[type=file]::file-selector-button:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Buttons ---------- */
button,
input[type=submit],
input[type=button],
input[type=reset],
a[role=button] {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .7rem 1.35rem;
  border: 0;
  border-radius: var(--radius);
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  color: var(--accent-contrast);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 4px 14px var(--accent-soft);
  transition: transform var(--ease), box-shadow var(--ease), filter var(--ease);
  -webkit-tap-highlight-color: transparent;
}
button:hover, input[type=submit]:hover, input[type=button]:hover, a[role=button]:hover {
  background: linear-gradient(10deg, var(--accent), var(--accent-2));
  filter: brightness(1.06);
  color: var(--accent-contrast);
}
button:active, input[type=submit]:active, input[type=button]:active, a[role=button]:active {
  transform: translateY(0) scale(.98);
}
button:focus-visible, input[type=submit]:focus-visible, a[role=button]:focus-visible {
  outline: 3px solid var(--accent-soft);
  outline-offset: 2px;
}
button:disabled, input[type=submit]:disabled {
  opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; filter: grayscale(.4);
}

/* Secondary buttons: reset + any button with [type=reset] or [data-ghost] stay classless via attributes */
button[type=reset], input[type=reset], button[type=button], input[type=button] {
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border);
  box-shadow: none;
}
button[type=reset]:hover, input[type=reset]:hover, button[type=button]:hover, input[type=button]:hover {
  color: var(--accent); border-color: var(--accent); box-shadow: none; filter: none;
}

/* Theme toggle: <button data-theme-toggle></button> (see lumen-theme.js) */
button[data-theme-toggle] {
  width: auto;
  padding: .55rem;
  border-radius: 999px;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border);
  box-shadow: none;
}
button[data-theme-toggle]:hover { color: var(--accent); border-color: var(--accent); background: var(--surface); filter: none; }
button[data-theme-toggle] svg { width: 1.2rem; height: 1.2rem; }

/* Buttons side by side wrap nicely */
form > p:has(> button), p:has(> button), p:has(> a[role=button]) { display: flex; flex-wrap: wrap; gap: .75rem; }

/* ---------- Misc ---------- */
progress, meter { width: 100%; height: .6rem; accent-color: var(--accent); }
details {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: .8rem 1rem; background: var(--surface);
}
summary { cursor: pointer; font-weight: 600; }
details[open] summary { margin-bottom: .6rem; }

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

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

@media (max-width: 36rem) {
  article { padding: 1.15rem; }
  button, input[type=submit], input[type=reset], input[type=button], a[role=button] { width: 100%; }
  p:has(> button), p:has(> a[role=button]) { flex-direction: column; }
}
