/* Colour themes for the BUTTERFLY pages. Every colour on both pages comes from
   these tokens; theme.js sets data-theme on <html>. "original" is the default. */

:root, :root[data-theme="original"] {
  --bg: #F7F2EC; --ink: #2A1A24;
  --primary: #5B2A4A; --primary-hover: #3E1A32; --on-primary: #FFFFFF;
  --accent: #B24B67; --eyebrow: #6E3A5C;
  --text: #4E3E47; --subtle: #6A5862;
  --card: #FFFFFF; --surface: #EFE3DA; --line: #E4D8CF; --dashed: #CDB6AA;
  --band: #2A1A24; --band-ink: #F7F2EC; --band-muted: #D9C8CF;
  color-scheme: light;
}

/* Same plum, pushed darker and cleaner so it survives a washed-out projector */
:root[data-theme="plum"] {
  --bg: #FCFAF7; --ink: #1E0F19;
  --primary: #3E1A32; --primary-hover: #2A0F22; --on-primary: #FFFFFF;
  --accent: #B24B67; --eyebrow: #5B2A4A;
  --text: #33242D; --subtle: #574650;
  --card: #FFFFFF; --surface: #F3EAE3; --line: #DCCFC5; --dashed: #BFA79B;
  --band: #1E0F19; --band-ink: #FFFFFF; --band-muted: #E6D8DE;
  color-scheme: light;
}

/* Monarch butterfly: burnt orange and near-black, deliberately not blood red */
:root[data-theme="monarch"] {
  --bg: #FBF7F1; --ink: #1C1B1A;
  --primary: #B04C16; --primary-hover: #8A3A10; --on-primary: #FFFFFF;
  --accent: #C85A19; --eyebrow: #A2461A;
  --text: #3A3633; --subtle: #5F5954;
  --card: #FFFFFF; --surface: #F6E9DA; --line: #EADBC9; --dashed: #D8BFA4;
  --band: #1C1B1A; --band-ink: #FBF7F1; --band-muted: #EDCBA8;
  color-scheme: light;
}

/* Night shift: dark navy for a dimmed lecture theatre */
:root[data-theme="night"] {
  --bg: #0F1B2D; --ink: #E8EEF5;
  --primary: #5FB3A8; --primary-hover: #7CC7BD; --on-primary: #0B1524;
  --accent: #E88BA3; --eyebrow: #8FD0C6;
  --text: #C3CFDC; --subtle: #93A3B5;
  --card: #16263D; --surface: #13223A; --line: #26395A; --dashed: #3A5075;
  --band: #081222; --band-ink: #E8EEF5; --band-muted: #A9BACD;
  color-scheme: dark;
}

/* Clinical calm: slate and sage, with a coral accent */
:root[data-theme="clinical"] {
  --bg: #F6F7F5; --ink: #1F2A30;
  --primary: #2F3E46; --primary-hover: #1F2A30; --on-primary: #FFFFFF;
  --accent: #C8603F; --eyebrow: #4A6E64;
  --text: #3D4A50; --subtle: #5D6A70;
  --card: #FFFFFF; --surface: #E8EEE9; --line: #D6DED8; --dashed: #AFC0B3;
  --band: #2F3E46; --band-ink: #F6F7F5; --band-muted: #C9D6CC;
  color-scheme: light;
}

html { background: var(--bg); scroll-padding-bottom: 96px; }  /* focus never hides behind the picker (2.4.11) */
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto !important; } }

/* Skip link: hidden until a keyboard user reaches it (2.4.1) */
.skip-link {
  position: absolute; left: 16px; top: -100px; z-index: 100;
  padding: 12px 20px; border-radius: 999px;
  background: var(--primary); color: var(--on-primary); font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: 16px; color: var(--on-primary); }
main:focus { outline: none; }

/* Animations off: the viewer's pause button (2.2.2), or their system setting */
html.motion-off *, html.motion-off *::before, html.motion-off *::after { animation: none !important; transition: none !important; }
html.motion-off { scroll-behavior: auto !important; }
html.motion-off .site-map.armed .site { opacity: 1; transform: none; }
body { background: var(--bg); color: var(--ink); }
a { color: var(--primary); }
a:hover { color: var(--primary-hover); }

/* Only while switching, so hover states stay instant the rest of the time */
html.theme-switching *, html.theme-switching *::before, html.theme-switching *::after {
  transition: background-color .35s ease, color .35s ease, border-color .35s ease, stroke .35s ease !important;
}

