/* =========================================================
   Classroom Traffic Light — tool-specific styles.
   Layered on /tools/_shared/tool.css.
   Signal colors (green / amber / red) are local because they
   are tool-specific; everything else uses shared tokens so
   the dark/light theme switch keeps working.
   ========================================================= */

/* ---------- Signal color tokens (local) ---------- */
.tl-card {
  --sig-stop:        #EF4444;   /* red */
  --sig-stop-fg:     #991B1B;
  --sig-stop-bg:     #FEE2E2;
  --sig-stop-glow:   rgba(239, 68, 68, 0.55);

  --sig-caution:     #F59E0B;   /* amber */
  --sig-caution-fg:  #854D0E;
  --sig-caution-bg:  #FEF3C7;
  --sig-caution-glow: rgba(245, 158, 11, 0.55);

  --sig-go:          #22C55E;   /* green */
  --sig-go-fg:       #166534;
  --sig-go-bg:       #DCFCE7;
  --sig-go-glow:     rgba(34, 197, 94, 0.55);

  /* The light housing — a dark casing in both themes so the
     lit lamp reads as glowing, like a real traffic light. */
  --tl-housing-bg:     #1B2230;
  --tl-housing-border: #0C111B;
  --tl-lamp-off:       #2B3344;   /* unlit lamp face */
}

:root[data-theme="dark"] .tl-card {
  --sig-stop-fg:     #FCA5A5;
  --sig-stop-bg:     rgba(239, 68, 68, 0.16);
  --sig-caution-fg:  #FCD34D;
  --sig-caution-bg:  rgba(245, 158, 11, 0.16);
  --sig-go-fg:       #86EFAC;
  --sig-go-bg:       rgba(34, 197, 94, 0.16);

  --tl-housing-bg:     #11161F;
  --tl-housing-border: #060910;
  --tl-lamp-off:       #232B3A;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tl-card {
    --sig-stop-fg:     #FCA5A5;
    --sig-stop-bg:     rgba(239, 68, 68, 0.16);
    --sig-caution-fg:  #FCD34D;
    --sig-caution-bg:  rgba(245, 158, 11, 0.16);
    --sig-go-fg:       #86EFAC;
    --sig-go-bg:       rgba(34, 197, 94, 0.16);

    --tl-housing-bg:     #11161F;
    --tl-housing-border: #060910;
    --tl-lamp-off:       #232B3A;
  }
}

/* ---------- Card surface tint by active signal ---------- */
/* A soft wash of the active color so the cue is unmissable from
   the back of the room. The transition is calm — no flicker. */
.tl-card {
  transition: background-color 0.3s ease, border-color 0.3s ease;
}
.tl-card[data-signal="stop"]    { background: var(--sig-stop-bg);    border-color: var(--sig-stop); }
.tl-card[data-signal="caution"] { background: var(--sig-caution-bg); border-color: var(--sig-caution); }
.tl-card[data-signal="go"]      { background: var(--sig-go-bg);      border-color: var(--sig-go); }

/* ---------- Display ---------- */
.tl-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-5);
  margin-bottom: var(--space-5);
}

/* ---------- Housing + lamps ---------- */
.tl-housing {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(14px, 3vw, 24px);
  padding: clamp(16px, 4vw, 28px);
  background: var(--tl-housing-bg);
  border: 4px solid var(--tl-housing-border);
  border-radius: clamp(28px, 8vw, 48px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
}
.tl-lamp {
  position: relative;
  width: clamp(96px, 26vw, 168px);
  height: clamp(96px, 26vw, 168px);
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--tl-lamp-off);
  cursor: pointer;
  /* Dim unlit lamps; the active one is set to full opacity below. */
  opacity: 0.32;
  box-shadow: inset 0 4px 10px rgba(0, 0, 0, 0.45);
  transition: opacity 0.25s ease, box-shadow 0.25s ease, transform 0.1s ease;
  -webkit-tap-highlight-color: transparent;
}
.tl-lamp:hover { opacity: 0.5; }
.tl-lamp:active { transform: scale(0.97); }
.tl-lamp:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}
.tl-lamp-glow {
  position: absolute;
  inset: 0;
  border-radius: 50%;
}

/* Lamp face colors (shown faintly even when off so the order reads). */
.tl-lamp-stop    .tl-lamp-glow { background: var(--sig-stop); }
.tl-lamp-caution .tl-lamp-glow { background: var(--sig-caution); }
.tl-lamp-go      .tl-lamp-glow { background: var(--sig-go); }

