/* ============================================================
   Five Things — Themes
   ============================================================ */

/* ---- Default (Dark Purple) ---- */
:root,
body.theme-default {
  --bg:           #1a0a2e;
  --bg-surface:   #2a1a42;
  --bg-elevated:  #3a2458;
  --text:         #e8d8ff;
  --text-muted:   #a090c0;
  --accent:       #9b59b6;
  --accent-hover: #b07fd4;
  --accent-dim:   #6c3d8a;
  --border:       #4a3468;
  --flag-color:   #e8734a;
  --flag-hover:   #ff8c5a;
  --flag-bg:      rgba(232, 115, 74, 0.12);
  --curtain-fold: #b07fd4;
  --rainbow: none;
  /* Curtain gradient stops: left panel outer→inner, right mirrors */
  --cs1: #1a0050; --cs2: #3a0880; --cs3: #6a2ec0;
  --cs4: #3a0880; --cs5: #1a0050; --cs6: #0d0520;
}

@media (prefers-color-scheme: light) {
  :root,
  body.theme-default {
    --bg:           #f0e8ff;
    --bg-surface:   #e0d0f8;
    --bg-elevated:  #d0b8f0;
    --text:         #1a0a2e;
    --text-muted:   #5a408a;
    --accent:       #7b2fa0;
    --accent-hover: #9b4fc0;
    --accent-dim:   #c090e0;
    --border:       #b090d8;
    --flag-color:   #c0442a;
    --flag-hover:   #e0552a;
    --flag-bg:      rgba(192, 68, 42, 0.1);
  }
}

