/* Leaderboard and admin pages. */

.page-head {
  padding: clamp(1.6rem, 5vw, 2.6rem) 0 1.2rem;
  text-align: center;
}
.page-head h1 { font-size: clamp(1.9rem, 7vw, 3rem); }
.page-head .mal {
  display: block;
  font-size: clamp(1.05rem, 3.6vw, 1.4rem);
  color: var(--green);
  margin-top: .1rem;
}
.page-head p { color: var(--muted); margin: .6rem 0 0; }

.crumbs {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding-top: .9rem;
}

.section-title {
  display: flex;
  align-items: baseline;
  gap: .6rem;
  margin: 2rem 0 .9rem;
  font-size: 1.2rem;
}
.section-title .mal { font-size: .98rem; color: var(--muted); }

/* --- champions ------------------------------------------------------------ */

.champs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: .8rem;
  list-style: none;
  padding: 0;
  margin: 0;
}

.champ {
  position: relative;
  padding: 1rem 1.05rem 1.1rem;
  border-radius: var(--radius);
  background: var(--paper);
  border: 1px solid rgba(192, 138, 30, .22);
  box-shadow: var(--shadow-sm);
}
.champ--held {
  background: linear-gradient(180deg, #FFFBF0, var(--paper));
  border-color: var(--gold);
}

.champ__game {
  margin: 0;
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--muted);
}
.champ__game .mal { color: var(--green); font-weight: 500; }

.champ__score {
  margin: .25rem 0 .1rem;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.9rem;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.champ__score small {
  font-family: var(--font-body);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}

.champ__names {
  margin: .3rem 0 0;
  font-weight: 700;
  color: var(--green);
  overflow-wrap: break-word;
}
.champ__names em {
  font-style: normal;
  font-weight: 500;
  color: var(--muted);
}

/* --- one game's board ------------------------------------------------------ */

.board-picker { flex-wrap: wrap; margin-bottom: 1rem; }

.board-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  background: var(--paper);
  border: 1px solid rgba(192, 138, 30, .22);
  box-shadow: var(--shadow-md);
}

.board {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.board th {
  padding: .7rem .9rem;
  text-align: left;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.board td {
  padding: .72rem .9rem;
  border-bottom: 1px solid rgba(43, 31, 18, .07);
}
.board tr:last-child td { border-bottom: 0; }

.board .col-rank  { width: 3.4rem; }
.board .col-score { text-align: right; font-weight: 800; }
.board .col-when  { width: 7rem; color: var(--muted); font-size: .84rem; white-space: nowrap; }

/* The value never wraps; its heading may, so a long unit like "time to serve"
   does not steal the width the names need. */
.board td.col-score { white-space: nowrap; }
.board th.col-score { text-align: right; white-space: normal; }

.board .name { font-weight: 700; overflow-wrap: break-word; }

/* On a phone the date is the first thing worth losing. */
@media (max-width: 540px) {
  .board .col-when { display: none; }
  .board th, .board td { padding-inline: .6rem; }
}

.rank-pill {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  padding: 0 .4rem;
  border-radius: 999px;
  background: var(--cream-deep);
  font-weight: 800;
  font-size: .9rem;
}
.rank-1 .rank-pill { background: var(--marigold); color: #3A2405; }
.rank-2 .rank-pill { background: #DFD6C2; }
.rank-3 .rank-pill { background: #E8CFAE; }
.rank-1 { background: rgba(239, 154, 30, .07); }

.joint {
  margin-left: .4rem;
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--gold);
}

.empty-note {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--muted);
}

.offline-note {
  margin-top: 1rem;
  padding: 1.1rem 1.2rem;
  border-radius: var(--radius);
  background: var(--paper);
  border: 1px dashed var(--gold);
  color: var(--muted);
  text-align: center;
}
.offline-note code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--cream-deep);
  padding: .1rem .4rem;
  border-radius: 5px;
  color: var(--ink);
}

/* ==========================================================================
   Admin panel
   ========================================================================== */

.admin { max-width: 760px; margin-inline: auto; padding-bottom: 3rem; }

.admin-card {
  padding: 1.3rem 1.35rem 1.5rem;
  border-radius: var(--radius);
  background: var(--paper);
  border: 1px solid rgba(192, 138, 30, .22);
  box-shadow: var(--shadow-md);
  margin-bottom: 1.1rem;
}
.admin-card > h2 {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  font-size: 1.15rem;
  margin-bottom: .3rem;
}
.admin-card > h2 .mal { font-size: .92rem; color: var(--green); }
.admin-card__hint {
  margin: 0 0 1.1rem;
  font-size: .88rem;
  color: var(--muted);
}

.field { display: grid; gap: .3rem; margin-bottom: .85rem; }
.field label {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}
.field input[type="text"],
.field input[type="password"],
.field input[type="datetime-local"],
.field textarea,
.field select {
  width: 100%;
  padding: .62rem .8rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--cream);
  box-shadow: inset 0 0 0 2px rgba(192, 138, 30, .28);
  font: inherit;
  color: var(--ink);
  min-height: 46px;
}
.field textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  background: var(--paper);
  box-shadow: inset 0 0 0 2px var(--green);
}

