/* ==========================================================================
   InCompetition — per-page layout.
   Everything here uses the tokens and components from design-system.css:
   no colour, spacing or size is invented on the spot.
   Mobile first: the media queries add room, they never take it away.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Sign in (student and admin)
   -------------------------------------------------------------------------- */

.login-page {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: var(--sp-4);
  background: radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--c-primary) 14%, var(--c-bg)), var(--c-bg));
}

.login-card {
  width: min(26rem, 100%);
}

.login-head {
  text-align: center;
  margin-bottom: var(--sp-5);
}

.login-head .brand {
  font-size: var(--fs-2xl);
  justify-content: center;
}

.login-head .brand__mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  font-size: var(--fs-lg);
}

.login-head p {
  margin-top: var(--sp-2);
  color: var(--c-text-muted);
}

.login-switch {
  margin-top: var(--sp-5);
  text-align: center;
  font-size: var(--fs-sm);
  color: var(--c-text-muted);
}

/* --------------------------------------------------------------------------
   Student home
   -------------------------------------------------------------------------- */

.status-hero {
  display: grid;
  gap: var(--sp-4);
}

.week-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

.week-meta__number {
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--c-text-muted);
}

.submission-status {
  display: grid;
  gap: var(--sp-4);
}

@media (min-width: 40rem) {
  .submission-status {
    grid-template-columns: 200px 1fr;
    align-items: start;
  }
}

/* The frame takes the shape of the photo: whole, never cropped, no empty bands. */
.submission-status__photo {
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--c-border);
  background: var(--c-surface-3);
}

.submission-status__photo img {
  display: block;
  width: 100%;
  max-height: 420px;
  object-fit: contain;
}

.history-item {
  display: flex;
  gap: var(--sp-3);
  align-items: center;
  padding: var(--sp-3);
  border-radius: var(--r-md);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
}

.history-item img {
  width: 56px;
  height: 72px;
  object-fit: contain;
  border-radius: var(--r-sm);
  flex: 0 0 auto;
  background: var(--c-surface-3);
}

.history-item__main { flex: 1; min-width: 0; }

.history-item__desc {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* --------------------------------------------------------------------------
   Voting — the deck screen (Tinder style)
   -------------------------------------------------------------------------- */

/* While the deck is up, voting takes over the screen: header, task, cards and
   buttons all fit, and nothing scrolls away under the thumb. */
body.is-voting {
  height: 100dvh;
  overflow: hidden;
}

body.is-voting .app-nav {
  display: none;
}

/* Vote confirmations sit at the top: at the bottom they would cover the buttons. */
body.is-voting .toast-region {
  top: max(var(--sp-3), env(safe-area-inset-top));
  bottom: auto;
}

/* The main element becomes the deck container. */
.main.vote-shell {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0;
}

.vote-top {
  flex: 0 0 auto;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  padding: var(--sp-2) var(--sp-4) var(--sp-3);
}

.vote-top__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  min-height: var(--tap);
}

/* The task stays on top for the whole session: nobody votes blind. */
.vote-task {
  margin-top: var(--sp-2);
  background: var(--c-primary-soft);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  font-size: var(--fs-sm);
  color: var(--c-text);
  display: flex;
  gap: var(--sp-2);
  align-items: flex-start;
}

.vote-task b {
  color: var(--c-primary-text);
  text-transform: uppercase;
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  flex: 0 0 auto;
  padding-top: 2px;
}

.vote-task__text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.vote-task.is-open .vote-task__text {
  -webkit-line-clamp: unset;
  display: block;
}

.vote-progress {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--c-text-muted);
}

.vote-progress .meter {
  width: 84px;
}

.deck-area {
  flex: 1 1 auto;
  position: relative;
  display: grid;
  place-items: center;
  padding: var(--sp-4);
  min-height: 0;
}

.deck {
  position: relative;
  width: min(22rem, 100%);
  height: 100%;
  max-height: 34rem;
}

/* Card hierarchy: the photo takes most of the space, the description lives in
   an opaque panel underneath — readable over any image, with no reliance on
   shadows or gradients laid over the photo. */
.vote-card {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-2);
  overflow: hidden;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  will-change: transform;
}

.vote-card--behind {
  transform: scale(0.94) translateY(14px);
  filter: saturate(0.85);
  box-shadow: var(--sh-1);
  pointer-events: none;
}

.vote-card--behind2 {
  transform: scale(0.88) translateY(28px);
  filter: saturate(0.7);
  box-shadow: var(--sh-1);
  pointer-events: none;
}

.vote-card__photo {
  flex: 1 1 auto;
  min-height: 0;
  background: var(--c-surface-3);
  position: relative;
}