/* Active lamp: full opacity + outer glow ring matching its color. */
.tl-card[data-signal="stop"]    #lamp-stop,
.tl-card[data-signal="caution"] #lamp-caution,
.tl-card[data-signal="go"]      #lamp-go {
  opacity: 1;
}
.tl-card[data-signal="stop"]    #lamp-stop {
  box-shadow: 0 0 0 4px rgba(255,255,255,0.08), 0 0 36px 6px var(--sig-stop-glow);
}
.tl-card[data-signal="caution"] #lamp-caution {
  box-shadow: 0 0 0 4px rgba(255,255,255,0.08), 0 0 36px 6px var(--sig-caution-glow);
}
.tl-card[data-signal="go"]      #lamp-go {
  box-shadow: 0 0 0 4px rgba(255,255,255,0.08), 0 0 36px 6px var(--sig-go-glow);
}

/* ---------- Caption + description group ---------- */
.tl-caption-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}
.tl-caption {
  font-size: clamp(34px, 8vw, 64px);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.02em;
  text-align: center;
  color: var(--text);
  transition: color 0.25s ease;
}
.tl-card[data-signal="stop"]    .tl-caption { color: var(--sig-stop-fg); }
.tl-card[data-signal="caution"] .tl-caption { color: var(--sig-caution-fg); }
.tl-card[data-signal="go"]      .tl-caption { color: var(--sig-go-fg); }
.tl-card.tl-no-caption .tl-caption { display: none; }

/* ---------- Description subtitle ---------- */
/* Shown only when the active light has a description (JS toggles
   .tl-has-desc). It follows the caption toggle: hiding the label
   hides its subtitle too. */
.tl-desc {
  display: none;
  max-width: 34ch;
  text-align: center;
  font-size: clamp(15px, 2.6vw, 21px);
  font-weight: 500;
  line-height: 1.3;
  color: var(--text-muted);
  transition: color 0.25s ease;
}
.tl-card.tl-has-desc .tl-desc { display: block; }
.tl-card.tl-no-caption .tl-desc { display: none; }

/* ---------- Hint ---------- */
.tl-hint {
  text-align: center;
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 0 0 var(--space-5);
}

/* ---------- Meta row (fullscreen) ---------- */
.tl-meta {
  display: flex;
  justify-content: center;
  margin-bottom: var(--space-6);
}
.tl-meta-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-colors);
}
.tl-meta-btn:hover { color: var(--text); border-color: var(--accent); }
.tl-meta-icon { width: 16px; height: 16px; flex-shrink: 0; }

/* ---------- Settings panel ---------- */
.tl-settings {
  border-top: 1px solid var(--border);
  padding-top: var(--space-6);
}
.tl-labels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}
.tl-label-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  transition: var(--transition-colors);
}
.tl-label-row:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.tl-label-top {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.tl-label-swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}
.tl-label-swatch.swatch-stop    { background: var(--sig-stop); }
.tl-label-swatch.swatch-caution { background: var(--sig-caution); }
.tl-label-swatch.swatch-go      { background: var(--sig-go); }
.tl-label-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  padding: 6px 0;
}
.tl-label-input:focus { outline: none; }

/* Optional per-light description input, sitting under its label. */
.tl-desc-input {
  width: 100%;
  min-width: 0;
  background: transparent;
  border: none;
  border-top: 1px solid var(--border);
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 6px 0 2px;
}
.tl-desc-input::placeholder { color: var(--text-muted); opacity: 0.6; }
.tl-desc-input:focus { outline: none; }

.tl-options {
  margin-top: var(--space-2);
}

/* ---------- Full-screen mode ---------- */
.tl-card:fullscreen {
  padding: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-8);
  border: none;
  border-radius: 0;
  overflow: hidden;
}
.tl-card:fullscreen[data-signal="stop"]    { background: var(--sig-stop-bg); }
.tl-card:fullscreen[data-signal="caution"] { background: var(--sig-caution-bg); }
.tl-card:fullscreen[data-signal="go"]      { background: var(--sig-go-bg); }
.tl-card:fullscreen .tl-text-header,
.tl-card:fullscreen .tl-hint,
.tl-card:fullscreen .tl-settings,
.tl-card:fullscreen .tl-meta {
  display: none;
}
.tl-card:fullscreen .tl-display {
  margin: 0;
  gap: clamp(24px, 5vh, 56px);
}
.tl-card:fullscreen .tl-housing {
  flex-direction: row;
  gap: clamp(24px, 6vw, 72px);
  padding: clamp(24px, 5vh, 56px);
}
.tl-card:fullscreen .tl-lamp {
  width: clamp(140px, 22vw, 360px);
  height: clamp(140px, 22vw, 360px);
}
.tl-card:fullscreen .tl-caption-group {
  gap: clamp(10px, 2.4vh, 28px);
}
.tl-card:fullscreen .tl-caption {
  font-size: clamp(80px, 16vw, 240px);
}
.tl-card:fullscreen .tl-desc {
  max-width: min(80vw, 28ch);
  font-size: clamp(24px, 4.4vw, 60px);
}

/* On tall/portrait displays in fullscreen, stack the lamps vertically
   like a real traffic light instead of the wide row. */
@media (orientation: portrait) {
  .tl-card:fullscreen .tl-housing {
    flex-direction: column;
  }
}