.field--check {
  display: flex;
  align-items: center;
  gap: .6rem;
}
.field--check input { width: 22px; height: 22px; accent-color: var(--green); }
.field--check label {
  font-size: .95rem;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
  font-weight: 600;
}

.field-row { display: grid; gap: .85rem; }
@media (min-width: 620px) { .field-row { grid-template-columns: 1fr 1fr; } }

.admin-actions {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
  margin-top: .4rem;
}

.flash {
  min-height: 1.2rem;
  font-size: .88rem;
  font-weight: 600;
  color: var(--green);
}
.flash.is-bad { color: var(--chethi); }

.admin-stats {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.recent { max-height: 380px; overflow-y: auto; }
.recent .board td { padding: .55rem .7rem; }
.recent .col-game { font-size: .84rem; color: var(--muted); white-space: nowrap; }

.icon-btn {
  border: 0;
  padding: .3rem .6rem;
  border-radius: 999px;
  background: transparent;
  color: var(--chethi);
  font: inherit;
  font-size: .8rem;
  font-weight: 700;
  cursor: pointer;
}
.icon-btn:hover { background: #FBE3E1; }

.danger-row {
  display: flex;
  gap: .5rem;
  align-items: flex-end;
  flex-wrap: wrap;
  padding-top: 1rem;
  margin-top: 1rem;
  border-top: 1px solid var(--line);
}
.danger-row .field { flex: 1 1 220px; margin-bottom: 0; }

.login-card { max-width: 380px; margin: 2rem auto; }

/* ==========================================================================
   The pookalam wall
   ========================================================================== */

.wall {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.wall:empty { display: none; }

.wall__item {
  padding: .5rem .5rem .2rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform .16s ease, box-shadow .16s ease;
}
.wall__item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* A button, for the keyboard and the tab order, stripped back to being the
   picture it wraps. */
.wall__frame {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  border-radius: 50%;
  cursor: zoom-in;
  transition: transform .16s ease;
}
.wall__frame:hover { transform: scale(1.02); }
.wall__frame:focus-visible {
  outline: 3px solid var(--green);
  outline-offset: 3px;
}

.wall__frame svg {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 50%;
}

.wall__caption {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: .5rem;
  margin: .5rem .25rem .3rem;
  font-size: .84rem;
}
.wall__who {
  font-weight: 700;
  /* Names are typed by whoever laid it, so a long one is trimmed rather than
     allowed to push the date off the card. */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wall__when {
  flex: none;
  color: var(--muted);
}

.wall__cta {
  margin: 1.75rem 0 0;
  text-align: center;
}

/* Smaller on the admin page, where they are there to be moderated rather than
   admired, and each one carries its own Take it down button. */
.wall--admin {
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  margin-bottom: .75rem;
}
.wall--admin .wall__item { text-align: center; }
.wall--admin .icon-btn { margin: 0 0 .35rem; }

/* --- one pookalam, as big as the screen allows ---------------------------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  padding: 1.25rem;
  overflow: auto;
  background: rgba(29, 21, 12, .82);
  backdrop-filter: blur(4px);
  cursor: zoom-out;
}
.lightbox[hidden] { display: none; }

/* Auto margins centre it but still let a tall screen scroll, which flex
   centring alone would clip. */
.lightbox__inner {
  position: relative;
  margin: auto;
  cursor: default;
}

.lightbox__art {
  /* Square, and never taller than the room left once the caption is in. */
  width: min(88vw, 78vh, 640px);
}
.lightbox__art svg {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 50%;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .45);
}

.lightbox__caption {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: .7rem;
  margin: 1rem 0 0;
  color: var(--cream);
  font-size: 1rem;
}
.lightbox__caption .wall__who { font-size: 1.15rem; }
.lightbox__caption .wall__when { color: rgba(251, 243, 226, .68); }

.lightbox__close {
  position: absolute;
  top: -.6rem;
  right: -.6rem;
  z-index: 1;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--cream);
  box-shadow: var(--shadow-md);
  color: var(--ink);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}
.lightbox__close:hover { background: var(--paper); }
.lightbox__close:focus-visible {
  outline: 3px solid var(--gold-light);
  outline-offset: 2px;
}

/* The wall behind should not scroll while one is being looked at. */
body.is-viewing { overflow: hidden; }
