/*
 * Neobrutalist theme for the Padel Championship app.
 *
 * This stylesheet embraces the bold, utilitarian aesthetic of
 * neobrutalism: strong outlines, flat backgrounds and a limited
 * colour palette.  The primary accent colour is the Top Employers
 * red (#e02b19).  Forms, tables and cards are framed with heavy
 * black borders and subtle shadows to evoke a tactile, printed
 * feel.  Typography is large and confident, using default sans‑serif
 * fonts to maximise compatibility across platforms.
 */

/* Base document styles */
body {
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    "Helvetica Neue",
    Arial,
    "Noto Sans",
    sans-serif;
  margin: 0;
  padding: 0;
  background-color: #fdf2f2; /* light red tint for subtle warmth */
  color: #0a0a0a;
}

header,
footer {
  background-color: #e02b19; /* Top Employers red */
  color: #ffffff;
  text-align: center;
  padding: 1rem;
  border-bottom: 4px solid #0a0a0a;
}

footer {
  border-top: 4px solid #0a0a0a;
  border-bottom: none;
}

main {
  max-width: 900px;
  margin: 2rem auto;
  padding: 1.5rem;
  background-color: #ffffff;
  border: 4px solid #0a0a0a;
  border-radius: 1rem;
  box-shadow: 8px 8px 0px #0a0a0a;
}

h1,
h2,
h3 {
  margin-top: 0;
  font-weight: 800;
  color: #545454;
}

/* Links */
a {
  color: #e02b19;
  text-decoration: underline;
  font-weight: 600;
}
a:hover {
  text-decoration: none;
}

/* Links inside the red header/footer must be light to stay visible. */
header a,
footer a {
  color: #ffffff;
}

/* Header layout: 960px-wide wrapper, vertically centred content */
.header-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  padding: 0.5rem 0;
}
header h1 {
  max-width: 1200px;
  margin: 0.85rem auto 0;
  text-align: center;
  color: #ffffff;
  font-size: 1.5rem;
}

/* Brand: TEI compass logo + wordmark */
.brand {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.brand a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: #ffffff;
}
.brand-logo {
  display: block;
  width: 2.75rem;
  height: 2.75rem;
  border: 3px solid #0a0a0a;
  border-radius: 0.6rem;
  box-shadow: 3px 3px 0px #0a0a0a;
}

/* Persistent nav — neobrutalist menu items: rounded, with a thicker
 * right + bottom border that reads as a hard offset shadow. */
.mainnav {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}
.mainnav a {
  font-weight: 700;
  text-decoration: none;
  color: #0a0a0a;
  background-color: #ffffff;
  padding: 0.45rem 0.95rem;
  border: 2px solid #0a0a0a;
  border-right-width: 5px;
  border-bottom-width: 5px;
  border-radius: 0.6rem;
  transition: transform 0.05s ease-in-out;
}
.mainnav a:hover {
  background-color: #fdf2f2;
  transform: translate(-1px, -1px);
}
.mainnav a:active {
  transform: translate(0, 0);
}

/* Home landing cards */
.home-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1.25rem;
}
.home-card {
  flex: 1 1 200px;
  min-width: 200px;
  text-decoration: none;
  color: #0a0a0a;
  background-color: #ffffff;
  border: 3px solid #0a0a0a;
  border-radius: 0.75rem;
  padding: 1rem;
  box-shadow: 4px 4px 0px #0a0a0a;
  transition: transform 0.05s ease-in-out;
}
.home-card:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0px #0a0a0a;
}
.home-card h3 {
  margin: 0 0 0.35rem 0;
}
.home-card p {
  margin: 0;
}

/* Player autocomplete-add row on the shuffler */
.player-add {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}
.player-add input {
  flex: 1;
}
.player-add button {
  align-self: stretch;
}

