@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;600&family=DM+Serif+Display&display=swap');

/* === Reset === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* === Tokens (dawn = default) === */
:root {
  --color-bg: #f5f0eb;
  --color-surface: #faf8f5;
  --color-text: #2c2c2c;
  --color-text-muted: #5f5f5f;
  --color-accent: #7e6b4a;
  --color-accent-hover: #73603f;
  --color-accent-text: #fff;
  --color-border: #e0dbd3;
  --color-error: #b44;
  --font-body: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-heading: "DM Serif Display", Georgia, serif;
  --max-width: 44rem;
  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 2rem;
  --space-lg: 4rem;
  --space-xl: 6rem;
}

/* === Theme: Day === */
:root[data-theme="day"] {
  --color-bg: #ffffff;
  --color-surface: #ffffff;
  --color-text: #1a1a1a;
  --color-text-muted: #666666;
  --color-accent: #7a6548;
  --color-accent-hover: #63523a;
  --color-accent-text: #fff;
  --color-border: #e5e5e5;
  --color-error: #c44;
}

/* === Theme: Mist === */
:root[data-theme="mist"] {
  --color-bg: #eff2f6;
  --color-surface: #f7f8fb;
  --color-text: #2a2d35;
  --color-text-muted: #5e6470;
  --color-accent: #4d6b7a;
  --color-accent-hover: #3d5b6a;
  --color-accent-text: #fff;
  --color-border: #d8dde6;
  --color-error: #c44;
}

/* === Theme: Dawn (explicit, same as default) === */
:root[data-theme="dawn"] {
  --color-bg: #f5f0eb;
  --color-surface: #faf8f5;
  --color-text: #2c2c2c;
  --color-text-muted: #5f5f5f;
  --color-accent: #7e6b4a;
  --color-accent-hover: #73603f;
  --color-accent-text: #fff;
  --color-border: #e0dbd3;
  --color-error: #b44;
}

/* === Theme: Dusk === */
:root[data-theme="dusk"] {
  --color-bg: #1c2333;
  --color-surface: #242c40;
  --color-text: #cdd2dc;
  --color-text-muted: #929ab0;
  --color-accent: #c4a882;
  --color-accent-hover: #d4bc9a;
  --color-accent-text: #1c2333;
  --color-border: #2e3750;
  --color-error: #e57373;
}

/* === Theme: Night === */
:root[data-theme="night"] {
  --color-bg: #111111;
  --color-surface: #1a1a1a;
  --color-text: #e0ddd8;
  --color-text-muted: #888;
  --color-accent: #c4a882;
  --color-accent-hover: #d4bc9a;
  --color-accent-text: #111111;
  --color-border: #2a2a2a;
  --color-error: #e57373;
}

/* === Theme: Ember === */
:root[data-theme="ember"] {
  --color-bg: #1a1410;
  --color-surface: #231c16;
  --color-text: #e0d8ce;
  --color-text-muted: #978b7e;
  --color-accent: #c49a6c;
  --color-accent-hover: #d4aa7c;
  --color-accent-text: #1a1410;
  --color-border: #342a20;
  --color-error: #e57373;
}

/* === Auto: system light = dawn (default), system dark = dusk === */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg: #1c2333;
    --color-surface: #242c40;
    --color-text: #cdd2dc;
    --color-text-muted: #929ab0;
    --color-accent: #c4a882;
    --color-accent-hover: #d4bc9a;
    --color-accent-text: #1c2333;
    --color-border: #2e3750;
    --color-error: #e57373;
  }
}

/* === Skip nav === */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-sm);
  background: var(--color-accent);
  color: var(--color-accent-text);
  padding: 0.5rem 1rem;
  border-radius: 2px;
  font-size: 0.875rem;
  z-index: 200;
  text-decoration: none;
}

.skip-link:focus {
  top: var(--space-xs);
}

/* === Base === */
html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  transition: color 0.3s ease, background-color 0.3s ease;
}

*, *::before, *::after {
  transition: color 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
}

/* === Focus === */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* === Reduced motion === */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
  }
}

/* === Typography === */
h1, h2, h3 {
  font-family: var(--font-heading);
  line-height: 1.25;
  font-weight: 400;
  letter-spacing: normal;
}

h1 {
  font-size: 2rem;
  margin-bottom: var(--space-sm);
}

h2 {
  font-size: 1.375rem;
  margin-top: var(--space-lg);
  margin-bottom: var(--space-sm);
}

h3 {
  font-size: 1.125rem;
  margin-bottom: var(--space-xs);
}

p {
  margin-bottom: var(--space-sm);
}

a {
  color: var(--color-accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  text-decoration-skip-ink: auto;
}

ul, ol {
  padding-left: 1.25rem;
  margin-bottom: var(--space-sm);
}

li {
  margin-bottom: var(--space-xs);
}

/* === Layout === */
.section {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-lg) var(--space-md);
}

/* === Nav === */
.site-header {
  border-bottom: 1px solid var(--color-border);
}

.nav {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-sm) var(--space-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-logo {
  font-weight: 600;
  font-size: 1.125rem;
  color: var(--color-text);
  text-decoration: none;
}

.nav-logo:hover {
  text-decoration: none;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  list-style: none;
  padding: 0;
  margin: 0;
}

.nav-links li {
  margin: 0;
}

.nav-links a {
  color: var(--color-text-muted);
  font-size: 0.9375rem;
  text-decoration: none;
}

.nav-links a:hover {
  color: var(--color-text);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentColor 30%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

.nav-links a[aria-current="page"] {
  color: var(--color-text);
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.75rem;
  min-width: 2.75rem;
  min-height: 2.75rem;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  order: 3;
}

.nav-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--color-text);
}