/* ---- Rainbow ---- */
body.theme-rainbow {
  --bg:           #0a0a0f;
  --bg-surface:   #14141e;
  --bg-elevated:  #1e1e2e;
  --text:         #f0f0f8;
  --text-muted:   #8888aa;
  --accent:       #a855f7;
  --accent-hover: #c084fc;
  --accent-dim:   #7c3aed;
  --border:       #2a2a44;
  --flag-color:   #e8734a;
  --flag-hover:   #ff8c5a;
  --flag-bg:      rgba(232, 115, 74, 0.12);
  --curtain-fold: rgba(255,255,255,0.6);
  --rainbow: linear-gradient(90deg,
    #ff3333 0%, #ff8800 17%, #ffee00 33%,
    #33cc55 50%, #3388ff 67%, #aa33ff 83%, #ff33bb 100%);
  /* Curtain gradient stops: rainbow left→right */
  --cs1: #cc1111; --cs2: #cc5500; --cs3: #ccaa00;
  --cs4: #117722; --cs5: #1144bb; --cs6: #220033;
}

@media (prefers-color-scheme: light) {
  body.theme-rainbow {
    --bg:           #f8f8ff;
    --bg-surface:   #ededf8;
    --bg-elevated:  #ddddf0;
    --text:         #111118;
    --text-muted:   #55556a;
    --accent:       #7c3aed;
    --accent-hover: #a855f7;
    --accent-dim:   #c084fc;
    --border:       #c0c0e0;
  }
}

/* ---- Spotlight — stage black, golden amber ---- */
body.theme-spotlight {
  --bg:           #0a0a0a;
  --bg-surface:   #181818;
  --bg-elevated:  #242424;
  --text:         #fff8e0;
  --text-muted:   #aa9966;
  --accent:       #f0b030;
  --accent-hover: #ffd060;
  --accent-dim:   #c08020;
  --border:       #38301a;
  --flag-color:   #e8734a;
  --flag-hover:   #ff8c5a;
  --flag-bg:      rgba(232, 115, 74, 0.12);
  --curtain-fold: rgba(255, 220, 80, 0.4);
  --rainbow: none;
  /* Curtain: classic red velvet */
  --cs1: #500010; --cs2: #880020; --cs3: #bb1030;
  --cs4: #880020; --cs5: #500010; --cs6: #1a0005;
}

@media (prefers-color-scheme: light) {
  body.theme-spotlight {
    --bg:           #fffaf0;
    --bg-surface:   #f5ecd8;
    --bg-elevated:  #ebdcc0;
    --text:         #1a1405;
    --text-muted:   #6a5520;
    --accent:       #a06800;
    --accent-hover: #c08000;
    --accent-dim:   #e0b860;
    --border:       #d8c890;
    --flag-color:   #c0442a;
    --flag-hover:   #e0552a;
    --flag-bg:      rgba(192, 68, 42, 0.1);
  }
}

/* ---- Greasepaint — vaudeville warm sepia ---- */
body.theme-greasepaint {
  --bg:           #1a1008;
  --bg-surface:   #2a1c10;
  --bg-elevated:  #3a2818;
  --text:         #f5e8c8;
  --text-muted:   #c0a070;
  --accent:       #cc3333;
  --accent-hover: #ff5555;
  --accent-dim:   #882222;
  --border:       #5a3820;
  --flag-color:   #e8a030;
  --flag-hover:   #ffbe50;
  --flag-bg:      rgba(232, 160, 48, 0.12);
  --curtain-fold: rgba(255, 200, 100, 0.35);
  --rainbow: none;
  /* Curtain: warm burgundy/amber velvet */
  --cs1: #3a1500; --cs2: #702000; --cs3: #b04000;
  --cs4: #702000; --cs5: #3a1500; --cs6: #140800;
}

@media (prefers-color-scheme: light) {
  body.theme-greasepaint {
    --bg:           #fbf3e4;
    --bg-surface:   #f0e2c8;
    --bg-elevated:  #e4d0ac;
    --text:         #2a1808;
    --text-muted:   #6a4a28;
    --accent:       #aa2222;
    --accent-hover: #cc3333;
    --accent-dim:   #e09090;
    --border:       #c8a880;
    --flag-color:   #b07010;
    --flag-hover:   #d08820;
    --flag-bg:      rgba(176, 112, 16, 0.1);
  }
}

/* ---- Neon Stage — electric cyan & magenta ---- */
body.theme-neon {
  --bg:           #050510;
  --bg-surface:   #0c0c20;
  --bg-elevated:  #141430;
  --text:         #e0e0ff;
  --text-muted:   #7070b0;
  --accent:       #00e5ff;
  --accent-hover: #60ffff;
  --accent-dim:   #0090b0;
  --border:       #1a1a40;
  --flag-color:   #ff00aa;
  --flag-hover:   #ff44cc;
  --flag-bg:      rgba(255, 0, 170, 0.12);
  --curtain-fold: rgba(0, 229, 255, 0.5);
  --rainbow: linear-gradient(90deg, #00e5ff 0%, #ff00ff 50%, #00e5ff 100%);
  /* Curtain: deep electric indigo */
  --cs1: #000060; --cs2: #001090; --cs3: #0020cc;
  --cs4: #001090; --cs5: #000060; --cs6: #000020;
}

@media (prefers-color-scheme: light) {
  body.theme-neon {
    --bg:           #f4f6ff;
    --bg-surface:   #e6eaff;
    --bg-elevated:  #d6dcf8;
    --text:         #0a0a30;
    --text-muted:   #40407a;
    --accent:       #0088aa;
    --accent-hover: #00a0c8;
    --accent-dim:   #80d8f0;
    --border:       #b0b0e0;
    --flag-color:   #c00080;
    --flag-hover:   #e000a0;
    --flag-bg:      rgba(192, 0, 128, 0.1);
    --rainbow: linear-gradient(90deg, #0088aa 0%, #c000c0 50%, #0088aa 100%);
  }
}

/* ---- Sock & Buskin — comedy/tragedy teal & gold ---- */
body.theme-sockbuskin {
  --bg:           #0a1520;
  --bg-surface:   #102030;
  --bg-elevated:  #183040;
  --text:         #e8f4f0;
  --text-muted:   #80a8a0;
  --accent:       #20c8a0;
  --accent-hover: #40e8c0;
  --accent-dim:   #108060;
  --border:       #204050;
  --flag-color:   #e8b030;
  --flag-hover:   #ffd050;
  --flag-bg:      rgba(232, 176, 48, 0.12);
  --curtain-fold: rgba(32, 200, 160, 0.4);
  --rainbow: none;
  /* Curtain: deep teal-navy */
  --cs1: #001830; --cs2: #003050; --cs3: #005070;
  --cs4: #003050; --cs5: #001830; --cs6: #000810;
}

@media (prefers-color-scheme: light) {
  body.theme-sockbuskin {
    --bg:           #eef8f5;
    --bg-surface:   #ddefea;
    --bg-elevated:  #c8e4dc;
    --text:         #0a2028;
    --text-muted:   #406068;
    --accent:       #108060;
    --accent-hover: #20a080;
    --accent-dim:   #80d0b8;
    --border:       #a0c8c0;
    --flag-color:   #b07810;
    --flag-hover:   #d09020;
    --flag-bg:      rgba(176, 120, 16, 0.1);
  }
}

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

html { font-size: 16px; min-width: 400px; }

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  position: relative;
}

/* ---- Curtain ---- */
.curtain-container {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  display: flex;
}

#curtainSvg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* Valance is a fixed-height bar that never scales with the viewport */
#valanceSvg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 7rem;
  z-index: 1;
}

/* Left panel accordions toward the left edge */
#curtainLeft {
  transform-origin: left center;
  transform: scaleX(1);
}
/* Right panel accordions toward the right edge */
#curtainRight {
  transform-origin: right center;
  transform: scaleX(1);
}