/* Home dashboard: slider + leaders */
.home-top {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 2rem;
  align-items: stretch;
}
.slider {
  position: relative;
  flex: 1 1 50%;
  min-height: 45vh;
  border: 3px solid #0a0a0a;
  border-radius: 0.75rem;
  box-shadow: 4px 4px 0px #0a0a0a;
  overflow: hidden;
  background-color: #fdf2f2;
}
.slide {
  position: absolute;
  inset: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transition: opacity 0.6s ease-in-out;
}
.slide.active {
  opacity: 1;
}
.slide-photo {
  display: block;
  flex: 1;
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
}
.slide a {
  display: flex;
  flex: 1;
}
.slide figcaption {
  background-color: #e02b19;
  color: #ffffff;
  font-weight: 800;
  text-align: center;
  padding: 0.5rem;
  border-top: 3px solid #0a0a0a;
}
.slide-empty {
  margin: auto;
  font-weight: 700;
  color: #888;
}

.leaders {
  flex: 1 1 50%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.leader-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  background-color: #ffffff;
  border: 3px solid #0a0a0a;
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  box-shadow: 4px 4px 0px #0a0a0a;
}
.leader-label {
  font-weight: 800;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.leader-player {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  text-decoration: none;
  color: #0a0a0a;
}
.leader-name {
  font-weight: 700;
}
.leader-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: #e02b19;
}

/* Home short-rankings header + season picker */
.rankings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.season-pick {
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.season-pick select {
  padding: 0.4rem;
  border: 3px solid #0a0a0a;
  border-radius: 0.5rem;
  font-weight: 700;
  cursor: pointer;
}

@media (max-width: 400px) {
  .home-top {
    flex-direction: column;
  }
  .slider {
    min-height: 38vh;
  }
}

/* Results page action row (re-shuffle / discard / print) */
.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-top: 1rem;
}
.actions-row form {
  margin: 0;
}
button.secondary {
  background-color: #ffffff;
  color: #0a0a0a;
}
button.secondary:hover {
  background-color: #fdf2f2;
}
.btn-link {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  border: 3px solid #0a0a0a;
  border-radius: 0.5rem;
  background-color: #ffffff;
  color: #0a0a0a;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 4px 4px 0px #0a0a0a;
}

/* Print scoring sheet */
.print-match {
  width: 100%;
  border: 2px solid #0a0a0a;
  margin-bottom: 0.5rem;
  border-collapse: collapse;
}
.print-match td {
  border: 1px solid #0a0a0a;
  padding: 0.5rem;
}
.print-match .court {
  font-weight: 800;
  width: 90px;
}
.print-match .scorebox {
  width: 60px;
}
.print-match .vs {
  width: 30px;
  text-align: center;
  color: #888;
}
@media print {
  header,
  footer,
  .mainnav,
  .no-print {
    display: none !important;
  }
  body {
    background-color: #ffffff;
  }
  main {
    box-shadow: none;
    border: none;
    margin: 0;
    max-width: none;
    padding: 0;
  }
}

/* Form elements */
form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
}

