/* ============================================================================
   TechSchool — House Cup public page theme (STANDALONE).
   "Great hall at night": deep navy, glowing crests, ceremonial gold.
   This stylesheet is used ONLY by templates/public/cup.html. It is intentionally
   kept separate from the app's app.css so it can diverge freely.
   Adapted from the housingsystem.local public theme.
   ========================================================================== */

:root {
  --c-bg:        221 44% 13%;
  --c-bg-2:      221 38% 18%;
  --c-surface:   221 33% 23%;
  --c-surface-2: 221 29% 29%;
  --c-line:      221 45% 72%;
  --c-fg:        222 100% 96%;
  --c-fg-muted:  221 38% 74%;
  --c-fg-dim:    221 24% 58%;

  --c-gold:      41 76% 60%;
  --c-gold-deep: 38 64% 46%;
  --c-success:   152 56% 52%;
  --c-error:     356 80% 66%;

  --font-display: "Fraunces", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --step--2: clamp(0.69rem, 0.67rem + 0.1vw, 0.75rem);
  --step--1: clamp(0.8rem, 0.77rem + 0.15vw, 0.875rem);
  --step-0:  clamp(0.95rem, 0.92rem + 0.2vw, 1.05rem);
  --step-1:  clamp(1.15rem, 1.05rem + 0.5vw, 1.4rem);
  --step-2:  clamp(1.45rem, 1.25rem + 1vw, 2rem);
  --step-3:  clamp(2rem, 1.5rem + 2.4vw, 3.4rem);
  --step-4:  clamp(2.6rem, 1.7rem + 4vw, 5rem);
  --leading-body: 1.6;

  --sp-2xs: 0.375rem; --sp-xs: 0.625rem; --sp-s: 1rem;
  --sp-m: 1.5rem; --sp-l: 2.25rem; --sp-xl: 3.5rem; --sp-2xl: 5.5rem;
  --radius: 14px;
  --radius-s: 9px;
  --radius-pill: 999px;
  --shadow-1: 0 2px 8px hsl(222 60% 4% / 0.4);
  --shadow-2: 0 18px 50px -16px hsl(222 70% 3% / 0.7);
  --tap: 44px;
  --container: 78rem;

  --dur-1: 120ms; --dur-2: 240ms; --dur-3: 420ms;
  --ease-out: cubic-bezier(0.2, 0, 0, 1);
  --ease-spring: cubic-bezier(0.34, 1.4, 0.64, 1);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh;
  font-family: var(--font-sans); font-size: var(--step-0); line-height: var(--leading-body);
  color: hsl(var(--c-fg));
  background:
    radial-gradient(120% 80% at 50% -10%, hsl(217 64% 26% / 0.6), transparent 60%),
    linear-gradient(180deg, hsl(var(--c-bg)) 0%, hsl(var(--c-bg-2)) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased; overflow-x: clip;
}

#constellation { position: fixed; inset: 0; z-index: 0; width: 100%; height: 100%; pointer-events: none; }

a { color: hsl(var(--c-gold)); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 2px solid hsl(var(--c-gold)); outline-offset: 3px; border-radius: 4px; }

/* ---- Layout ---- */
.wrap { position: relative; z-index: 1; width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: clamp(1rem, 4vw, 2.5rem); }
.section { margin-top: var(--sp-xl); }
.eyebrow {
  font-size: var(--step--2); letter-spacing: 0.28em; text-transform: uppercase;
  color: hsl(var(--c-gold)); font-weight: 600; display: inline-flex; align-items: center; gap: 0.6em;
}
.eyebrow::before, .eyebrow::after {
  content: ""; height: 1px; width: clamp(18px, 6vw, 44px);
  background: linear-gradient(90deg, transparent, hsl(var(--c-gold) / 0.7));
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.08; margin: 0; }

/* ---- Masthead ---- */
.masthead { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-s); padding-block: var(--sp-m); }
.brand { display: flex; align-items: center; gap: 0.7rem; min-width: 0; }
.brand__mark {
  --size: clamp(40px, 11vw, 52px); width: var(--size); height: var(--size); flex-shrink: 0;
  border-radius: 50%; display: grid; place-items: center; box-sizing: border-box;
  background: radial-gradient(circle at 50% 36%, #fff, #e7edf8 80%);
  box-shadow: 0 2px 10px hsl(222 60% 4% / 0.4), 0 0 0 1px hsl(var(--c-gold) / 0.45);
}
.brand__mark b { font-family: var(--font-display); font-weight: 600; color: hsl(221 50% 22%); font-size: calc(var(--size) * 0.36); letter-spacing: -0.02em; }
.brand__mark img { width: 78%; height: 78%; object-fit: contain; border-radius: 50%; }
.brand__txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.1; }
.brand__txt b { font-family: var(--font-display); font-size: var(--step-1); font-weight: 600; color: hsl(var(--c-fg)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand__txt span { font-size: var(--step--2); letter-spacing: 0.18em; text-transform: uppercase; color: hsl(var(--c-gold)); font-weight: 600; }

/* Staff sign-in / back link pill */
.signin-link {
  display: inline-flex; align-items: center; gap: 0.5rem; flex-shrink: 0;
  min-height: var(--tap); padding: 0 1.1rem; border-radius: var(--radius-pill);
  border: 1px solid hsl(var(--c-gold) / 0.5); background: hsl(var(--c-gold) / 0.07);
  color: hsl(var(--c-gold)); font-weight: 600; font-size: var(--step--1); cursor: pointer; white-space: nowrap;
  transition: background var(--dur-1), border-color var(--dur-1), transform var(--dur-1);
}
.signin-link:hover { background: hsl(var(--c-gold) / 0.15); border-color: hsl(var(--c-gold) / 0.85); text-decoration: none; }
.signin-link:active { transform: scale(0.97); }
.signin-link .icon { width: 1.05rem; height: 1.05rem; }
@media (max-width: 22rem) { .signin-link__txt { display: none; } }

/* ---- Trophy hero ---- */
.trophy { --size: clamp(116px, 32vw, 196px); position: relative; width: var(--size); margin: 0 auto var(--sp-m); display: grid; place-items: center; isolation: isolate; }
.trophy::before { content: ""; position: absolute; z-index: -1; width: 116%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle, hsl(var(--c-gold) / 0.32), transparent 66%); }
.trophy svg { width: 100%; height: auto; display: block; filter: drop-shadow(0 12px 22px hsl(222 70% 3% / 0.55)); animation: trophy-float 6s var(--ease-out) infinite; }
@keyframes trophy-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

.hero { padding-block: clamp(2rem, 7vw, 4.5rem) clamp(1rem, 3vw, 2rem); text-align: center; }
.hero h1 { font-size: var(--step-4); margin: 0.4rem 0 0; letter-spacing: -0.01em; }
.hero .gold { color: hsl(var(--c-gold)); }
.hero .lede { margin: var(--sp-s) auto 0; max-width: 46ch; color: hsl(var(--c-fg-muted)); font-size: var(--step-0); }

/* Leader spotlight */
.leader {
  display: inline-flex; align-items: center; gap: var(--sp-m); margin-top: var(--sp-l);
  padding: var(--sp-s) var(--sp-m) var(--sp-s) var(--sp-s);
  background: linear-gradient(180deg, hsl(var(--c-surface) / 0.7), hsl(var(--c-surface) / 0.4));
  border: 1px solid hsl(var(--c-gold) / 0.35); border-radius: var(--radius);
  box-shadow: var(--shadow-2), 0 0 60px -20px hsl(var(--c-gold) / 0.5); text-align: left; max-width: 100%;
}
.leader__crest { width: clamp(64px, 18vw, 92px); height: auto; flex-shrink: 0; filter: drop-shadow(0 6px 16px hsl(222 70% 3% / 0.6)); }
.leader__label { font-size: var(--step--2); letter-spacing: 0.22em; text-transform: uppercase; color: hsl(var(--c-gold)); font-weight: 600; display: flex; align-items: center; gap: 0.45em; }
.leader__name { font-family: var(--font-display); font-size: var(--step-2); margin: 0.1rem 0; }
.leader__pts { color: hsl(var(--c-fg-muted)); font-size: var(--step--1); }
.leader__pts b { color: hsl(var(--c-fg)); font-size: var(--step-0); font-variant-numeric: tabular-nums; }

.icon { width: 1em; height: 1em; display: inline-block; vertical-align: -0.12em; }

/* ---- House crest cards ---- */
.houses { display: grid; gap: clamp(0.75rem, 2vw, 1.25rem); grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 56rem) { .houses { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.house {
  --hue: #E7B84B; position: relative; display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: var(--sp-m) var(--sp-s) var(--sp-s);
  background:
    radial-gradient(120% 60% at 50% 0%, color-mix(in srgb, var(--hue) 16%, transparent), transparent 70%),
    linear-gradient(180deg, hsl(var(--c-surface) / 0.85), hsl(var(--c-surface) / 0.5));
  border: 1px solid hsl(var(--c-line) / 0.14); border-top: 2px solid color-mix(in srgb, var(--hue) 80%, transparent);
  border-radius: var(--radius); box-shadow: var(--shadow-1); color: inherit;
  transition: transform var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out), border-color var(--dur-2);
  overflow: hidden;
}
.house:hover, .house:focus-visible { transform: translateY(-4px); text-decoration: none; border-color: color-mix(in srgb, var(--hue) 50%, transparent); box-shadow: var(--shadow-2), 0 0 50px -22px var(--hue); }
.house:active { transform: translateY(-1px); }
.house__rank { position: absolute; top: 10px; left: 12px; font-family: var(--font-display); font-size: var(--step--1); color: hsl(var(--c-fg-dim)); }
.house__rank.is-first { color: hsl(var(--c-gold)); }
.house__crown { position: absolute; top: 8px; right: 10px; color: hsl(var(--c-gold)); width: 1.25rem; height: 1.25rem; }
.house__crest { height: clamp(96px, 26vw, 132px); width: auto; margin: 0.25rem auto var(--sp-xs); filter: drop-shadow(0 8px 18px hsl(222 70% 3% / 0.55)); transition: transform var(--dur-3) var(--ease-spring); }
.house:hover .house__crest { transform: scale(1.05) rotate(-1deg); }
/* Fallback monogram medallion when a house has no emblem uploaded */
.house__crest--mono { height: clamp(96px, 26vw, 132px); width: clamp(96px, 26vw, 132px); border-radius: 50%; display: grid; place-items: center; margin: 0.25rem auto var(--sp-xs); background: radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--hue) 40%, #1c2740), color-mix(in srgb, var(--hue) 14%, #1c2740)); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--hue) 60%, transparent), 0 8px 18px hsl(222 70% 3% / 0.5); }
.house__crest--mono b { font-family: var(--font-display); font-size: clamp(2rem, 7vw, 3rem); color: #fff; }
.house__name { font-family: var(--font-display); font-size: var(--step-1); color: hsl(var(--c-fg)); line-height: 1.05; }
.house__pts { font-size: clamp(1.8rem, 7vw, 2.4rem); font-weight: 600; font-family: var(--font-display); color: hsl(var(--c-fg)); font-variant-numeric: tabular-nums; margin-top: var(--sp-xs); line-height: 1; }
.house__pts.is-neg { color: hsl(var(--c-error)); }
.house__unit { font-size: var(--step--2); letter-spacing: 0.18em; text-transform: uppercase; color: hsl(var(--c-fg-dim)); }
.meter { margin-top: var(--sp-s); width: 100%; height: 7px; background: hsl(var(--c-bg) / 0.6); border-radius: var(--radius-pill); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, color-mix(in srgb, var(--hue) 60%, transparent), var(--hue)); box-shadow: 0 0 12px color-mix(in srgb, var(--hue) 60%, transparent); transform-origin: left; animation: rise var(--dur-3) var(--ease-out) both; }
@keyframes rise { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ---- Panels (charts, feed, campus) ---- */
.grid { display: grid; gap: clamp(0.75rem, 2vw, 1.25rem); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 56rem) {
  .grid.cols-3 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
  .grid.cols-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
.panel { background: linear-gradient(180deg, hsl(var(--c-surface) / 0.8), hsl(var(--c-surface) / 0.45)); border: 1px solid hsl(var(--c-line) / 0.12); border-radius: var(--radius); padding: var(--sp-m); box-shadow: var(--shadow-1); }
.panel__title { font-family: var(--font-sans); font-weight: 600; font-size: var(--step--1); letter-spacing: 0.08em; text-transform: uppercase; color: hsl(var(--c-fg-muted)); margin: 0 0 var(--sp-s); display: flex; align-items: center; gap: 0.5rem; }
.panel--link { display: block; color: inherit; text-decoration: none; cursor: pointer; transition: transform var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out), border-color var(--dur-2); }
.panel--link:hover, .panel--link:focus-visible { transform: translateY(-4px); text-decoration: none; border-color: hsl(var(--c-gold) / 0.45); box-shadow: var(--shadow-2), 0 0 50px -26px hsl(var(--c-gold)); }
.panel--link:active { transform: translateY(-1px); }
.chartbox { position: relative; height: 280px; }
.empty { text-align: center; color: hsl(var(--c-fg-dim)); padding: var(--sp-l) 0; font-size: var(--step--1); }
.note { font-size: var(--step--2); color: hsl(var(--c-fg-dim)); margin-top: var(--sp-s); }

.donut { display: grid; gap: var(--sp-s) var(--sp-m); align-items: center; }
@media (min-width: 22rem) { .donut { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); } }
.donut .chartbox { height: 200px; }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-xs); }
.legend li { display: flex; align-items: center; gap: 0.6rem; font-size: var(--step--1); }
.legend__dot { width: 12px; height: 12px; border-radius: 4px; flex-shrink: 0; box-shadow: 0 1px 4px hsl(222 60% 4% / 0.5); }
.legend__name { color: hsl(var(--c-fg-muted)); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend__val { margin-left: auto; font-weight: 600; color: hsl(var(--c-fg)); font-variant-numeric: tabular-nums; }

/* Feed */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; align-items: center; gap: var(--sp-s); padding: var(--sp-xs) 0; border-top: 1px solid hsl(var(--c-line) / 0.08); }
.feed li:first-child { border-top: 0; }
.feed__dot { width: 34px; height: 34px; flex-shrink: 0; border-radius: var(--radius-pill); display: grid; place-items: center; font-weight: 700; color: white; box-shadow: 0 0 14px -2px var(--dot, hsl(var(--c-gold) / 0.6)); }
.feed__body { min-width: 0; flex: 1; }
.feed__body .h { font-size: var(--step--1); color: hsl(var(--c-fg)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed__body .h b { font-weight: 600; }
.feed__body .t { font-size: var(--step--2); color: hsl(var(--c-fg-dim)); }
.feed__amt { font-weight: 700; font-variant-numeric: tabular-nums; font-size: var(--step-0); }
.feed__amt.up { color: hsl(var(--c-success)); }
.feed__amt.down { color: hsl(var(--c-error)); }

/* Campus bars */
.bars { display: flex; flex-direction: column; gap: var(--sp-s); }
.bars .row .top { display: flex; justify-content: space-between; font-size: var(--step--1); margin-bottom: 0.3rem; }
.bars .row .top span { color: hsl(var(--c-fg-muted)); }
.bars .row .top b { color: hsl(var(--c-fg)); font-variant-numeric: tabular-nums; }
.bars .track { height: 8px; background: hsl(var(--c-bg) / 0.6); border-radius: var(--radius-pill); overflow: hidden; }
.bars .track > i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, hsl(var(--c-gold-deep)), hsl(var(--c-gold))); }

/* Footer + back link */
.site-nav { position: relative; z-index: 1; margin-top: var(--sp-2xl); padding-top: var(--sp-l); border-top: 1px solid hsl(var(--c-line) / 0.12); text-align: center; }
.back-link { display: inline-flex; align-items: center; gap: 0.4rem; font-size: var(--step--1); color: hsl(var(--c-fg-muted)); }
.foot { position: relative; z-index: 1; text-align: center; color: hsl(var(--c-fg-dim)); font-size: var(--step--2); padding: var(--sp-xl) var(--sp-s) calc(var(--sp-l) + env(safe-area-inset-bottom)); }
.foot a { color: hsl(var(--c-fg-muted)); }

/* ---- Mobile collapse ---- */
@media (max-width: 30rem) {
  .masthead { gap: var(--sp-xs); }
  .leader { flex-direction: column; text-align: center; gap: var(--sp-xs); padding: var(--sp-m) var(--sp-m) var(--sp-s); }
  .leader__label { justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  .house:hover { transform: none; }
  .panel--link:hover { transform: none; }
}
