/* ==========================================================================
   Seasonal palettes
   Each block works on <html> and on any element with data-season/data-mode
   (the previews on the Appearance page use this). theme.js sets the
   attributes; a custom accent arrives as an inline --accent on the element.
   ========================================================================== */

:root,
[data-season="fall"] {
  --bg: #fbf3e8;
  --surface: #fffaf3;
  --surface-2: #f6e7d3;
  --text: #3b2416;
  --muted: #7d5f4a;
  --accent: #b9501c;
  --accent-text: #ffffff;
  --border: #ead6bf;
  --danger: #a3261f;
  --header-from: #7a3312;
  --header-to: #c26a24;
  --header-text: #fff6ea;
  --motif: "🍂";
  --season-name: "Fall";
}

[data-season="fall"][data-mode="dark"] {
  --bg: #1f1510;
  --surface: #2a1c15;
  --surface-2: #34241b;
  --text: #f3e6d8;
  --muted: #c2a58c;
  --accent: #e8833a;
  --accent-text: #1a1410;
  --border: #4a3427;
  --danger: #f08a7e;
  --header-from: #3a1d0e;
  --header-to: #6e3413;
  --header-text: #fbe9d6;
}

[data-season="winter"] {
  --bg: #f2f6fa;
  --surface: #ffffff;
  --surface-2: #e6eef6;
  --text: #1d2a38;
  --muted: #5d6f82;
  --accent: #2f6690;
  --accent-text: #ffffff;
  --border: #d3dfeb;
  --danger: #a3261f;
  --header-from: #1f3d5a;
  --header-to: #3a7868;
  --header-text: #f2f8fd;
  --motif: "❄️";
  --season-name: "Winter";
}

[data-season="winter"][data-mode="dark"] {
  --bg: #0f1720;
  --surface: #17222e;
  --surface-2: #1e2b39;
  --text: #e4edf5;
  --muted: #9db0c3;
  --accent: #7fb6e0;
  --accent-text: #0f1720;
  --border: #2a3a4b;
  --danger: #f08a7e;
  --header-from: #0d1f30;
  --header-to: #1f4a44;
  --header-text: #e4edf5;
}

[data-season="spring"] {
  --bg: #f7f8f1;
  --surface: #fffffc;
  --surface-2: #eef2e3;
  --text: #27331f;
  --muted: #66735a;
  --accent: #a8406b;
  --accent-text: #ffffff;
  --border: #dfe6cf;
  --danger: #a3261f;
  --header-from: #557a3c;
  --header-to: #b5577f;
  --header-text: #fdfbf5;
  --motif: "🌸";
  --season-name: "Spring";
}

[data-season="spring"][data-mode="dark"] {
  --bg: #161a13;
  --surface: #1f251b;
  --surface-2: #283022;
  --text: #eef2e6;
  --muted: #aab59b;
  --accent: #e88aae;
  --accent-text: #161a13;
  --border: #36412e;
  --danger: #f08a7e;
  --header-from: #24361a;
  --header-to: #5c2a40;
  --header-text: #f3efe6;
}

[data-season="summer"] {
  --bg: #fffaf0;
  --surface: #ffffff;
  --surface-2: #fff0d1;
  --text: #2a2a1f;
  --muted: #6f6a55;
  --accent: #0f7478;
  --accent-text: #ffffff;
  --border: #f1e2bd;
  --danger: #a3261f;
  --header-from: #d98a14;
  --header-to: #0f7478;
  --header-text: #fffdf6;
  --motif: "☀️";
  --season-name: "Summer";
}

[data-season="summer"][data-mode="dark"] {
  --bg: #131a1a;
  --surface: #1a2424;
  --surface-2: #213030;
  --text: #f2f0e6;
  --muted: #a9b3ad;
  --accent: #4fc3c0;
  --accent-text: #131a1a;
  --border: #2e3f3f;
  --danger: #f08a7e;
  --header-from: #5a3a08;
  --header-to: #0b4a4c;
  --header-text: #f7f2e4;
}

/* Values derived from the palette (recomputed per element, so custom accents flow through). */
:root,
[data-season] {
  --accent-soft: color-mix(in srgb, var(--accent) 14%, var(--surface));
  --accent-border: color-mix(in srgb, var(--accent) 45%, var(--border));
  --shadow: 0 1px 2px color-mix(in srgb, var(--text) 8%, transparent),
            0 6px 18px color-mix(in srgb, var(--text) 7%, transparent);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 14px;
  color-scheme: light;
}

[data-mode="dark"] { color-scheme: dark; }