label {
  font-weight: 700;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

input[type="text"],
input[type="number"],
input[type="date"],
textarea {
  padding: 0.75rem;
  font-size: 1rem;
  border: 3px solid #0a0a0a;
  border-radius: 0.5rem;
  background-color: #fefefe;
}

textarea {
  resize: vertical;
}

button {
  align-self: flex-start;
  padding: 0.75rem 1.5rem;
  background-color: #e02b19;
  color: #ffffff;
  border: 3px solid #0a0a0a;
  border-radius: 0.5rem;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 4px 4px 0px #0a0a0a;
  transition: transform 0.05s ease-in-out;
}

button:hover {
  background-color: #b62514;
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0px #0a0a0a;
}

button:active {
  transform: translate(0, 0);
  box-shadow: 4px 4px 0px #0a0a0a;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 2rem;
  border: 3px solid #0a0a0a;
}

th,
td {
  padding: 0.75rem;
  border: 1px solid #0a0a0a;
  text-align: left;
}

th {
  background-color: #e02b19;
  color: #ffffff;
  font-weight: 700;
}

tr:nth-child(even) td {
  background-color: #fdf2f2;
}

/* Ranking tables: centre the numeric columns and give the numbers a slightly
 * bigger, bolder neobrutalist weight. The Player column (2nd) stays left. */
.scoreboard th,
.scoreboard td {
  text-align: center;
}
.scoreboard th:nth-child(2),
.scoreboard td:nth-child(2) {
  text-align: left;
}
.scoreboard tbody td {
  font-size: 1.1rem;
  font-weight: 800;
}
.scoreboard tbody td:nth-child(2) {
  font-weight: 700;
}

/* Matches log: centred cells, bigger body font, bold score columns (3 & 5)
 * so the result is easy to scan without hunting. */
.matches-table th,
.matches-table td {
  text-align: center;
}
.matches-table tbody td {
  font-size: 1.05rem;
}
.matches-table tbody td:nth-child(3),
.matches-table tbody td:nth-child(5) {
  font-size: 1.2rem;
  font-weight: 800;
}

/* Head-to-head: picker control */
.h2h-control {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.5rem 0 1.25rem;
  flex-wrap: wrap;
}
.h2h-control select {
  padding: 0.45rem;
  border: 3px solid #0a0a0a;
  border-radius: 0.5rem;
  font-weight: 700;
}

/* Modal: backdrop + neobrutalist card */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(10, 10, 10, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-backdrop[hidden] {
  display: none;
}
.modal-card {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow: auto;
  background: #ffffff;
  border: 4px solid #0a0a0a;
  border-radius: 1rem;
  box-shadow: 8px 8px 0px #0a0a0a;
  padding: 1.5rem 1.25rem 1.25rem;
}
.modal-close {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  width: 2rem;
  height: 2rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  color: #0a0a0a;
  border: 2px solid #0a0a0a;
  border-right-width: 4px;
  border-bottom-width: 4px;
  border-radius: 0.5rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: none;
}
.modal-close:hover {
  background: #fdf2f2;
  transform: none;
}

/* Comparison card: two players + stat rows */
.compare-head {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.compare-player {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  text-align: center;
}
.compare-name {
  font-weight: 800;
}
.compare-vs {
  font-weight: 800;
  font-size: 1.1rem;
  color: #e02b19;
}
.compare-rows {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.compare-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.5rem;
}
.compare-row .cval {
  min-width: 3.2rem;
  padding: 0.35rem 0.5rem;
  text-align: center;
  font-size: 1.15rem;
  font-weight: 800;
  background: #fdf2f2;
  border: 2px solid #0a0a0a;
  border-right-width: 4px;
  border-bottom-width: 4px;
  border-radius: 0.5rem;
}
.compare-row .clabel {
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: #545454;
}

/* Schedule cards */
.schedule {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
}

.match {
  display: flex;
  flex-direction: column;
  padding: 1rem;
  border: 3px solid #0a0a0a;
  border-radius: 0.75rem;
  background-color: #ffffff;
  box-shadow: 4px 4px 0px #0a0a0a;
  gap: 0.75rem;
}

.match h3 {
  margin: 0;
  font-weight: 700;
  color: #0a0a0a;
}

.players {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.players span {
  flex: 1;
  text-align: center;
  font-weight: 600;
}

/* Utility classes */
.error {
  color: #e02b19;
  font-weight: 700;
}

/* Banner (e.g. schedule awaiting results) */
.banner {
  background-color: #fff3cd;
  border: 3px solid #0a0a0a;
  border-radius: 0.75rem;
  padding: 0.85rem 1rem;
  box-shadow: 4px 4px 0px #0a0a0a;
  font-weight: 600;
}

/* Score entry pair on the results page */
.score-entry {
  display: flex;
  gap: 1rem;
}
.score-entry label {
  flex: 1;
}

/* Player avatars (deterministic initials) */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 800;
  border: 3px solid #0a0a0a;
  border-radius: 50%;
  box-shadow: 2px 2px 0px #0a0a0a;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35);
  flex: none;
}
.avatar-sm {
  width: 2rem;
  height: 2rem;
  font-size: 0.75rem;
}
.avatar-lg {
  width: 7rem;
  height: 7rem;
  font-size: 1.25rem;
  box-shadow: 4px 4px 0px #0a0a0a;
}
/* Real photo instead of initials */
.avatar-photo {
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  color: transparent;
}

/* Player link cell in the scoreboard */
.player-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
}
.player-cell:hover span {
  text-decoration: underline;
}

/* Player detail hero (avatar + name) */
.player-hero {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}
.player-hero h1 {
  color: #ffffff;
  margin: 0;
}

/* Compact ELO chart */
.elo-chart-wrap {
  position: relative;
  height: 140px;
  margin-bottom: 1.5rem;
}

/* Match-day review */
.review-text {
  white-space: pre-wrap;
  word-wrap: break-word;
  background-color: #fdf2f2;
  border: 3px solid #0a0a0a;
  border-radius: 0.75rem;
  padding: 1rem;
  box-shadow: 4px 4px 0px #0a0a0a;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.5;
  margin-bottom: 1rem;
}

/* ---------------------------------------------------------------------
 * Mobile / small-screen adjustments
 * People check standings and add matches from their phones, so the
 * layout has to hold up below ~400px.
 * ------------------------------------------------------------------- */
@media (max-width: 800px) {
  .header-inner {
    flex-direction: column;
  }
}

@media (max-width: 400px) {
  main {
    margin: 1rem;
    padding: 1rem;
    border-radius: 0.75rem;
    box-shadow: 5px 5px 0px #0a0a0a;
  }

  header,
  footer {
    padding: 0.85rem;
  }
  header h1 {
    font-size: 1.4rem;
  }

  .header-inner {
    max-width: 400px;
    justify-content: center;
    align-items: center;
    flex-direction: column;
  }

  /* Tables scroll horizontally instead of overflowing the viewport. */
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
  th,
  td {
    padding: 0.55rem;
  }

  /* Stat and match cards stack full-width. */
  .stat-card,
  .match-card {
    flex: 1 1 100%;
    min-width: 0;
  }
  .stat-value {
    font-size: 1.6rem;
  }

  /* Schedule match teams stack vertically for readability. */
  .players {
    flex-direction: column;
    gap: 0.25rem;
  }

  /* Player hero shrinks but stays legible. */
  .player-hero h1 {
    font-size: 1.4rem;
  }
  .avatar-lg {
    width: 7rem;
    height: 7rem;
    font-size: 1.1rem;
  }

  /* Comfortable tap targets. */
  button {
    width: 100%;
    align-self: stretch;
    text-align: center;
  }
}

/* Stats grid for player detail page */
.stats-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  flex: 1;
  min-width: 200px;
  background-color: #ffffff;
  border: 3px solid #0a0a0a;
  border-radius: 0.75rem;
  padding: 1rem;
  box-shadow: 4px 4px 0px #0a0a0a;
}

.stat-card h3 {
  margin-top: 0;
  margin-bottom: 0.5rem;
  font-size: 1rem;
  font-weight: 700;
}

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  margin: 0;
}

