/* Store TV tag display — replaces d2icharity.com/TagSchedule/tags-display.html.
 * Everything is sized from the space actually available: app.js picks the
 * rows × columns that make the tags as large as possible and sets --w (tag
 * width in px); all tag text is in em of that width. Nothing ever scrolls,
 * whatever the screen or the number of tags. */

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

:root {
  --bg: #f3f4f6;
  --ink: #111827;
  --muted: #6b7280;
  --brand: #e11d48;
  --pad: clamp(10px, 2.5vmin, 40px);
}

html, body { height: 100%; }

body {
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: "Helvetica Neue", Arial, sans-serif;
  -webkit-user-select: none; user-select: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ---------- header ---------- */
.hd {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(4px, 1vmin, 12px);
  padding: var(--pad) var(--pad) 0;
  text-align: center;
}

.title {
  font-size: clamp(22px, 6vmin, 96px);
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.05;
}

.date {
  font-size: clamp(12px, 2vmin, 26px);
  font-weight: 600;
  color: var(--muted);
}

/* Corner menu: small and quiet so the page reads as title + tags. */
.menu-btn {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  z-index: 30;
  width: 40px;
  height: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 0.2s, background 0.2s;
}
.menu-btn span { width: 18px; height: 2px; border-radius: 2px; background: var(--ink); }
.menu-btn:hover, .menu-btn[aria-expanded="true"] { opacity: 1; background: #e5e7eb; }
.menu-btn:focus-visible { opacity: 1; outline: 3px solid var(--brand); outline-offset: 2px; }

.menu {
  position: fixed;
  top: calc(max(10px, env(safe-area-inset-top)) + 46px);
  right: max(10px, env(safe-area-inset-right));
  z-index: 30;
  display: flex;
  flex-direction: column;
  min-width: 190px;
  padding: 6px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}
.menu a, .menu button {
  appearance: none;
  border: 0;
  background: none;
  text-align: left;
  font-family: inherit;
  cursor: pointer;
  padding: 11px 14px;
  border-radius: 8px;
  color: var(--ink);
  font-weight: 600;
  font-size: 16px;
  text-decoration: none;
}
.menu a:hover, .menu button:hover { background: #f3f4f6; }
.menu button { border-top: 1px solid #e5e7eb; border-radius: 0 0 8px 8px; margin-top: 4px; color: var(--muted); }
.menu a[aria-current="page"] { background: var(--ink); color: #fff; }

/* Sale page: the image is the whole page. */
body.sale-page .hd { display: none; }
body.sale-page .stage { margin: 0; }
body.sale-page .sale { border-radius: 0; }
body.sale-page:has(.sale:not([hidden])) { background: #0b0b0c; }
body.sale-page:has(.sale:not([hidden])) .menu-btn span { background: #fff; }
body.sale-page:has(.sale:not([hidden])) .menu-btn:hover,
body.sale-page:has(.sale:not([hidden])) .menu-btn[aria-expanded="true"] { background: rgba(255, 255, 255, 0.2); }

/* TV mode: no cursor, menu button only while someone moves the mouse. */
body.kiosk { cursor: none; }
body.kiosk .menu-btn { opacity: 0; pointer-events: none; }
body.kiosk.awake { cursor: auto; }
body.kiosk.awake .menu-btn { opacity: 0.6; pointer-events: auto; }

/* ---------- stage ---------- */
.stage {
  flex: 1 1 0;
  min-height: 0;
  position: relative;
  margin: var(--pad);
  display: flex;
  align-items: center;
  justify-content: center;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: center;
  gap: var(--gap, 16px);
}

.tag {
  position: relative;
  flex: none;
  width: var(--w, 200px);
  height: calc(var(--w, 200px) * 1.5);
  font-size: calc(var(--w, 200px) / 100); /* 1em = 1% of tag width */
  filter: drop-shadow(0 0.04em 0.06em rgba(0, 0, 0, 0.2));
  transition: transform 1.1s ease-in-out, opacity 1.1s ease-in-out;
  animation: tag-in 0.6s cubic-bezier(0.2, 0.9, 0.3, 1.15) both;
  animation-delay: calc(var(--i, 0) * 90ms);
}
.tag svg { display: block; width: 100%; height: 100%; }

.tag-face {
  position: absolute;
  left: 5%;
  right: 5%;
  top: 27%;
  bottom: 5%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3em;
  text-align: center;
  font-weight: 900;
  line-height: 0.95;
  color: var(--tag-ink, #fff);
}
.tag-deal { display: flex; flex-direction: column; align-items: center; }
.tag-big { font-size: 34em; letter-spacing: -0.03em; }
.tag-big.long { font-size: 25em; }
.tag-small { font-size: 15em; letter-spacing: 0.02em; }
.tag-name { font-size: 14em; letter-spacing: 0.03em; }
.tag.full .tag-name { font-size: 19em; }

/* Discount tags breathe so the eye lands on them (legacy blinked). */
.tag.deal .tag-deal { animation: pulse 1.6s ease-in-out infinite; }

@keyframes tag-in {
  from { opacity: 0; transform: translateY(8%) scale(0.85); }
  to   { opacity: 1; transform: none; }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.07); }
}

/* Exit patterns carried over from the legacy display. */
.exit-left   { transform: translateX(-100vw); opacity: 0; }
.exit-right  { transform: translateX(100vw); opacity: 0; }
.exit-top    { transform: translateY(-100vh); opacity: 0; }
.exit-bottom { transform: translateY(100vh); opacity: 0; }
.exit-scale  { transform: scale(0); opacity: 0; }
.exit-fade   { transform: scale(1.4); opacity: 0; }
.exit-spin-l { transform: translateX(-100vw) rotate(-360deg); opacity: 0; }
.exit-spin-r { transform: translateX(100vw) rotate(360deg); opacity: 0; }

.msg {
  max-width: 22ch;
  text-align: center;
  font-weight: 800;
  font-size: clamp(22px, 6vmin, 90px);
  line-height: 1.15;
  color: #374151;
}
.msg small {
  display: block;
  margin-top: 0.6em;
  font-size: 0.45em;
  font-weight: 600;
  color: var(--muted);
}
.sale {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 12px;
}
[hidden] { display: none !important; }

/* ---------- promo slide (TV mode) ---------- */
.promo {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0b0b0c;
  animation: fade 0.5s ease both;
}
.promo img { max-width: 100%; max-height: 100%; object-fit: contain; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .tag, .tag.deal .tag-deal, .promo { animation: none; }
  .tag { transition: opacity 0.4s; }
  [class*="exit-"] { transform: none; }
}
