/*
 * List themes. A theme overrides the colour tokens of base.css (light AND
 * dark) on the element carrying data-theme: <html> on the visitor page, the
 * list panel on the admin page (as a preview). It may add decorations,
 * scoped the same way.
 *
 * Adding a theme: add its id to src/domain/themes.ts, its label to
 * client/core/themes.ts, then a [data-theme="<id>"] block below.
 *
 * "classic" is the default look defined in base.css: no overrides.
 */

/* ---------- Noël ---------- */

[data-theme="christmas"] {
  --bg: #f7f3ea;
  --surface: #fffdf8;
  --surface-muted: #eee8da;
  --panel: #e6efe4;
  --ink: #1e2a22;
  --ink-muted: #56655b;
  --border: #d5dfd0;
  --accent: #b3121f;
  --accent-ink: #ffffff;
  --accent-soft: #fbe3e4;
  --success: #1d6b3e;
  --success-soft: #dff0e3;
  --snow: #c3d0d8;
}

@media (prefers-color-scheme: dark) {
  [data-theme="christmas"] {
    --bg: #0f1a14;
    --surface: #16241c;
    --surface-muted: #1d2e24;
    --panel: #192a20;
    --ink: #f3efe6;
    --ink-muted: #a9b8ad;
    --border: #2c4134;
    --accent: #ff6b6b;
    --accent-ink: #0f1a14;
    --accent-soft: #3b1f22;
    --success: #7fd6a0;
    --success-soft: #183626;
    --snow: #ffffff;
  }
}

/* Red and green ribbons on the cards (also in the admin preview) */
[data-theme="christmas"] .gift-card {
  border-top: 4px solid var(--accent);
}

[data-theme="christmas"] .gift-card:nth-child(even) {
  border-top-color: var(--success);
}

/* Page decorations: visitor page only (data-theme on <html>) */
:root[data-theme="christmas"] .site-header h1::after {
  content: " 🎄";
}

/* Garland of lights under the header */
:root[data-theme="christmas"] .site-header {
  position: relative;
  padding-bottom: 40px;
}

