/* Visual style follows served.bracket.tennis (bracket.tennis repo, `.served` theme). */

@font-face {
  font-family: "Magical Night";
  src: url("assets/fonts/MagicalNight-Regular.woff2") format("woff2");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  --served-primary: #327146;
  --served-secondary: #6a726d;
  --served-faded: #9bbfa8;
  --served-accent: #ebb93f;
  --served-accent-light: #f7da94;
  --served-cream: #f5eee4;
  --served-cream-dark: #d1cdc7;
  --card: #ffffff;
  --text: #000000;
  --text-strong: #020617;
  --muted: #525252;

  --font-display: "Magical Night", serif;
  --font-sans: "obviously-narrow", "IBM Plex Sans Condensed", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--served-cream);
}

body {
  margin: 0;
  background-color: var(--served-cream);
  background-image: linear-gradient(90deg, var(--served-cream) 20%, rgba(245, 238, 228, 0) 100%),
    linear-gradient(0deg, var(--served-cream) 80%, rgba(245, 238, 228, 0) 100%), url("assets/wipe.webp");
  background-size: auto, auto, 100% auto;
  background-position: 0 0, 0 0, top center;
  background-repeat: no-repeat;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.45;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
}

/* ---------- page ---------- */

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 48px 24px;
}

@media (max-width: 640px) {
  .page {
    padding: 40px 16px 32px;
  }
}

.hero {
  grid-area: hero;
  max-width: 560px;
}

.hero h1 {
  margin: 0 0 16px;
  font-family: var(--font-display);
  font-weight: normal;
  font-size: 56px;
  line-height: 1;
  color: var(--served-primary);
  text-shadow: 2px 2px 0 var(--served-accent);
}

@media (max-width: 640px) {
  .hero h1 {
    font-size: 44px;
  }
}

.lede {
  margin: 0;
  font-size: 18px;
  line-height: 30px;
}

/* Desktop: title then matches on the left, top 10 pinned on the right.
   Phone: title, then tabs that switch between the matches and the top 10. */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 13fr) minmax(0, 11fr);
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "hero picks"
    "catalog picks";
  gap: 32px 48px;
}

.view-tabs {
  display: none;
}

.catalog {
  grid-area: catalog;
}

.picks {
  grid-area: picks;
  align-self: start;
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  /* Room inside the scroll box so focus rings and card edges aren't clipped. */
  margin: -6px;
  padding: 6px;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    grid-template-areas: "hero" "tabs" "view";
    gap: 20px;
  }

  /* Only one of these shows at a time, so they share a row. */
  .picks,
  .catalog {
    grid-area: view;
  }

  .picks {
    position: static;
    max-height: none;
    overflow: visible;
    margin: 0;
    padding: 0;
  }

  .view-tabs {
    grid-area: tabs;
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    gap: 4px;
    margin: 0 -16px;
    padding: 8px 16px;
    background: var(--served-cream);
    border-bottom: 1px solid var(--served-cream-dark);
  }

  .view-tabs button {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 8px 6px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    font-family: var(--font-display);
    font-size: 24px;
    line-height: 1;
    color: var(--served-primary);
    opacity: 0.5;
    cursor: pointer;
  }

  .view-tabs button[aria-selected="true"] {
    background: var(--card);
    opacity: 1;
    box-shadow: 0 0 0 1px var(--served-cream-dark);
  }

  .tab-count {
    min-width: 22px;
    padding: 3px 6px 1px;
    border-radius: 999px;
    background: var(--served-accent);
    color: #000;
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 700;
    line-height: 1.2;
  }

  body:not([data-tab="picks"]) .picks,
  body[data-tab="picks"] .catalog {
    display: none;
  }

  /* The tab already says "My top 10". */
  .picks .display {
    display: none;
  }

  .picks .section-head {
    justify-content: flex-end;
  }
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.head-tools {
  display: flex;
  align-items: baseline;
  gap: 16px;
}

.head-tools .link-btn {
  font-size: 16px;
}