.vote-card__photo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.vote-card__caption {
  flex: 0 0 auto;
  padding: var(--sp-3) var(--sp-4) var(--sp-4);
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
  font-size: var(--fs-md);
  line-height: 1.4;
  color: var(--c-text);
}

.vote-card.is-dragging {
  transition: none;
}

.vote-card.is-animating {
  transition: transform 280ms cubic-bezier(0.22, 0.61, 0.36, 1), opacity 280ms ease;
}

/* Stamp shown while swiping: it tells you which vote you are about to cast. */
.stamp {
  position: absolute;
  top: var(--sp-5);
  padding: var(--sp-2) var(--sp-4);
  border: 3px solid currentcolor;
  border-radius: var(--r-sm);
  font-size: var(--fs-xl);
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity 80ms linear;
  background: var(--c-surface);
  pointer-events: none;
}

.stamp--no {
  left: var(--sp-4);
  color: var(--c-vote-no);
  transform: rotate(-14deg);
}

.stamp--yes {
  right: var(--sp-4);
  color: var(--c-vote-yes);
  transform: rotate(14deg);
}

.stamp--maybe {
  left: 50%;
  top: 40%;
  translate: -50% 0;
  color: var(--c-vote-maybe);
}

/* Actions: always present — not a fallback for the swipe. */
.vote-actions {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4) max(var(--sp-4), env(safe-area-inset-bottom));
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
}

.vote-btn {
  display: grid;
  gap: 2px;
  place-items: center;
  min-height: var(--tap-lg);
  padding: var(--sp-2);
  border-radius: var(--r-md);
  border: 2px solid var(--c-border-strong);
  background: var(--c-surface);
  color: var(--c-text);
  font: inherit;
  cursor: pointer;
  transition: transform var(--transition), background var(--transition), border-color var(--transition);
}

.vote-btn__num {
  font-size: var(--fs-xl);
  font-weight: 900;
  line-height: 1;
}

.vote-btn__label {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.vote-btn:hover { transform: translateY(-2px); }
.vote-btn:active { transform: translateY(0); }

.vote-btn--no { color: var(--c-vote-no); border-color: color-mix(in srgb, var(--c-vote-no) 75%, var(--c-surface)); }
.vote-btn--no:hover { background: var(--c-vote-no-soft); border-color: var(--c-vote-no); }

.vote-btn--maybe { color: var(--c-vote-maybe); border-color: color-mix(in srgb, var(--c-vote-maybe) 75%, var(--c-surface)); }
.vote-btn--maybe:hover { background: var(--c-vote-maybe-soft); border-color: var(--c-vote-maybe); }

.vote-btn--yes { color: var(--c-vote-yes); border-color: color-mix(in srgb, var(--c-vote-yes) 75%, var(--c-surface)); }
.vote-btn--yes:hover { background: var(--c-vote-yes-soft); border-color: var(--c-vote-yes); }

/* Disabled without opacity: the label stays as readable as everywhere else. */
.vote-btn[disabled] {
  background: var(--c-surface-2);
  border-color: var(--c-border);
  color: var(--c-text-muted);
  cursor: not-allowed;
  transform: none;
}

.vote-help {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-3);
  padding: 0 var(--sp-4) var(--sp-2);
  background: var(--c-surface);
  font-size: var(--fs-xs);
  color: var(--c-text-muted);
}

@media (min-width: 48rem) {
  .deck { max-height: 30rem; }
  .vote-actions {
    max-width: 30rem;
    margin-inline: auto;
    width: 100%;
    border-top: none;
  }
  .vote-help { justify-content: center; gap: var(--sp-5); }
}

/* --------------------------------------------------------------------------
   Voting — the superlike screen
   -------------------------------------------------------------------------- */

.superlike-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-3);
}

@media (min-width: 40rem) {
  .superlike-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 64rem) {
  .superlike-grid { grid-template-columns: repeat(4, 1fr); }
}

.superlike-item {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 0;
  border: 2px solid var(--c-border);
  border-radius: var(--r-md);
  background: var(--c-surface);
  color: var(--c-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}

.superlike-item:hover {
  border-color: var(--c-primary);
  transform: translateY(-3px);
  box-shadow: var(--sh-2);
}

.superlike-item img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: contain;
  background: var(--c-surface-3);
}

.superlike-item__caption {
  padding: var(--sp-3);
  font-size: var(--fs-sm);
  line-height: 1.35;
}

.superlike-item[aria-pressed="true"] {
  border-color: var(--c-vote-super);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c-vote-super) 30%, transparent);
}