:root[data-theme="christmas"] .site-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 12px;
  height: 14px;
  background:
    radial-gradient(circle at 12px 7px, #e63946 0 4px, transparent 5px) 0 0 / 96px 14px,
    radial-gradient(circle at 36px 7px, #f4c430 0 4px, transparent 5px) 0 0 / 96px 14px,
    radial-gradient(circle at 60px 7px, #2a9d8f 0 4px, transparent 5px) 0 0 / 96px 14px,
    radial-gradient(circle at 84px 7px, #4d7cfe 0 4px, transparent 5px) 0 0 / 96px 14px,
    linear-gradient(var(--border), var(--border)) 0 3px / 100% 1px no-repeat;
  animation: christmas-twinkle 2.4s ease-in-out infinite alternate;
}

@keyframes christmas-twinkle {
  from {
    filter: brightness(0.85) saturate(0.9);
  }
  to {
    filter: brightness(1.15) saturate(1.2);
  }
}

/* Gently falling snow, behind the content */
:root[data-theme="christmas"] body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.7;
  background-image:
    radial-gradient(3px 3px at 20px 30px, var(--snow) 50%, transparent 51%),
    radial-gradient(2px 2px at 90px 120px, var(--snow) 50%, transparent 51%),
    radial-gradient(4px 4px at 150px 60px, var(--snow) 50%, transparent 51%),
    radial-gradient(2px 2px at 60px 170px, var(--snow) 50%, transparent 51%),
    radial-gradient(3px 3px at 180px 190px, var(--snow) 50%, transparent 51%);
  background-size: 200px 220px;
  animation: christmas-snow 18s linear infinite;
}

@keyframes christmas-snow {
  from {
    background-position: 0 0;
  }
  to {
    background-position: 40px 220px;
  }
}

@media (prefers-reduced-motion: reduce) {
  :root[data-theme="christmas"] .site-header::after,
  :root[data-theme="christmas"] body::before {
    animation: none;
  }
}

/* Santa in the header's background, on the right, standing on the garland */
:root[data-theme="christmas"] .site-header .container {
  position: relative;
  z-index: 1;
}

:root[data-theme="christmas"] .site-header::before {
  content: "";
  position: absolute;
  right: max(16px, calc((100% - 960px) / 2 + 16px));
  bottom: 18px;
  height: 120px;
  aspect-ratio: 220 / 260;
  pointer-events: none;
  background: url("/img/themes/christmas-santa.svg") bottom / contain no-repeat;
}

/* narrow screens: smaller and faded, behind the title */
@media (max-width: 560px) {
  :root[data-theme="christmas"] .site-header::before {
    height: 84px;
    opacity: 0.45;
  }
}

/* ---------- Anniversaire ---------- */

[data-theme="birthday"] {
  --bg: #fdf6f9;
  --surface: #ffffff;
  --surface-muted: #f6ebf1;
  --panel: #f3ecfb;
  --ink: #2b2233;
  --ink-muted: #6c6075;
  --border: #e8dcea;
  --accent: #c2185b;
  --accent-ink: #ffffff;
  --accent-soft: #fde4ee;
  --success: #0f8a7e;
  --success-soft: #dcf4f1;
}

@media (prefers-color-scheme: dark) {
  [data-theme="birthday"] {
    --bg: #1a1420;
    --surface: #241c2b;
    --surface-muted: #2e2436;
    --panel: #261d30;
    --ink: #f6eef8;
    --ink-muted: #b9aac2;
    --border: #3d3147;
    --accent: #ff6fa3;
    --accent-ink: #1a1420;
    --accent-soft: #3d1f30;
    --success: #5fd9c9;
    --success-soft: #173631;
  }
}

/* Ribbons of party colours on the cards (also in the admin preview) */
[data-theme="birthday"] .gift-card {
  border-top: 4px solid #ff5c8a;
}

[data-theme="birthday"] .gift-card:nth-child(4n + 2) {
  border-top-color: #2ec4b6;
}

[data-theme="birthday"] .gift-card:nth-child(4n + 3) {
  border-top-color: #ffc93c;
}

[data-theme="birthday"] .gift-card:nth-child(4n + 4) {
  border-top-color: #8e6cef;
}

/* Page decorations: visitor page only (data-theme on <html>) */
:root[data-theme="birthday"] .site-header h1::after {
  content: " 🎂";
}

/* Bunting under the header */
:root[data-theme="birthday"] .site-header {
  position: relative;
  padding-bottom: 44px;
}

:root[data-theme="birthday"] .site-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 6px;
  height: 26px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 128 26'%3E%3Cpath d='M0 3 Q64 9 128 3' fill='none' stroke='%23b9a9c2' stroke-width='1.5'/%3E%3Cpath d='M6 4 L22 5.5 L14 24 Z' fill='%23ff5c8a'/%3E%3Cpath d='M38 6 L54 6.5 L46 25 Z' fill='%23ffc93c'/%3E%3Cpath d='M70 6.5 L86 6 L78 25 Z' fill='%232ec4b6'/%3E%3Cpath d='M102 5.5 L118 4 L110 24 Z' fill='%238e6cef'/%3E%3C/svg%3E")
    0 0 / 128px 26px repeat-x;
}

/* Balloons on the right of the header, above the bunting */
:root[data-theme="birthday"] .site-header .container {
  position: relative;
  z-index: 1;
}

:root[data-theme="birthday"] .site-header::before {
  content: "";
  position: absolute;
  right: max(16px, calc((100% - 960px) / 2 + 16px));
  bottom: 22px;
  height: 130px;
  aspect-ratio: 200 / 260;
  pointer-events: none;
  background: url("/img/themes/birthday-balloons.svg") bottom / contain no-repeat;
  animation: birthday-float 4s ease-in-out infinite alternate;
}

@keyframes birthday-float {
  from {
    transform: translateY(0) rotate(-1.5deg);
  }
  to {
    transform: translateY(-6px) rotate(1.5deg);
  }
}

@media (max-width: 560px) {
  :root[data-theme="birthday"] .site-header::before {
    height: 90px;
    opacity: 0.45;
  }
}

/* Confetti slowly falling behind the content */
:root[data-theme="birthday"] body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.55;
  background-image:
    radial-gradient(4px 4px at 20px 40px, #ff5c8a 50%, transparent 51%),
    radial-gradient(3px 5px at 110px 20px, #ffc93c 50%, transparent 51%),
    radial-gradient(4px 3px at 190px 120px, #2ec4b6 50%, transparent 51%),
    radial-gradient(3px 3px at 60px 160px, #8e6cef 50%, transparent 51%),
    radial-gradient(5px 3px at 150px 200px, #ff5c8a 50%, transparent 51%),
    radial-gradient(3px 4px at 230px 70px, #2ec4b6 50%, transparent 51%);
  background-size: 260px 240px;
  animation: birthday-confetti 26s linear infinite;
}

@keyframes birthday-confetti {
  from {
    background-position: 0 0;
  }
  to {
    background-position: -60px 240px;
  }
}

@media (prefers-reduced-motion: reduce) {
  :root[data-theme="birthday"] .site-header::before,
  :root[data-theme="birthday"] body::before {
    animation: none;
  }
}
