/* Tree of Lights — kiosk stylesheet
   Memorial/editorial: warm light emerging from darkness. Nothing flashes
   faster than 3x/sec anywhere in this file (seizure safety). */

:root {
  /* Surfaces — warm, never pure black */
  --bg:          #141110;
  --surface:     #221C18;
  --surface-2:   #2E2620;
  --border:      #3A322B;

  /* The Light — candlelight gold */
  --gold:        #E8B45C;
  --gold-bright: #F6D18A;
  --gold-deep:   #C89A4A;

  /* Text — warm ivory */
  --text:        #F4EEE4;
  --text-2:      #C9BEAE;
  --text-3:      #9A8F7E;
  --on-gold:     #141110;

  --warn:        #D98A6A;

  --glow: radial-gradient(circle at center,
            rgba(246, 209, 138, 0.20) 0%,
            rgba(246, 209, 138, 0.07) 32%,
            transparent 66%);

  --serif: ui-serif, "New York", Georgia, "Times New Roman", serif;
  --sans: -apple-system, system-ui, "SF Pro Text", "Helvetica Neue", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

.hidden { display: none !important; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 18px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

#app { position: relative; height: 100%; }

/* ------------------------------------------------------------------ */
/* Screens — cross-fade with a small rise                              */
/* ------------------------------------------------------------------ */

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 250ms ease-in, transform 250ms ease-in;
}

.screen.active {
  opacity: 1;
  transform: none;
  pointer-events: auto;
  transition: opacity 400ms ease-out 150ms, transform 400ms ease-out 150ms;
}

.screen-inner {
  width: 100%;
  max-width: 680px;
  padding: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 32px;
}

.screen-inner.narrow { max-width: 620px; }
.screen-inner.wide { max-width: 760px; }

/* ------------------------------------------------------------------ */
/* Type                                                                */
/* ------------------------------------------------------------------ */

.tagline {
  font-family: var(--serif);
  font-size: 48px;
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.welcome-sub {
  font-family: var(--serif);
  font-size: 22px;
  color: var(--text-2);
  max-width: 26em;
}

.screen-title {
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.005em;
}

.screen-hint { color: var(--text-2); font-size: 18px; margin-top: -16px; }

.count-line {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-top: 16px;
}

.count {
  display: block;
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 500;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
  margin-top: 8px;
}

/* ------------------------------------------------------------------ */
/* Buttons                                                             */
/* ------------------------------------------------------------------ */

.btn {
  font-family: var(--sans);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 120ms ease, background-color 120ms ease, opacity 120ms ease;
}

.btn:focus-visible { outline: 3px solid var(--gold-bright); outline-offset: 3px; }
.btn:active { transform: scale(0.98); }

.btn-primary {
  min-height: 64px;
  padding: 20px 40px;
  background: var(--gold);
  color: var(--on-gold);
  box-shadow: 0 0 24px rgba(232, 180, 92, 0.22);
}

.btn-primary:active { background: var(--gold-deep); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-hero { min-width: 320px; }

.btn-quiet {
  min-height: 56px;
  padding: 16px 32px;
  background: transparent;
  border: 1.5px solid var(--gold-deep);
  color: var(--gold);
}

.btn-quiet:active { background: rgba(232, 180, 92, 0.10); }

.btn-text {
  min-height: 60px;
  padding: 16px 24px;
  background: none;
  border: none;
  font-family: var(--sans);
  font-size: 18px;
  color: var(--text-2);
  cursor: pointer;
}

.btn-text:focus-visible { outline: 3px solid var(--gold-bright); outline-offset: 3px; }
.btn-back::before { content: "‹ "; }

.btn-row { display: flex; gap: 16px; justify-content: center; }

/* ------------------------------------------------------------------ */
/* Name input                                                          */
/* ------------------------------------------------------------------ */

.name-input {
  width: 100%;
  max-width: 440px;
  min-height: 64px;
  padding: 16px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 22px;
  text-align: center;
  -webkit-user-select: text;
  user-select: text;
}

.name-input::placeholder { color: var(--text-3); }
.name-input:focus { outline: none; border-color: var(--gold-deep); }

/* ------------------------------------------------------------------ */
/* Mitzvah grid                                                        */
/* ------------------------------------------------------------------ */

.mitzvah-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  width: 100%;
}

.mitzvah-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 120px;
  padding: 24px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 20px;
  font-weight: 500;
  line-height: 1.3;
  cursor: pointer;
  position: relative;
  transition: transform 120ms ease, border-color 120ms ease,
              background-color 120ms ease, box-shadow 120ms ease;
}

.mitzvah-card:active { transform: scale(0.98); }
.mitzvah-card:focus-visible { outline: 3px solid var(--gold-bright); outline-offset: 3px; }

.mitzvah-card svg {
  width: 32px;
  height: 32px;
  stroke: var(--text-2);
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mitzvah-card.selected {
  border: 2px solid var(--gold);
  background: rgba(232, 180, 92, 0.08);
  box-shadow: 0 0 20px rgba(232, 180, 92, 0.18);
}

.mitzvah-card.selected::after {
  content: "✓";
  position: absolute;
  top: 10px;
  right: 14px;
  color: var(--gold);
  font-size: 18px;
  font-weight: 600;
}

.mitzvah-card.ghost {
  background: transparent;
  border: 1.5px dashed var(--border);
  color: var(--text-2);
}

/* Custom mitzvah box */

.custom-box { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 8px; }

.custom-label {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}

.custom-note { font-size: 14px; color: var(--text-3); max-width: 30em; }

/* ------------------------------------------------------------------ */
/* Confirm                                                             */
/* ------------------------------------------------------------------ */

.confirm-lead { font-family: var(--serif); font-style: italic; font-size: 22px; color: var(--text-2); }

.confirm-mitzvah {
  font-family: var(--serif);
  font-size: 44px;
  font-weight: 500;
  line-height: 1.15;
}

.submit-error { color: var(--warn); font-size: 18px; min-height: 1.5em; }

/* ------------------------------------------------------------------ */
/* Tree illumination                                                   */
/* ------------------------------------------------------------------ */

.screen-dark { background: var(--bg); }

.tree-wrap { width: min(74vh, 90vw); max-width: 640px; }
.tree-wrap svg { width: 100%; height: auto; display: block; }

.tree-branch { stroke: var(--surface-2); fill: none; stroke-linecap: round; }

.tree-light {
  fill: #4A3B28;
  opacity: 0.4;
  transition: opacity 500ms ease-out, fill 500ms ease-out, r 500ms ease-out;
}

.tree-light.lit {
  fill: var(--gold-bright);
  opacity: 1;
  filter: url(#tol-glow);
}

/* Settled candle flicker — 3.5s period, far below any flash threshold */
.tree-settled .tree-light.lit {
  animation: flicker 3.5s ease-in-out infinite alternate;
  animation-delay: var(--fd, 0s);
}

@keyframes flicker {
  from { opacity: 1; }
  to { opacity: 0.93; }
}

.tree-caption {
  font-family: var(--serif);
  font-style: italic;
  font-size: 22px;
  color: var(--text-2);
  opacity: 0;
  transition: opacity 800ms ease-out;
}

.tree-caption.shown { opacity: 1; }

/* ------------------------------------------------------------------ */
/* Child name reveal — the name floats in candlelight, no box          */
/* ------------------------------------------------------------------ */

#screen-reveal .screen-inner { gap: 48px; }

.reveal-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding: 48px 24px;
}

.reveal-stage::before {
  content: "";
  position: absolute;
  inset: -15%;
  background: var(--glow);
  opacity: 0;
  transition: opacity 800ms ease-out;
  pointer-events: none;
}

.reveal-stage.glow::before { opacity: 1; }

.reveal-lead {
  font-family: var(--serif);
  font-style: italic;
  font-size: 22px;
  color: var(--text-2);
  opacity: 0;
  transition: opacity 500ms ease-out;
}

.reveal-photo {
  width: 180px;
  max-height: 230px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--gold-deep);
  filter: sepia(0.12);
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 800ms ease-out, transform 800ms ease-out;
}

.reveal-photo.shown { opacity: 1; transform: none; }

.reveal-name {
  font-family: var(--serif);
  font-size: 56px;
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: 0.01em;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 800ms ease-out, transform 800ms ease-out;
}

.reveal-rule {
  width: 48px;
  height: 1px;
  background: var(--gold-deep);
  transform: scaleX(0);
  transition: transform 400ms ease-out;
}

.reveal-detail {
  font-family: var(--serif);
  font-size: 20px;
  color: var(--text);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 500ms ease-out, transform 500ms ease-out;
}

.reveal-source {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--text-3);
  margin-top: 8px;
}