/* ---- The logo closes its wings now and then (theme.js adds .flap) ---- */
.logo-wings { transform-box: view-box; transform-origin: 60px 50px; }
.flapper.flap .logo-wings { animation: wing-flap .9s ease-in-out; }
.logo:hover .logo-wings { animation: wing-flap .9s ease-in-out; }
@keyframes wing-flap {
  0%, 100% { transform: scaleX(1); }
  22%      { transform: scaleX(.14); }
  44%      { transform: scaleX(1); }
  66%      { transform: scaleX(.22); }
  86%      { transform: scaleX(1); }
}
@media (prefers-reduced-motion: reduce) {
  .flapper.flap .logo-wings, .logo:hover .logo-wings { animation: none; }
}

/* ---- Theme picker ---- */
.theme-picker {
  position: fixed; right: 16px; bottom: 16px; z-index: 50;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px 8px 16px; border-radius: 999px;
  background: var(--card); color: var(--ink);
  border: 1px solid var(--line); box-shadow: 0 6px 24px rgba(0,0,0,.14);
  font: 600 0.875rem/1 "Source Sans 3", "Segoe UI", sans-serif;
}
.theme-picker .tp-label { color: var(--subtle); }
.theme-picker .tp-name { min-width: 7.5em; }
.theme-picker button {
  width: 30px; height: 30px; padding: 0; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; background: none;
  display: grid; place-items: center;
}
.theme-picker button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.theme-picker button[aria-pressed="true"] { border-color: var(--ink); }
.theme-picker .tp-motion {
  white-space: nowrap;
  width: auto; height: 30px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--ink);
  font: inherit; display: flex; gap: 0.3em; align-items: center;
}
.theme-picker .tp-motion[aria-pressed="true"] { border-color: var(--ink); }
.theme-picker .tp-sep { width: 1px; align-self: stretch; background: var(--line); margin: 0 2px; }
.theme-picker .tp-swatch {
  width: 22px; height: 22px; border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.18);
}
@media (max-width: 560px) {
  .theme-picker { left: 16px; right: 16px; justify-content: space-between; }
  .theme-picker .tp-label, .theme-picker .tp-name { display: none; }
  .theme-picker { gap: 6px; padding: 6px 8px; }
}
@media (max-width: 420px) {
  .theme-picker .tp-long { display: none; }
}
@media print { .theme-picker { display: none; } }

/* ---- Footer logos sit on white, as their artwork needs, whatever the theme ---- */
.logo-plate {
  background: #FFFFFF; border-radius: 12px; padding: 0 20px; height: 88px; box-sizing: border-box;
  display: flex; align-items: center; border: 1px solid var(--line);
}
.logo-plate { max-width: 100%; }
.logo-plate img { display: block; max-width: 100%; height: auto; }  /* shrinks in proportion on the narrowest phones */
a.logo-plate { transition: border-color .15s ease, box-shadow .15s ease; }
a.logo-plate:hover { border-color: var(--primary); box-shadow: 0 2px 10px rgba(0,0,0,.12); }
a.logo-plate:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }
@media (max-width: 420px) { .ci-card { flex-direction: column; } }
/* the code carries its own white border, so it scans on every theme */
.qr img { display: block; border-radius: 10px; }

/* ---- Site map: eight butterflies land, then flutter now and then ---- */
.site-map .land { fill: var(--surface); stroke: var(--primary); stroke-width: 1.4; stroke-linejoin: round; }
.site-map .site { stroke: var(--accent); stroke-width: 5; stroke-linejoin: round; stroke-linecap: round; }
.site-map .site-wings path { fill: color-mix(in srgb, var(--accent) 22%, transparent); }
.site-map .site-shadow { fill: var(--ink); opacity: .12; stroke: none; }
.site-map .site-wings { transform-box: fill-box; transform-origin: center; }

.site-map.armed .site { opacity: 0; transform: translate(-40px, -60px) rotate(-25deg); }
.site-map.landed .site {
  opacity: 1; transform: none;
  transition: opacity .5s ease, transform 1.1s cubic-bezier(.2, .8, .3, 1.15);
  transition-delay: calc(var(--i) * 180ms);
}
.site-map.landed .site-wings {
  animation: site-flutter 5s ease-in-out infinite;
  animation-delay: calc(var(--i) * 650ms);
}
@keyframes site-flutter {
  0%, 70%, 100% { transform: scaleX(1); }
  76%           { transform: scaleX(.2); }
  82%           { transform: scaleX(1); }
  88%           { transform: scaleX(.3); }
  94%           { transform: scaleX(1); }
}
@media (prefers-reduced-motion: reduce) {
  .site-map.armed .site { opacity: 1; transform: none; }
  .site-map.landed .site-wings { animation: none; }
}