@media (prefers-reduced-motion: no-preference) {
  .curtain-container.animate-open #curtainLeft {
    animation: curtainAccordionLeft var(--curtain-open-duration, 5s) ease-in-out forwards;
  }
  .curtain-container.animate-open #curtainRight {
    animation: curtainAccordionRight var(--curtain-open-duration, 5s) ease-in-out forwards;
  }

  @keyframes curtainAccordionLeft {
    from { transform: scaleX(1); }
    to   { transform: scaleX(var(--curtain-target-scale, 0.04)); }
  }
  @keyframes curtainAccordionRight {
    from { transform: scaleX(1); }
    to   { transform: scaleX(var(--curtain-target-scale, 0.04)); }
  }
}

/* Curtain stopped/done — freeze as thin strip at each edge */
.curtain-container.open-done #curtainLeft {
  animation: none;
}
.curtain-container.open-done #curtainRight {
  animation: none;
}

/* ---- Theme picker ---- */
.theme-picker {
  position: fixed;
  top: 1rem;
  right: 3rem;
  z-index: 150;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  padding: 0.35rem 0.75rem;
}

.theme-picker label {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.7);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.theme-picker select {
  background: #1a1a2e;
  border-color: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.85rem;
  padding: 0.2rem 0.4rem;
  width: auto;
}