.display {
  margin: 0;
  font-family: var(--font-display);
  font-weight: normal;
  font-size: 36px;
  line-height: 1.1;
  color: var(--served-primary);
}

.count {
  font-size: 18px;
  color: var(--served-secondary);
  font-variant-numeric: tabular-nums;
}

/* ---------- cards & rows ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--served-cream-dark);
  border-radius: 4px;
}

.pick-list,
.match-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Rows have their own fill, so round the outer ones to match the card. */
.pick-list > li:first-child,
.match-list > li:first-child {
  border-top-left-radius: 3px;
  border-top-right-radius: 3px;
}

.pick-list > li:last-child,
.match-list > li:last-child {
  border-bottom-left-radius: 3px;
  border-bottom-right-radius: 3px;
}

.pick-list > li + li,
.match-list > li + li {
  border-top: 1px solid var(--served-cream-dark);
}

.pick {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 8px 4px;
  background: var(--card);
  cursor: grab;
  transition: margin 0.18s ease;
}

.grip {
  flex: none;
  display: grid;
  place-items: center;
  width: 20px;
  height: 36px;
  margin-right: -6px;
  color: var(--served-cream-dark);
  touch-action: none;
}

.grip svg {
  fill: currentColor;
}

.pick:hover .grip {
  color: var(--served-secondary);
}

/* The row left behind while its copy is being dragged. */
.pick.drag-source {
  background: var(--served-cream);
}

.pick.drag-source > * {
  opacity: 0.25;
}

/* The floating copy that follows the pointer. */
.drag-clone {
  position: fixed;
  z-index: 1000;
  margin: 0;
  list-style: none;
  border-radius: 6px;
  box-shadow: 0 0 0 1px var(--served-cream-dark), 0 16px 32px rgba(0, 0, 0, 0.18), 0 3px 8px rgba(0, 0, 0, 0.08);
  transform: scale(1.02);
  pointer-events: none;
  cursor: grabbing;
}

body.is-dragging,
body.is-dragging * {
  cursor: grabbing !important;
  user-select: none;
}

/* Drop marker: the gap between two rows opens up and lights up. */
.pick.gap-before {
  margin-top: 16px;
}

.pick.gap-after {
  margin-bottom: 16px;
}

/* Drawn above the floating copy so it stays visible under the pointer. */
.drop-line {
  position: fixed;
  z-index: 1001;
  height: 4px;
  margin-top: -2px;
  border-radius: 2px;
  background: var(--served-accent);
  box-shadow: 0 0 0 3px rgba(235, 185, 63, 0.3);
  pointer-events: none;
  animation: drop-line 0.18s ease-out;
}

@keyframes drop-line {
  from {
    opacity: 0;
    transform: scaleX(0.6);
  }
}

@media (prefers-reduced-motion: reduce) {
  .pick {
    transition: none;
  }

  .drop-line {
    animation: none;
  }
}

.rank {
  flex: none;
  width: 28px;
  text-align: center;
  font-family: var(--font-display);
  font-size: 24px;
  line-height: 1;
  padding-top: 4px;
  color: var(--served-primary);
  text-shadow: 1px 1px 0 var(--served-accent);
}

.pick-body,
.match-body {
  flex: 1;
  min-width: 0;
}

.title {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--text-strong);
  overflow-wrap: anywhere;
}

.score {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 10px;
}

.score-text,
.score .highlights {
  white-space: nowrap;
}

/* A fixed offset and thickness, with no gaps cut for descenders, so the
   underline looks the same on every row whatever its pixel rounding. */
.score .highlights {
  color: var(--served-primary);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-skip-ink: none;
}

/* Sized to the cap height and sitting on the baseline, level with the "H". */
.highlights svg {
  height: 0.7em;
  width: 1em;
  margin-right: 5px;
  vertical-align: baseline;
  fill: currentColor;
}

/* A base letter with a Latin-1 accent laid over it (see nameHtml in app.js). */
.dia {
  position: relative;
  display: inline-block;
}