/* ==========================================================================
   Base
   ========================================================================== */

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html[data-text-size="large"] { font-size: 112.5%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  transition: background-color 0.25s ease, color 0.25s ease;
}

html[data-decorations="on"] body {
  background:
    radial-gradient(900px 340px at 50% -120px, var(--accent-soft), transparent 70%),
    var(--bg);
  background-attachment: fixed;
}

h1, h2, h3, .brand, .card-title, .recipe-title {
  font-family: var(--serif);
  letter-spacing: 0.005em;
}

html[data-font="sans"] :is(h1, h2, h3, .brand, .card-title, .recipe-title) { font-family: var(--sans); }

h1 { font-size: 2rem; line-height: 1.2; margin: 0 0 6px; }
h2 { font-size: 1.3rem; margin: 28px 0 10px; }
h3 { font-size: 1.05rem; margin: 0 0 6px; }

a { color: var(--accent); }

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

.muted { color: var(--muted); font-size: 0.92rem; }

/* ==========================================================================
   Header
   ========================================================================== */

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  justify-content: space-between;
  padding: 14px max(16px, calc((100% - 1040px) / 2));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

html[data-decorations="on"] .topbar {
  background: linear-gradient(120deg, var(--header-from), var(--header-to));
  border-bottom: none;
  color: var(--header-text);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 1.45rem;
  font-weight: 700;
  color: inherit;
  text-decoration: none;
}

html[data-decorations="on"] .brand::before {
  content: var(--motif);
  font-size: 1.3rem;
}

nav { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }

nav a {
  color: inherit;
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 500;
}

nav a:hover, nav a[aria-current="page"] { background: color-mix(in srgb, currentColor 14%, transparent); }

html[data-decorations="on"] .topbar button.secondary {
  color: var(--header-text);
  border-color: color-mix(in srgb, var(--header-text) 60%, transparent);
}

html[data-decorations="on"] .topbar :is(button:not(.secondary), .button) {
  background: var(--header-text);
  color: var(--header-from);
  border-color: var(--header-text);
}

/* ==========================================================================
   Layout and components
   ========================================================================== */

main { max-width: 1040px; margin: 0 auto; padding: 28px 16px 80px; }
main.narrow { max-width: 760px; }

.page-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; justify-content: space-between; margin-bottom: 20px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.recipe-card { display: flex; flex-direction: column; gap: 6px; transition: transform 0.15s ease, border-color 0.15s ease; }
.recipe-card:hover { transform: translateY(-2px); border-color: var(--accent-border); }

.card-title { font-size: 1.2rem; font-weight: 700; color: var(--text); text-decoration: none; }
.card-title:hover { color: var(--accent); }
.card-desc { margin: 0; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-border);
  vertical-align: middle;
}