.superlike-item[aria-pressed="true"]::after {
  content: "★ Superlike";
  position: absolute;
  top: var(--sp-2);
  right: var(--sp-2);
  padding: 0.25em 0.7em;
  border-radius: var(--r-pill);
  background: var(--c-vote-super);
  color: #fff;
  font-size: var(--fs-xs);
  font-weight: 800;
}

/* --------------------------------------------------------------------------
   Admin panel
   -------------------------------------------------------------------------- */

.tabs {
  display: flex;
  gap: var(--sp-1);
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--c-border);
  margin-bottom: var(--sp-5);
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 0 0 auto;
  min-height: var(--tap);
  padding: var(--sp-2) var(--sp-4);
  border: none;
  border-bottom: 3px solid transparent;
  background: none;
  color: var(--c-text-muted);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
}

.tab:hover { color: var(--c-text); background: var(--c-surface-2); }

.tab[aria-selected="true"] {
  color: var(--c-primary-text);
  border-bottom-color: var(--c-primary);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
  gap: var(--sp-3);
}

.stat {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
}

.stat__value {
  font-size: var(--fs-2xl);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.stat__label {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--c-text-muted);
  font-weight: 700;
}

.mod-grid {
  display: grid;
  gap: var(--sp-4);
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
}

.mod-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  background: var(--c-surface);
  overflow: hidden;
}

.mod-card__photo {
  aspect-ratio: 4 / 3;
  object-fit: contain;
  width: 100%;
  background: var(--c-surface-3);
}

.mod-card__body {
  padding: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  flex: 1;
}

.mod-card__name {
  font-weight: 700;
}

.mod-card__actions {
  display: flex;
  gap: var(--sp-2);
  margin-top: auto;
  flex-wrap: wrap;
}

.mod-card__actions .btn { flex: 1 1 auto; }

.mod-card.is-hidden-post { border-color: color-mix(in srgb, var(--c-danger) 40%, transparent); }
.mod-card.is-accepted { border-color: color-mix(in srgb, var(--c-success) 40%, transparent); }

.phase-actions {
  display: grid;
  gap: var(--sp-3);
}

@media (min-width: 40rem) {
  .phase-actions { grid-auto-flow: column; grid-auto-columns: 1fr; }
}

/* --------------------------------------------------------------------------
   Leaderboards and awards
   -------------------------------------------------------------------------- */

.podium {
  display: grid;
  gap: var(--sp-3);
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
}

.winner-card {
  display: grid;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-radius: var(--r-lg);
  background: var(--c-medal-soft);
  border: 2px solid var(--c-medal-border);
  text-align: center;
  justify-items: center;
}

.winner-card img {
  width: 100%;
  max-width: 12rem;
  aspect-ratio: 3 / 4;
  object-fit: contain;
  background: var(--c-surface-3);
  border-radius: var(--r-md);
  border: 1px solid var(--c-medal-border);
}

.winner-card__name {
  font-size: var(--fs-lg);
  font-weight: 800;
  color: var(--c-medal);
}

.week-switcher {
  display: flex;
  gap: var(--sp-2);
  overflow-x: auto;
  padding-bottom: var(--sp-2);
  scrollbar-width: none;
}

.week-switcher::-webkit-scrollbar { display: none; }

.week-chip {
  flex: 0 0 auto;
  min-height: var(--tap);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-pill);
  border: 1px solid var(--c-border-strong);
  background: var(--c-surface);
  color: var(--c-text);
  font: inherit;
  font-weight: 650;
  font-size: var(--fs-sm);
  cursor: pointer;
  white-space: nowrap;
}

.week-chip:hover { background: var(--c-surface-2); }

.week-chip[aria-pressed="true"] {
  background: var(--c-primary);
  border-color: var(--c-primary);
  color: #fff;
}

.award-sheet {
  background: var(--c-surface);
  border-radius: var(--r-lg);
  padding: var(--sp-6);
  border: 1px solid var(--c-border);
}

.award-sheet h1 {
  font-size: var(--fs-3xl);
  text-align: center;
}

.award-list {
  list-style: none;
  margin: var(--sp-5) 0 0;
  padding: 0;
  display: grid;
  gap: var(--sp-2);
}

.award-list li {
  display: grid;
  grid-template-columns: 3rem 1fr auto;
  gap: var(--sp-3);
  align-items: center;
  padding: var(--sp-3);
  border-radius: var(--r-md);
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  page-break-inside: avoid;
}

.award-list li.is-winner {
  background: var(--c-medal-soft);
  border-color: var(--c-medal-border);
}

.award-points {
  font-size: var(--fs-xl);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
