/* North Field — club pickleball ladder.
   Daytime outdoor court: bright sky blue, the optic-yellow ball, coral and
   mint for match state. Bright by default for everyone; night mode is an
   opt-in for evening play, never something the OS decides for you. */

:root {
  --sky:       #1fa2e0;
  --sky-deep:  #0c7db5;
  --sky-wash:  #dff1fb;
  --ball:      #e9f13b;
  --ball-ink:  #4a4e08;
  --coral:     #ff6f5e;
  --mint:      #23bd86;

  --ground:   #eaf6fb;
  --surface:  #ffffff;
  --sunken:   #f3fafd;
  --line:     #d3e8f2;
  --ink:      #123b4d;
  --ink-soft: #3f6b7d;
  --ink-mute: #7196a6;

  --on-sky:       #ffffff;
  --masthead-bg:  #1fa2e0;
  --masthead-ink: #ffffff;
  --net-tape:     #ffffff;
  --net-mesh:     rgba(255, 255, 255, .55);

  --radius:    14px;
  --radius-sm: 9px;
  --shadow:    0 1px 2px rgba(18, 59, 77, .05), 0 10px 26px -14px rgba(18, 59, 77, .26);

  --step--1: .82rem;
  --step-0:  1rem;
  --step-1:  1.2rem;
  --step-2:  1.75rem;

  --sans: "Nunito Sans", ui-sans-serif, system-ui, "Helvetica Neue", sans-serif;
  --display: "Fredoka", "Nunito Sans", ui-rounded, system-ui, sans-serif;
}

/* Night mode — floodlit evening blue, never near-black. Opt-in only, so this
   is the one place the palette is redefined and no media query fights it. */
:root[data-theme="night"] {
  --sky:       #4fc3f7;
  --sky-deep:  #8ad8fb;
  --sky-wash:  #1e4559;
  --ball:      #e9f13b;
  --ball-ink:  #2f330a;
  --coral:     #ff8877;
  --mint:      #45d6a2;

  --ground:   #10293a;
  --surface:  #17374b;
  --sunken:   #1e4559;
  --line:     #2d5b74;
  --ink:      #eaf6fb;
  --ink-soft: #b4d2e0;
  --ink-mute: #8fb3c4;

  --on-sky:       #06283a;
  --masthead-bg:  #0e2434;
  --masthead-ink: #eaf6fb;
  --net-tape:     #d8f0fb;
  --net-mesh:     rgba(143, 216, 251, .4);

  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 26px -14px rgba(0, 0, 0, .55);
}

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

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--step-0);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.shell { width: min(1180px, 100% - 3rem); margin-inline: auto; }

/* ---------- masthead ---------- */

.masthead { background: var(--masthead-bg); color: var(--masthead-ink); }

.masthead-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 1.5rem 1.2rem;
}

.brand { display: flex; align-items: center; gap: .8rem; }
.brand-icon { width: clamp(44px, 5vw, 56px); height: auto; flex: none; }

.wordmark { display: flex; flex-direction: column; gap: .15rem; }

.wordmark-club {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(2rem, 4.6vw, 2.9rem);
  line-height: 1;
  letter-spacing: -.01em;
}

.wordmark-sub {
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  opacity: .82;
}

.masthead-tools { display: flex; align-items: flex-end; gap: .8rem; }

/* the net: white tape over mesh */
.net {
  height: 12px;
  background:
    linear-gradient(var(--net-tape) 0 4px, transparent 4px 100%),
    repeating-linear-gradient(90deg, var(--net-mesh) 0 1px, transparent 1px 7px) 0 4px / 100% 8px no-repeat,
    var(--sky);
}

/* ---------- layout ---------- */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 20.5rem) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
  padding-block: 1.8rem 4rem;
}

@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .shell { width: min(1180px, 100% - 1.6rem); }
}

.rail, .feed-col { display: grid; gap: 1.5rem; align-content: start; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.2rem 1.25rem 1.35rem;
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: .5rem;
  padding-bottom: .8rem;
  margin-bottom: 1rem;
  border-bottom: 2px solid var(--sky-wash);
}

.panel-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: var(--step-1);
  font-weight: 600;
  letter-spacing: -.005em;
}

.panel-note { font-size: var(--step--1); color: var(--ink-mute); max-width: 34ch; }

.empty { color: var(--ink-mute); font-size: var(--step--1); margin: .2rem 0 0; }

/* ---------- ladder ---------- */