.feed-section { margin-bottom: 34px; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 12px; }
.section-head h2 { margin: 0; }
.count {
  display: inline-grid; place-items: center;
  min-width: 26px; height: 26px; padding: 0 8px;
  border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  font-family: var(--sans); font-size: 0.85rem; font-weight: 700;
  vertical-align: 3px;
}
.invite-card { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.invite-card h3, .invite-card p { margin: 0 0 4px; }

.empty {
  text-align: center;
  padding: 48px 16px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
}
html[data-decorations="on"] .empty::before { content: var(--motif); display: block; font-size: 2.2rem; margin-bottom: 8px; }

button, .button {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  border-radius: 999px;
  padding: 7px 16px;
  text-decoration: none;
  display: inline-block;
  transition: filter 0.15s ease, background-color 0.15s ease;
}
button:hover, .button:hover { filter: brightness(1.07); }
button.secondary { background: transparent; color: var(--accent); }
button.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
button.link { background: none; border: none; color: var(--accent); padding: 0; font-weight: 500; text-decoration: underline; }
button:disabled { opacity: 0.6; cursor: default; }

form { display: grid; gap: 14px; }
label { display: grid; gap: 6px; font-weight: 600; font-size: 0.95rem; }
input, textarea, select {
  font: inherit;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
textarea { min-height: 130px; resize: vertical; }
.hint { font-weight: 400; color: var(--muted); font-size: 0.85rem; }

.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.notice {
  max-width: 1008px;
  margin: 16px auto 0;
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
}
@media (max-width: 1040px) { .notice { margin: 16px 16px 0; } }

.code { font-family: ui-monospace, Consolas, monospace; font-size: 1.3rem; letter-spacing: 3px; font-weight: 700; }

/* Recipe page */
.recipe-title { font-size: 2.3rem; }
.recipe-layout { display: grid; grid-template-columns: minmax(220px, 1fr) 2fr; gap: 20px; margin: 20px 0; }
.recipe-layout .card, .grid .card { margin-bottom: 0; }
@media (max-width: 720px) { .recipe-layout { grid-template-columns: 1fr; } }
.recipe-layout h2 { margin-top: 0; }
.ingredients { list-style: none; padding: 0; margin: 0; }
.ingredients li { padding: 7px 0; border-bottom: 1px dashed var(--border); }
.ingredients li:last-child { border-bottom: none; }
.steps { padding-left: 0; margin: 0; list-style: none; counter-reset: step; }
.steps li { counter-increment: step; position: relative; padding: 0 0 14px 44px; }
.steps li::before {
  content: counter(step);
  position: absolute; left: 0; top: -2px;
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 0.9rem;
}
.description { white-space: pre-wrap; font-size: 1.05rem; }

.comment { border-top: 1px solid var(--border); padding: 14px 0; }
.comment p { margin: 8px 0 6px 44px; white-space: pre-wrap; }
.comment > .link { margin-left: 44px; }
.comment-head { display: flex; align-items: center; }
.comment-head .badge { font-size: 0.7rem; padding: 1px 8px; }

/* Sign in / create account */
.auth-wrap { display: grid; place-items: center; padding: 12px 0 40px; }
.auth-card { width: 100%; max-width: 440px; padding: 28px 28px 22px; }
.auth-card h1 { font-size: 1.8rem; }
.auth-card > p.muted { margin: 0 0 18px; }
.auth-motif {
  width: 56px; height: 56px; border-radius: 50%;
  display: grid; place-items: center;
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--header-from), var(--header-to));
  font-size: 1.6rem;
}
.auth-motif::before { content: var(--motif); }
html[data-decorations="off"] .auth-motif::before { content: "🍳"; }
.auth-card button[type="submit"] { width: 100%; padding: 10px 16px; margin-top: 4px; }
.auth-switch { text-align: center; margin: 18px 0 0; color: var(--muted); }
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.label-row a { font-weight: 500; font-size: 0.88rem; }

.password-field { position: relative; }
.password-field input { padding-right: 64px; }
.password-field .link { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 0.88rem; }

.password-rules { list-style: none; margin: -4px 0 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; font-size: 0.86rem; color: var(--muted); }
.password-rules li::before { content: "○"; display: inline-block; width: 1.3em; }
.password-rules li.met { color: var(--text); }
.password-rules li.met::before { content: "✓"; color: var(--accent); font-weight: 700; }

.form-error {
  margin: 0;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--danger);
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 8%, var(--surface));
}

/* Family */
.member { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.member:last-child { border-bottom: none; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: inline-grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700;
  margin-right: 10px;
}

/* ==========================================================================
   Appearance page
   ========================================================================== */

.settings-section { margin-bottom: 18px; }
.settings-section h2 { margin-top: 0; }

.season-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.season-item { display: grid; gap: 8px; align-content: start; }

/* Each preview carries its own data-season/data-mode, so it paints its own palette. */
.season-preview {
  display: grid;
  gap: 0;
  padding: 0;
  overflow: hidden;
  text-align: left;
  font-weight: 400;
  color: var(--text);
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
}
.season-preview:hover { filter: none; border-color: var(--accent-border); }
.season-preview[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); }
.season-preview .swatch-header {
  height: 46px;
  background: linear-gradient(120deg, var(--header-from), var(--header-to));
  color: var(--header-text);
  padding: 10px 12px;
  font-family: var(--serif);
  font-weight: 700;
}
.season-preview .swatch-header::before { content: var(--motif) " "; }
.season-preview .swatch-header::after { content: var(--season-name); }
.season-preview .swatch-body { padding: 12px; display: grid; gap: 8px; }
.swatch-line { height: 8px; border-radius: 4px; background: var(--surface-2); }
.swatch-line.short { width: 60%; }
.swatch-button {
  justify-self: start;
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 0.8rem;
  font-weight: 600;
}
.selected-tag { font-size: 0.8rem; font-weight: 600; color: var(--accent); }

.segmented { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
@media (max-width: 560px) { .segmented { border-radius: 16px; } }
.segmented button { background: transparent; color: var(--text); border-color: transparent; font-weight: 500; }
.segmented button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

.setting-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.setting-row:last-child { border-bottom: none; }
.setting-label { font-weight: 600; }
.setting-label .hint { display: block; }

.accent-row { display: flex; align-items: center; gap: 10px; }
.accent-row input[type="color"] { width: 46px; height: 34px; padding: 2px; border-radius: 8px; cursor: pointer; }

.switch { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.switch input { width: 20px; height: 20px; accent-color: var(--accent); }

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