/* ---- Page wrapper ---- */
.page-wrapper {
  max-width: 860px;
  margin: 0 auto;
  padding: 8rem 1.25rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* ---- Header ---- */
header h1 {
  font-size: clamp(2rem, 6vw, 3rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-align: center;
  color: var(--accent-hover);
  text-shadow: 0 0 20px rgba(155, 89, 182, 0.5);
}

body.theme-rainbow header h1,
body.theme-neon header h1 {
  color: transparent;
  text-shadow: none;
  background: var(--rainbow);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ---- Controls ---- */
.content-col {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  width: 100%;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 1rem;
  align-items: flex-end;
  background: var(--bg-surface);
  padding: 1.25rem 1.5rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  width: 100%;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.control-group label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

select {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  cursor: pointer;
  appearance: auto;
  width: 100%;
}

select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---- Buttons ---- */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.6rem 1.4rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  align-self: flex-end;
  white-space: nowrap;
}

.btn-primary-short-text {
  display: none;
}

.btn-primary:hover,
.btn-primary:focus-visible {
  background: var(--accent-hover);
  outline: 2px solid var(--accent-hover);
  outline-offset: 2px;
}

body.theme-rainbow .btn-primary,
body.theme-neon .btn-primary {
  background: var(--rainbow);
  color: #0a0a0f;
  font-weight: 700;
}

body.theme-rainbow .btn-primary:hover,
body.theme-rainbow .btn-primary:focus-visible,
body.theme-neon .btn-primary:hover,
body.theme-neon .btn-primary:focus-visible {
  opacity: 0.85;
  background: var(--rainbow);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 1.2rem;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-secondary:hover,
.btn-secondary:focus-visible {
  background: var(--accent-dim);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-flag {
  background: var(--flag-color);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.5rem 1.2rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-flag:hover,
.btn-flag:focus-visible {
  background: var(--flag-hover);
  outline: 2px solid var(--flag-hover);
  outline-offset: 2px;
}

/* ---- Activities area ---- */
#activitiesArea {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}

.activity-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.4rem 0.75rem;
  align-items: start;
  transition: border-color 0.2s;
}

.activity-card:hover {
  border-color: transparent;
  box-shadow: 0 0 0 1px transparent,
              inset 0 0 0 1px transparent;
  outline: 1px solid;
  outline-color: var(--accent-hover);
  /* Rainbow glow */
  box-shadow: 0 0 8px rgba(168, 85, 247, 0.4),
              0 0 2px rgba(255, 51, 51, 0.3);
}

/* activity header row: name + refresh */
.activity-header {
  grid-column: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.activity-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent-hover);
}

.btn-refresh {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.2rem;
  border-radius: 50%;
  transition: color 0.15s, background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-refresh:hover,
.btn-refresh:focus-visible {
  color: var(--accent-hover);
  background: rgba(155, 89, 182, 0.15);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

body.theme-rainbow .activity-name,
body.theme-neon .activity-name {
  color: transparent;
  background: var(--rainbow);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* substitution rows */
.sub-text {
  grid-column: 1;
  font-size: 0.9rem;
  color: var(--text-muted);
  align-self: center;
  padding-left: calc(1.1rem + 0.4rem + 0.5rem); /* button size + padding + gap */
}

.sub-text .item-name {
  color: var(--text);
  font-weight: 600;
  font-style: italic;
}

/* flag buttons — right column */
.btn-flag-row {
  grid-column: 3;
  background: none;
  border: 1px solid transparent;
  color: var(--flag-color);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.2rem 0.35rem;
  border-radius: 5px;
  opacity: 0.55;
  transition: opacity 0.15s, background 0.15s, border-color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-flag-row:hover,
.btn-flag-row:focus-visible {
  opacity: 1;
  background: var(--flag-bg);
  border-color: var(--flag-color);
  outline: 2px solid var(--flag-color);
  outline-offset: 2px;
}

/* Loading / empty state */
.state-message {
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  padding: 2rem 0;
}

/* ---- Modal ---- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.65);
}

.modal-content {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--flag-color);
  border-radius: 12px;
  padding: 2rem;
  max-width: 420px;
  width: 90%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.modal-content h2 {
  color: var(--flag-color);
  font-size: 1.2rem;
}

.modal-content p {
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.5;
}

.flag-comment-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.flag-comment {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  font-family: inherit;
  resize: vertical;
}

.flag-comment:focus {
  outline: none;
  border-color: var(--flag-color);
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* ---- Footer ---- */
footer {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

footer .disclaimer {
  font-style: italic;
  min-height: 1.2em;
  overflow: hidden;
}

@keyframes billboard-in-top {
  from { opacity: 0; transform: translateY(-120%); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes billboard-in-bottom {
  from { opacity: 0; transform: translateY(120%); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes billboard-out-top {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-120%); }
}

@keyframes billboard-out-bottom {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(120%); }
}

footer .disclaimer.bb-out-top      { animation: billboard-out-top    0.3s ease forwards; }
footer .disclaimer.bb-out-bottom   { animation: billboard-out-bottom 0.3s ease forwards; }
footer .disclaimer.bb-out-bottom-slow { animation: billboard-out-bottom 0.6s ease forwards; }
footer .disclaimer.bb-in-bottom    { animation: billboard-in-bottom  0.3s ease forwards; }
footer .disclaimer.bb-in-top       { animation: billboard-in-top     0.3s ease forwards; }

footer .version {
  opacity: 0.6;
}

/* ---- Responsive ---- */
@media (max-width: 540px) {
  .controls {
    flex-direction: column;
    align-items: stretch;
  }
  .btn-primary {
    align-self: stretch;
    text-align: center;
  }
  .activity-card {
    padding: 0.85rem 1rem;
  }
}
@media (max-width: 480px) {
  .btn-primary-long-text {
    display: none;
  }
  .btn-primary-short-text {
    display: inline;
  }
}

/* ---- Print (selected theme colors) ---- */
@media print {
  html { min-width: 0; }

  body,
  body[class] {
    background: #fff;
  }

  header h1,
  .activity-name {
    text-shadow: none;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .curtain-container,
  .theme-picker,
  .controls,
  .btn-refresh,
  .btn-flag-row,
  .modal,
  footer .disclaimer,
  footer .copyright,
  footer .version {
    display: none !important;
  }

  .page-wrapper {
    max-width: none;
    padding: 0;
    gap: 1rem;
  }

  .activity-card {
    background: none;
    border: none;
    box-shadow: none;
    break-inside: avoid;
  }

  .sub-text { padding-left: 0; }
  footer { border-top: none; }
}