.stat-delta {
  margin-top: 0.25rem;
  font-weight: 700;
  color: #e02b19; /* fallback when no direction class is present */
}
/* Trend-aware delta colours: green when gaining, red when losing. */
.stat-delta.up {
  color: #16a34a;
}
.stat-delta.down {
  color: #e02b19;
}

/* Partner and opponent lists */
.partner-list,
.opponent-list {
  list-style: none;
  padding-left: 0;
  margin-top: 0;
  margin-bottom: 1rem;
}

.partner-list li,
.opponent-list li {
  margin-bottom: 0.5rem;
}

/* Last matches section */
.last-matches {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.match-card {
  flex: 1;
  min-width: 200px;
  background-color: #ffffff;
  border: 3px solid #0a0a0a;
  border-radius: 0.75rem;
  padding: 0.75rem;
  box-shadow: 4px 4px 0px #0a0a0a;
  text-align: center;
}

.match-card h4 {
  margin: 0 0 0.5rem 0;
  font-weight: 700;
}

.match-card .match-teams {
  margin: 0 0 0.6rem 0;
  font-weight: 600;
}

/* Score row: centred, with each number in a neobrutalist tile. */
.match-card .match-score {
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
}
.match-card .score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.4rem;
  padding: 0.35rem 0.55rem;
  font-size: 1.15rem;
  font-weight: 800;
  background-color: #fdf2f2;
  border: 2px solid #0a0a0a;
  border-right-width: 4px;
  border-bottom-width: 4px;
  border-radius: 0.5rem;
}
.match-card .score-vs {
  font-weight: 800;
  color: #888;
}