/* === Theme picker === */
.theme-picker {
  order: 4;
  position: relative;
  flex-shrink: 0;
}

.theme-picker-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  width: 2.75rem;
  height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.theme-picker-btn:hover {
  color: var(--color-text);
}

.theme-picker-btn svg {
  width: 18px;
  height: 18px;
}

.theme-menu {
  display: none;
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 0.5rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  z-index: 100;
}

.theme-picker.open .theme-menu {
  display: block;
}

.theme-menu-group {
  display: flex;
  gap: 0.25rem;
}

.theme-menu-group button {
  width: 3.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  padding: 0.35rem 0;
  background: transparent;
  border: none;
  border-radius: 2px;
  cursor: pointer;
  font-family: inherit;
  color: var(--color-text-muted);
  transition: background-color 0.12s ease, color 0.12s ease;
}

.theme-menu-group button:hover {
  background: rgba(128, 128, 128, 0.07);
  color: var(--color-text);
}

.theme-menu-group button.active {
  background: var(--color-accent);
  color: var(--color-accent-text);
}

.theme-menu-group button svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.theme-menu-label {
  display: block;
  font-size: 0.6875rem;
  line-height: 1.2;
  white-space: nowrap;
}

.theme-menu-divider {
  height: 1px;
  background: var(--color-border);
  opacity: 0.4;
  margin: 0.375rem 0;
}

.theme-menu-mode {
  gap: 0.25rem;
}

.theme-menu-mode button {
  width: auto;
  flex: 1;
  flex-direction: row;
  padding: 0.3rem 0;
}

.theme-menu-mode .theme-menu-label {
  font-size: 0.75rem;
}

/* === Callout === */
.callout {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  background: color-mix(in srgb, var(--color-surface), var(--color-border) 20%);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: var(--space-sm);
  margin-bottom: var(--space-md);
}

.callout p {
  margin-bottom: 0;
}

/* === Hero === */
.hero {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-xl) var(--space-md) var(--space-lg);
}

.hero h1 {
  font-size: 2.5rem;
  max-width: 20ch;
}

.hero p {
  color: var(--color-text-muted);
  font-size: 1.125rem;
  max-width: 40ch;
  margin-bottom: var(--space-md);
}

/* === Button === */
.btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  background: var(--color-accent);
  color: var(--color-accent-text);
  border: none;
  border-radius: 2px;
  font-size: 0.9375rem;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease;
}

.btn:hover {
  background: var(--color-accent-hover);
  text-decoration: none;
}

/* === Link arrow === */
.link-arrow {
  display: inline-block;
  font-size: 0.9375rem;
}

.link-arrow::after {
  content: " \2192";
}

/* === Cards === */
.card-grid {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: var(--space-md);
  margin-top: var(--space-sm);
}

.card {
  padding: var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: 2px;
  background: var(--color-surface);
}

.card p {
  color: var(--color-text-muted);
  font-size: 0.9375rem;
  margin-bottom: 0;
}

/* === FAQ === */
.faq-list {
  margin-top: var(--space-sm);
}

.faq-item {
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-md) 0;
}

.faq-item h2 {
  font-size: 1.4rem;
  margin-top: 0;
  margin-bottom: var(--space-xs);
}

.faq-item > p {
  margin-bottom: 0;
}

.faq-item > p:not(.faq-detail) {
  font-size: 1.3125rem;
}

.faq-detail {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-top: 0.375rem;
  margin-bottom: 0;
}

/* === Forms === */
.form {
  margin-top: var(--space-md);
  max-width: 28rem;
}

.form-field {
  margin-bottom: var(--space-sm);
}

.form-field label {
  display: block;
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.optional {
  font-weight: 400;
  color: var(--color-text-muted);
}

.form-field input,
.form-field textarea {
  width: 100%;
  padding: 0.625rem 0.75rem;
  font-family: inherit;
  font-size: 1rem;
  border: 1px solid var(--color-border);
  border-radius: 2px;
  background: var(--color-surface);
  color: var(--color-text);
  transition: color 0.6s ease, background-color 0.6s ease, border-color 0.6s ease;
}

.form-field textarea {
  resize: vertical;
}

.form-field input:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--color-accent);
}

.form-status {
  margin-top: var(--space-sm);
  font-size: 0.9375rem;
}

.form-status.error {
  color: var(--color-error);
}

.form-status.info {
  color: var(--color-text-muted);
}

/* === Quiz === */
.quiz {
  margin-top: var(--space-sm);
}

.quiz-question {
  border: none;
  padding: 0;
  margin-bottom: var(--space-md);
}

.quiz-question legend {
  font-weight: 600;
  margin-bottom: var(--space-xs);
}

.quiz-option {
  display: block;
  padding: 0.25rem 0;
  cursor: pointer;
  font-size: 0.9375rem;
}

.quiz-option input {
  margin-right: 0.5rem;
}

.quiz-result {
  margin-top: var(--space-md);
  padding: var(--space-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 2px;
}

.quiz-result:empty {
  display: none;
}

/* === Footer === */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding: var(--space-md);
  text-align: center;
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

/* === Responsive === */
@media (max-width: 640px) {
  .nav-toggle {
    display: flex;
  }

  .nav-links {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    padding: var(--space-sm) var(--space-md);
    gap: var(--space-xs);
  }

  .nav-links.open {
    display: flex;
  }

  .site-header {
    position: relative;
  }

  .hero h1 {
    font-size: 1.75rem;
  }

  .section {
    padding: var(--space-md) var(--space-sm);
  }

  .hero {
    padding: var(--space-lg) var(--space-sm) var(--space-md);
  }
}