.ladder { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; }

.rung {
  display: grid;
  grid-template-columns: 2.3rem minmax(0, 1fr) auto;
  align-items: center;
  gap: .75rem;
  padding: .55rem .5rem;
  border-radius: var(--radius-sm);
}

.rung:nth-child(odd) { background: var(--sunken); }

/* Top three get a badge — the podium is real standings information */
.rung-rank {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.15rem;
  line-height: 2.3rem;
  height: 2.3rem;
  text-align: center;
  border-radius: 50%;
  color: var(--ink-mute);
  font-variant-numeric: tabular-nums;
}

.rung:nth-child(1) .rung-rank { background: var(--ball); color: var(--ball-ink); }
.rung:nth-child(2) .rung-rank,
.rung:nth-child(3) .rung-rank { background: var(--sky-wash); color: var(--sky-deep); }

.rung-id { display: flex; flex-direction: column; min-width: 0; gap: .1rem; }

.rung-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.rung-meta {
  font-size: var(--step--1);
  color: var(--ink-mute);
  display: flex;
  flex-wrap: wrap;
  gap: .25rem .4rem;
  align-items: center;
}

.rung-meta .nowrap { white-space: nowrap; }

.rung-num { display: grid; justify-items: end; gap: .1rem; }

.rung-rating {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.35rem;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.spark { display: block; width: 58px; height: 20px; overflow: hidden; }

.tag {
  font-size: .7rem;
  font-weight: 700;
  padding: .08rem .45rem;
  border-radius: 999px;
}

.tag-prov { background: var(--sky-wash); color: var(--sky-deep); }
.tag-pending { background: var(--coral); color: #fff; }

/* ---------- forms ---------- */

.stack { display: grid; gap: .85rem; }
.row { display: flex; flex-wrap: wrap; gap: .85rem; align-items: flex-end; }
.row .field { flex: 1 1 8rem; }

.field { display: grid; gap: .3rem; min-width: 0; }

.field-label {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-mute);
}

.masthead .field-label { color: inherit; opacity: .85; }

input, select {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: .5rem .65rem;
  min-width: 0;
  width: 100%;
}

input::placeholder { color: var(--ink-mute); }

input:hover, select:hover { border-color: var(--sky); }

:focus-visible { outline: 3px solid var(--sky-deep); outline-offset: 2px; }

.btn {
  font: inherit;
  font-family: var(--display);
  font-weight: 600;
  border: none;
  background: var(--sky);
  color: var(--on-sky);
  padding: .5rem 1.25rem;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .12s ease, background .12s ease;
}

.btn:hover { background: var(--sky-deep); transform: translateY(-1px); }
.btn:active { transform: none; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.btn-quiet { background: var(--sky-wash); color: var(--sky-deep); }
.btn-quiet:hover { background: var(--sky-wash); color: var(--ink); transform: translateY(-1px); }

.btn-sm { padding: .35rem .9rem; font-size: var(--step--1); }

.ghost-btn {
  font: inherit;
  font-size: var(--step--1);
  font-weight: 700;
  color: inherit;
  background: rgba(255, 255, 255, .16);
  border: 1.5px solid rgba(255, 255, 255, .5);
  border-radius: 999px;
  padding: .42rem .9rem;
  cursor: pointer;
  white-space: nowrap;
}

.ghost-btn:hover { background: rgba(255, 255, 255, .28); }

/* ---------- auth ---------- */

.auth-widget { position: relative; display: flex; align-items: flex-end; }

.auth-slot { display: flex; align-items: center; gap: .6rem; }

.auth-name { font-weight: 700; font-size: var(--step--1); white-space: nowrap; }

.auth-panel:not([hidden]) { margin-top: -.4rem; margin-bottom: 1rem; }

/* .panel is normally used on the (dark-text) body background; inside the
   masthead it would otherwise inherit the masthead's white text onto its
   own white surface, so pin its colours back explicitly. */
.auth-panel { color: var(--ink); }
.auth-panel .panel-head { border-bottom-color: var(--sky-wash); }
.auth-panel .field-label { color: var(--ink-mute); opacity: 1; }

/* ---------- availability ---------- */

.avail-grid { display: grid; gap: .5rem; }

.avail-row {
  display: grid;
  grid-template-columns: 4.4rem 1fr 1fr;
  gap: .4rem;
  align-items: center;
}

.avail-day {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: var(--step--1);
  font-weight: 700;
  color: var(--ink-soft);
}

.avail-day input { width: auto; }

.avail-start[disabled], .avail-end[disabled] { opacity: .45; }

/* ---------- who's free ---------- */

.whosfree { margin-top: 1rem; padding-top: .95rem; border-top: 1.5px solid var(--line); }

.whosfree-list { list-style: none; margin: .7rem 0 0; padding: 0; display: grid; gap: .3rem; }

.whosfree-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: .4rem .8rem;
  padding: .35rem .1rem;
  border-bottom: 1px solid var(--line);
}

.whosfree-row:last-child { border-bottom: none; }

/* ---------- invite landing ---------- */

.invite-panel { border-left: 5px solid var(--mint); }

/* ---------- match creation ---------- */

.sides { display: grid; grid-template-columns: 1fr auto 1fr; gap: .85rem; align-items: center; }

@media (max-width: 620px) {
  .sides { grid-template-columns: minmax(0, 1fr); }
  .versus { justify-self: start; }
}

.side {
  display: grid;
  gap: .45rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: .3rem .65rem .75rem;
  margin: 0;
  min-width: 0;
}

.side legend {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-mute);
  padding-inline: .3rem;
}