.dia::after {
  content: attr(data-mark);
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  text-align: center;
  pointer-events: none;
}

.dia.acute.cap::after {
  top: -0.2em;
}

/* A mirrored cedilla stands in for the ogonek. */
.dia.ogonek::after {
  top: 0.04em;
  left: 0.32em;
  transform: scaleX(-1);
}

.meta {
  color: var(--served-secondary);
  font-size: 15px;
}

.score {
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

/* Players, then event · round right beside them, score underneath. */
.row-top {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0 10px;
}

/* On narrow rows the event drops under the players rather than squeezing them. */
.row-top .meta {
  flex: none;
  white-space: nowrap;
}

.pick .title {
  font-size: 16px;
}

.pick .score {
  font-size: 14px;
  line-height: 1.3;
  color: var(--muted);
}

.pick .meta {
  font-size: 13px;
}

.pick-controls {
  flex: none;
  display: flex;
}

.icon-btn {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--served-secondary);
  cursor: pointer;
  font-size: 16px;
}

.icon-btn:hover:not(:disabled) {
  background: var(--served-cream);
  color: var(--served-primary);
}

.icon-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.empty {
  margin: 0;
  padding: 16px 12px;
  color: var(--served-secondary);
}

.match {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 12px 12px 12px 16px;
}

.match.picked {
  background: color-mix(in srgb, var(--served-accent-light) 35%, white);
}

.match .score {
  margin-top: 2px;
}

.note {
  margin: 4px 0 0;
  font-size: 15px;
  line-height: 1.35;
  color: var(--muted);
}

/* ---------- buttons ---------- */

.btn {
  display: inline-block;
  border-radius: 8px;
  font-family: var(--font-display);
  font-weight: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: 0.02em;
  padding: 14px 20px 10px;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.btn-primary {
  border: 0;
  background: var(--served-primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--served-accent);
}

.btn-outline {
  border: 2px solid var(--served-primary);
  background: transparent;
  color: var(--served-primary);
  font-size: 20px;
  padding: 11px 16px 8px;
}

.btn-outline:hover:not(:disabled) {
  background: var(--served-primary);
  color: #fff;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button.add {
  flex: none;
  min-width: 64px;
  font-size: 18px;
  padding: 9px 12px 6px;
}

button.add.ranked {
  border-color: var(--served-accent);
  background: var(--served-accent);
  color: #000;
}

button.add.ranked:hover {
  background: var(--served-accent-light);
  border-color: var(--served-accent-light);
}

.link-btn {
  border: 0;
  background: none;
  padding: 0;
  font-size: 17px;
  font-weight: 500;
  color: var(--text-strong);
  text-decoration: underline;
  cursor: pointer;
}

.link-btn:hover {
  color: var(--served-primary);
  text-decoration: none;
}

.link-btn.muted {
  color: var(--muted);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid var(--served-primary);
  outline-offset: 2px;
}

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

.field input,
.field select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--served-cream-dark);
  border-radius: 6px;
  background: var(--card);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
  color: var(--served-secondary);
}

.field input,
.field select {
  font-size: 16px;
  color: var(--text);
}

.submit-form {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-top: 16px;
}

/* Same height as the email box beside it. */
.submit-form .field input,
.submit-form .btn {
  height: 46px;
}

.submit-form .btn {
  padding: 4px 22px 0;
}

.submit-form .field {
  flex: 1;
  min-width: 0;
}

.toast {
  margin: 12px 0 0;
  font-weight: 600;
  color: var(--served-primary);
}

.toast:empty {
  display: none;
}

.toast.error {
  color: #b42318;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-top: 16px;
}

/* ---------- shared-list banner ---------- */

.banner {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: center;
  margin-bottom: 32px;
  padding: 14px 16px;
  background: var(--served-accent-light);
  border-radius: 8px;
}

.banner span {
  flex: 1 1 220px;
  font-size: 18px;
  font-weight: 600;
}

.banner .btn {
  font-size: 20px;
  padding: 11px 16px 8px;
}