.reveal-stage .shown { opacity: 1; transform: none; }
.reveal-rule.shown { transform: scaleX(1); }

#reveal-continue { opacity: 0; transition: opacity 600ms ease-out; pointer-events: none; }
#reveal-continue.shown { opacity: 1; pointer-events: auto; }

/* ------------------------------------------------------------------ */
/* Thank you + welcome embers                                          */
/* ------------------------------------------------------------------ */

.thanks-title {
  font-family: var(--serif);
  font-size: 44px;
  font-weight: 500;
  line-height: 1.15;
}

.thanks-sub {
  font-family: var(--serif);
  font-size: 22px;
  color: var(--text-2);
  max-width: 24em;
}

.welcome-lights {
  display: flex;
  gap: 24px;
  justify-content: center;
}

.welcome-lights span {
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold-bright);
  box-shadow: 0 0 16px 4px rgba(246, 209, 138, 0.35);
  animation: flicker 4s ease-in-out infinite alternate;
}

.welcome-lights span:nth-child(2) { animation-delay: 0.9s; }
.welcome-lights span:nth-child(3) { animation-delay: 1.7s; }

/* ------------------------------------------------------------------ */
/* Landscape fallback (installation target is portrait)                */
/* ------------------------------------------------------------------ */

@media (orientation: landscape) and (max-height: 900px) {
  .screen-inner { gap: 24px; padding: 32px; }
  .tagline { font-size: 40px; }
  .reveal-name { font-size: 48px; }
  .mitzvah-card { min-height: 96px; padding: 16px 12px; font-size: 18px; }
  .tree-wrap { width: min(60vh, 50vw); }
  #screen-reveal .screen-inner { gap: 24px; }
  .reveal-stage { padding: 24px; gap: 16px; }
}

/* ------------------------------------------------------------------ */
/* Reduced motion                                                      */
/* ------------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  .screen { transform: none; transition: opacity 200ms ease; }
  .screen.active { transition: opacity 200ms ease; }
  .reveal-name, .reveal-detail { transform: none; transition: opacity 300ms ease; }
  .tree-light { transition: opacity 600ms ease, fill 600ms ease; }
  .tree-settled .tree-light.lit,
  .welcome-lights span { animation: none; }
}