.versus {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--sky);
}

.doubles-only[hidden] { display: none; }

/* ---------- match feed ---------- */

.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: .9rem; }

.match {
  border: 1.5px solid var(--line);
  border-left: 5px solid var(--ink-mute);
  border-radius: var(--radius-sm);
  padding: .85rem 1rem .95rem;
  display: grid;
  gap: .75rem;
  background: var(--surface);
}

.match[data-status="scheduled"]      { border-left-color: var(--ball); }
.match[data-status="awaiting_score"] { border-left-color: var(--ball); }
.match[data-status="scored"]         { border-left-color: var(--sky); }
.match[data-status="confirmed"]      { border-left-color: var(--mint); }
.match[data-status="disputed"]       { border-left-color: var(--coral); }

.match-top { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .5rem; }

.match-id { font-size: var(--step--1); color: var(--ink-mute); font-weight: 600; }

.match-pills { display: flex; flex-wrap: wrap; gap: .4rem; }

.status {
  font-size: .72rem;
  font-weight: 700;
  padding: .16rem .6rem;
  border-radius: 999px;
  background: var(--sky-wash);
  color: var(--sky-deep);
}

.status-awaiting_score { background: var(--ball); color: var(--ball-ink); }
.status-confirmed { background: var(--mint); color: #fff; }
.status-disputed { background: var(--coral); color: #fff; }
.status-open-slots { background: var(--ball); color: var(--ball-ink); }

.card-sides { display: grid; grid-template-columns: 1fr auto 1fr; gap: .7rem; align-items: center; }

.card-side { display: grid; gap: .1rem; min-width: 0; }
.card-side.b { text-align: right; }
.card-side .who { font-weight: 700; }
.card-side .who-sub { font-size: var(--step--1); color: var(--ink-mute); }

.scoreline {
  font-family: var(--display);
  font-weight: 600;
  font-size: var(--step-2);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--ink-mute);
}

.scoreline .pending { color: var(--sky); font-size: var(--step-1); }
.scoreline .won { color: var(--sky-deep); }

.games { display: flex; flex-wrap: wrap; gap: .4rem; font-size: var(--step--1); }

.game-chip {
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .08rem .55rem;
  font-weight: 700;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.match-actions { display: flex; flex-wrap: wrap; gap: .55rem; align-items: flex-end; }

.game-inputs { display: flex; flex-wrap: wrap; gap: .45rem; align-items: flex-end; }
.game-inputs .field { width: 4.3rem; }
.game-inputs input { text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- toasts ---------- */

.toast-dock {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  display: grid;
  gap: .5rem;
  z-index: 10;
  max-width: min(26rem, calc(100% - 2rem));
}

.toast {
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-left: 5px solid var(--mint);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: .6rem .85rem;
  font-size: var(--step--1);
  font-weight: 600;
  animation: rise .2s ease-out;
}

.toast-bad { border-left-color: var(--coral); }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* club admin lists */
.admin-list { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .5rem; }
.admin-list li { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; }
.admin-list select { max-width: 9rem; }

/* open play list */
.ev-list > li { flex-direction: column; align-items: stretch; padding-bottom: .5rem; border-bottom: 1px solid var(--line, rgba(128,128,128,.25)); }
.ev-list > li > div, .ev-list > li > span { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; }
.ev-list small { display: block; opacity: .75; }
.ev-mine { font-weight: 600; opacity: 1; }
.ev-roster { margin-top: .5rem; }

/* floor */
.floor-courts li { display: grid; grid-template-columns: 5.5rem 1fr auto; align-items: center; gap: .5rem; }
.floor-court { font-weight: 600; }
.floor-score input { width: 3.5rem; }
.floor-table { width: 100%; border-collapse: collapse; }
.floor-table th, .floor-table td { text-align: left; padding: .25rem .5rem; }
@media (max-width: 560px) { .floor-courts li { grid-template-columns: 1fr; } }

/* profile + attendance */
.rung[data-membership] { cursor: pointer; }
.rung[data-membership]:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
.prof-ratings { gap: 1rem; }
.prof-rating { display: grid; }
.prof-rating strong { font-size: 1.6rem; }
.prof-up { color: #1f7a3d; }
.prof-down { color: #b3261e; }
.ev-flag { color: #b3261e; opacity: 1; display: inline; }

.reset-code { display: grid; gap: .35rem; padding: .75rem 1rem; margin: 0 0 .75rem; border: 1px dashed currentColor; border-radius: .5rem; }
.reset-code code { font-size: 1.25rem; letter-spacing: .15em; user-select: all; }

/* ---------- landing and home ---------- */
.landing-hero {
  background: linear-gradient(90deg, rgba(12, 59, 77, .88) 0%, rgba(12, 59, 77, .55) 55%, rgba(12, 59, 77, .15) 100%), url('/img/hero.jpg') center 62% / cover;
  color: #fff;
  padding: clamp(2.5rem, 9vw, 6rem) 0;
}
.landing-hero-inner { max-width: 1180px; }
.landing-hero h1 { font-family: var(--display); font-weight: 600; font-size: clamp(2rem, 6vw, 3.4rem); line-height: 1.1; margin: 0 0 1rem; max-width: 16ch; }
.landing-hero p { max-width: 46ch; font-size: 1.1rem; margin: 0 0 1.5rem; }
.landing-cta { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.landing-look { color: #fff; text-decoration: underline; padding: .4rem .25rem; }
.landing-body { padding: 1.5rem 0 .5rem; }
.landing-cards { list-style: none; margin: 0 0 1.5rem; padding: 0; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.landing-cards li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem; }
.landing-cards h3 { margin: 0 0 .35rem; font-family: var(--display); }
.landing-cards p { margin: 0; color: var(--ink-soft); }
.landing-steps { margin: 0 0 1rem; padding-left: 1.2rem; display: grid; gap: .5rem; }
.landing-steps strong { display: block; }
.landing-steps span { color: var(--ink-soft); }
.landing-foot { color: var(--ink-mute); font-size: var(--step--1); }
.home-panel h3 { margin: 0 0 .4rem; font-size: 1rem; color: var(--ink-soft); }
.home-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 1rem; }
.home-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.home-list small { display: block; color: var(--ink-mute); }
.home-actions { gap: .5rem; flex-wrap: wrap; }
@media (max-width: 600px) { .landing-hero { background-position: 70% 62%; } }

/* ---------- print: bulletin-board poster and weekly sheet ---------- */
#print-area { display: none; }
@media print {
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block; }
  body { background: #fff; color: #000; }
  .sheet { font-family: 'Nunito Sans', system-ui, sans-serif; color: #000; }
  .poster { text-align: center; padding-top: 2cm; }
  .poster h1 { font-size: 48pt; margin: 0 0 .2em; }
  .poster-lead { font-size: 18pt; margin: 0 0 1cm; }
  .poster-qr svg { width: 12cm; height: 12cm; }
  .poster-cta { font-size: 36pt; font-weight: 700; margin: .6cm 0 .1cm; }
  .poster-url { font-size: 16pt; }
  .weekly h1 { font-size: 24pt; margin: 0 0 .4cm; }
  .weekly h1 small { font-size: 12pt; font-weight: 400; margin-left: .5em; }
  .weekly h2 { font-size: 14pt; margin: .5cm 0 .2cm; border-bottom: 1px solid #000; }
  .weekly ul, .weekly ol { margin: 0; padding-left: 1.2em; font-size: 11pt; line-height: 1.4; }
  .weekly ol li span { float: right; }
  .sheet-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1cm; }
  .sheet-foot { margin-top: 1cm; font-size: 10pt; }
  @page { margin: 1.5cm; }
}
