/* Newlands Cricket Club - squad management
   Palette: pitch green, willow cream, ball red. */

:root {
  --pitch:      #0f3d2e;
  --pitch-soft: #14513c;
  --ball:       #c1452b;
  --ball-dark:  #9c3421;
  --cream:      #f6f3ea;
  --paper:      #ffffff;
  --ink:        #16211d;
  --ink-soft:   #5b6b64;
  --line:       #dfdcd1;
  /* Form controls need a 3:1 boundary (WCAG 1.4.11); --line is only 1.37:1. */
  --field-line: #a9a596;
  --gold:       #c8a951;
  --ok:         #2f7d55;
  --shadow:     0 1px 2px rgba(16, 33, 29, .06), 0 8px 24px rgba(16, 33, 29, .06);
  --radius:     10px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font: 16px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a { color: var(--pitch); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2 { line-height: 1.2; margin: 0 0 .4em; letter-spacing: -.015em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.15rem; }

.wrap { width: min(1180px, 100% - 2.5rem); margin-inline: auto; }
.main { padding: 2rem 0 4rem; }
.muted { color: var(--ink-soft); }

/* Available to screen readers, invisible on screen. */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 10;
  background: var(--paper); color: var(--pitch);
  padding: .6rem 1rem; border-radius: 0 0 8px 0; font-weight: 600;
}
.skip-link:focus { left: 0; }

/* ------------------------------------------------------------- top bar */

.topbar {
  background: var(--pitch);
  color: var(--cream);
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, .08);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 66px; flex-wrap: wrap; }

.brand { display: inline-flex; align-items: center; gap: .6rem; color: var(--cream); font-weight: 700; letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.brand-ball {
  width: 20px; height: 20px; border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, #e05f43, var(--ball) 60%, var(--ball-dark));
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .25);
  position: relative;
}
.brand-ball::after {
  content: ""; position: absolute; inset: 0;
  border-left: 1.5px dashed rgba(255, 255, 255, .7);
  left: 50%; width: 0;
}
.brand-text { font-size: 1.02rem; }

.nav { display: flex; align-items: center; gap: 1.25rem; }
.nav > a { color: rgba(246, 243, 234, .82); font-size: .93rem; font-weight: 500; }
.nav > a:hover { color: #fff; text-decoration: none; }
.nav > a[aria-current="page"] { color: #fff; box-shadow: 0 2px 0 var(--gold); }

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

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .4rem; padding: .6rem 1.05rem;
  background: var(--ball); color: #fff;
  border: 1px solid transparent; border-radius: 8px;
  font: inherit; font-weight: 600; font-size: .92rem;
  cursor: pointer; white-space: nowrap;
  transition: background .15s ease, transform .05s ease;
}
.btn:hover { background: var(--ball-dark); text-decoration: none; color: #fff; }
.btn:active { transform: translateY(1px); }
.btn-sm { padding: .42rem .8rem; font-size: .86rem; }
.btn-ghost { background: transparent; color: var(--pitch); border-color: var(--line); }
.btn-ghost:hover { background: rgba(15, 61, 46, .07); color: var(--pitch); }
.btn-danger { background: transparent; color: var(--ball-dark); border-color: rgba(193, 69, 43, .4); }
.btn-danger:hover { background: rgba(193, 69, 43, .09); color: var(--ball-dark); }
.is-disabled { opacity: .4; pointer-events: none; }

/* --------------------------------------------------------------- flashes */

.flashes { margin-top: 1rem; }
.flash {
  border-radius: 8px; padding: .7rem 1rem; margin-bottom: .6rem;
  font-size: .93rem; border: 1px solid transparent;
}
.flash-success { background: #e8f4ec; border-color: #bcdfc9; color: #1d5c3c; }
.flash-error   { background: #fbeae6; border-color: #f0c4b9; color: #8f2f1c; }

/* ------------------------------------------------------------------ hero */

.hero {
  display: grid; grid-template-columns: 1.35fr 1fr; gap: 2rem; align-items: center;
  background: linear-gradient(135deg, var(--pitch), var(--pitch-soft));
  color: var(--cream);
  border-radius: 16px; padding: 2.6rem;
  box-shadow: var(--shadow);
}
.eyebrow {
  margin: 0 0 .6rem; text-transform: uppercase; letter-spacing: .16em;
  font-size: .72rem; font-weight: 700; color: var(--gold);
}
.hero h1 { font-size: clamp(1.8rem, 3.6vw, 2.7rem); margin-bottom: .5rem; }
.lede { color: rgba(246, 243, 234, .8); max-width: 52ch; margin: 0 0 1.5rem; }
.hero-actions { display: flex; gap: .7rem; flex-wrap: wrap; }
.hero .btn-ghost { color: var(--cream); border-color: rgba(255, 255, 255, .4); }
.hero .btn-ghost:hover { background: rgba(255, 255, 255, .12); color: #fff; }

.hero-card { display: flex; justify-content: center; }
.pitch {
  position: relative; width: 150px; height: 260px;
  background: linear-gradient(#cfc09a, #e4d8bb);
  border-radius: 6px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
  display: flex; flex-direction: column; justify-content: space-between; align-items: center;
  padding: 26px 0;
}
.crease { width: 78%; height: 2px; background: rgba(255, 255, 255, .85); }
.crease-far { opacity: .75; }
.stumps { display: flex; gap: 5px; align-items: flex-end; }
.stumps span { display: block; width: 3px; height: 34px; background: var(--cream); border-radius: 2px; }

/* -------------------------------------------------------------- stat row */

.stat-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem; margin: 1.4rem 0;
}
.stat {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.2rem; display: flex; flex-direction: column; gap: .15rem;
}
.stat-value { font-size: 1.75rem; font-weight: 700; letter-spacing: -.02em; color: var(--pitch); }
.stat-label { font-size: .8rem; color: var(--ink-soft); }

/* --------------------------------------------------------------- panels */

.panel {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.3rem 1.4rem; margin-bottom: 1.4rem;
}
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .9rem; }
.panel-head h2 { margin: 0; }
.panel-head a { font-size: .85rem; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.4rem; }
.empty { text-align: center; padding: 2.6rem 1.4rem; }
/* :not(.eyebrow) so this does not out-specify the gold eyebrow on the error page. */
.empty p:not(.eyebrow) { color: var(--ink-soft); margin-bottom: 1.2rem; }

/* --------------------------------------------------------- leaderboards */

.leaderboard { list-style: none; margin: 0; padding: 0; counter-reset: rank; }
.leaderboard li { counter-increment: rank; border-top: 1px solid var(--line); }
.leaderboard li:first-child { border-top: 0; }
.leaderboard a { display: flex; align-items: center; gap: .8rem; padding: .6rem 0; color: inherit; }
.leaderboard a:hover { text-decoration: none; }
.leaderboard a:hover .lb-name { color: var(--ball); }
.lb-avatar, .avatar {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  background: var(--pitch); color: var(--cream);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .76rem; font-weight: 700; letter-spacing: .02em;
}
.lb-name { flex: 1; font-weight: 600; font-size: .94rem; display: flex; flex-direction: column; }
.lb-name small { font-weight: 400; color: var(--ink-soft); font-size: .78rem; }
.lb-value { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--pitch); }

.role-bars { display: flex; flex-direction: column; gap: .8rem; }
.role-bar-top { display: flex; justify-content: space-between; font-size: .88rem; margin-bottom: .3rem; }
.role-bar-top span { font-variant-numeric: tabular-nums; color: var(--ink-soft); }
.bar { height: 8px; background: #e9e6db; border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--pitch), var(--pitch-soft)); border-radius: 99px; }

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

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-head p { margin: .2rem 0 0; font-size: .9rem; }
.page-head-actions { display: flex; gap: .6rem; flex-wrap: wrap; }

.breadcrumb { font-size: .85rem; color: var(--ink-soft); margin: 0 0 1rem; }
.breadcrumb span { opacity: .5; margin: 0 .25rem; }

/* -------------------------------------------------------------- filters */

.filters {
  display: flex; gap: .6rem; flex-wrap: wrap; align-items: center;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .8rem; margin-bottom: 1.2rem;
}
.filters input[type="search"] { flex: 1 1 260px; min-width: 0; }
/* A select is as wide as its widest option, so a long team name would overflow. */
.filters select { max-width: 100%; min-width: 0; }

input, select, textarea {
  font: inherit; color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--field-line); border-radius: 8px;
  padding: .5rem .65rem;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--pitch-soft);
  outline: 2px solid var(--pitch-soft);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------- table */

.table-scroll { overflow-x: auto; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: .7rem .85rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table thead th {
  background: #f2efe6; font-size: .74rem; text-transform: uppercase;
  letter-spacing: .08em; color: var(--ink-soft); font-weight: 700; white-space: nowrap;
}
.table thead th a { color: inherit; display: inline-block; padding: .25rem .35rem; margin: -.25rem -.35rem; }
.table thead th a.is-sorted { color: var(--pitch); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #faf8f2; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .jersey { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ink-soft); width: 3rem; }
/* Tinted rather than faded: opacity dropped the "Unavailable" badge to 2.15:1. */
.table tr.is-inactive td { background: #f4f2ea; }
.table tr.is-inactive:hover td { background: #efece2; }

.player-cell { display: flex; align-items: center; gap: .65rem; color: inherit; }
.player-cell:hover { text-decoration: none; }
.player-cell:hover strong { color: var(--ball); }
.player-cell small { display: block; color: var(--ink-soft); font-size: .78rem; }

.tag {
  display: inline-block; font-size: .68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; padding: .1rem .38rem; border-radius: 4px;
  background: #ece9de; color: var(--ink-soft); vertical-align: middle; margin-left: .3rem;
}
.tag-capt { background: rgba(200, 169, 81, .22); color: #7a6320; }
.tag-ok { background: #e3f1e8; color: #2a6f4b; }

.role-pill {
  display: inline-block; font-size: .75rem; font-weight: 600;
  padding: .15rem .5rem; border-radius: 99px;
  background: #eceadf; color: var(--ink-soft); white-space: nowrap;
}
.role-bat { background: #e6eefb; color: #23508f; }
.role-bow { background: #fbe9e5; color: #a03a24; }
.role-all { background: #e7f2e9; color: #276845; }
.role-wic { background: #f5ebd6; color: #7d6220; }

.actions-col { width: 1%; white-space: nowrap; }
.row-actions { display: flex; align-items: center; gap: .8rem; font-size: .86rem; }
/* 24px minimum touch target, WCAG 2.5.8. */
.row-actions a, .link-danger { display: inline-flex; align-items: center; min-height: 24px; }
.link-danger {
  background: none; border: 0; padding: 0; font: inherit; font-size: .86rem;
  color: var(--ball-dark); cursor: pointer; text-decoration: none;
}
.link-danger:hover { text-decoration: underline; }

.pager { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1.2rem; font-size: .88rem; color: var(--ink-soft); }

/* -------------------------------------------------------------- profile */

/* min-width: 0 throughout, or one long surname scrolls the whole document. */
.profile {
  display: grid; grid-template-columns: 150px 1fr; gap: 1.8rem;
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.6rem; margin-bottom: 1.4rem;
  min-width: 0;
}
.profile-main { min-width: 0; }
.profile-photo img { width: 150px; height: 150px; object-fit: cover; border-radius: 12px; display: block; }
.avatar-xl { width: 150px; height: 150px; border-radius: 12px; font-size: 2.6rem; }
.profile-title { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; }
.profile-title h1 { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.shirt-number {
  font-size: 1.05rem; font-weight: 800; color: #fff; background: var(--pitch);
  border-radius: 8px; padding: .1rem .5rem; font-variant-numeric: tabular-nums;
}
.profile-tags { margin: .5rem 0 1.1rem; display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.profile-tags .tag { margin-left: 0; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .9rem 1.4rem; margin: 0 0 1.4rem; }
.facts dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); font-weight: 700; }
.facts dd { margin: .15rem 0 0; font-size: .94rem; }
.profile-actions { display: flex; gap: .6rem; flex-wrap: wrap; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .1rem 1rem; }
.stat-grid > div { display: flex; justify-content: space-between; gap: .5rem; padding: .45rem 0; border-bottom: 1px dashed var(--line); }
.stat-grid .k { color: var(--ink-soft); font-size: .87rem; }
.stat-grid .v { font-weight: 700; font-variant-numeric: tabular-nums; }
.notes { margin: 0; color: var(--ink-soft); }

/* ----------------------------------------------------------------- form */

.form { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: .4rem 1.4rem 1.4rem; }
.form fieldset { border: 0; border-top: 1px solid var(--line); padding: 1.2rem 0; margin: 0; }
.form fieldset:first-of-type { border-top: 0; }
.form legend {
  font-size: .74rem; text-transform: uppercase; letter-spacing: .1em;
  font-weight: 700; color: var(--ball); padding: 0;
}
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.grid-tight { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.span-2 { grid-column: span 2; }

.form label { display: flex; flex-direction: column; gap: .3rem; font-size: .88rem; }
.form label > span { font-weight: 600; color: var(--ink); }
.form label > span em { font-style: normal; font-weight: 500; color: var(--ink-soft); font-size: .78rem; }
.form textarea { resize: vertical; }
.form label.check { flex-direction: row; align-items: center; gap: .5rem; align-self: end; padding-bottom: .5rem; }
.form label.check input { width: 16px; height: 16px; accent-color: var(--pitch); }

.has-error input, .has-error select { border-color: var(--ball); background: #fffaf9; }
.field-error { display: block; margin: 0; font-size: .8rem; color: var(--ball-dark); }

.form-actions { display: flex; gap: .6rem; padding-top: 1.2rem; border-top: 1px solid var(--line); }

/* --------------------------------------------------------------- footer */

.footer { border-top: 1px solid var(--line); background: var(--paper); }
.footer-inner {
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: 1.2rem 0; font-size: .82rem; color: var(--ink-soft);
}

/* ------------------------------------------------------------ responsive */

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; padding: 1.8rem; }
  .hero-card { display: none; }
  .two-col { grid-template-columns: 1fr; }
  .profile { grid-template-columns: 1fr; }
  .profile-photo img, .avatar-xl { width: 110px; height: 110px; font-size: 2rem; }
  .span-2 { grid-column: auto; }
}

@media (max-width: 560px) {
  .wrap { width: min(1180px, 100% - 1.6rem); }
  .brand-text { font-size: .92rem; }
  .nav { gap: .8rem; }
  .filters { flex-direction: column; align-items: stretch; }
  /* The bar is a column here, so flex-basis would become a 260px HEIGHT. */
  .filters input[type="search"] { flex: 0 0 auto; width: 100%; }
  .filters .btn { width: 100%; }
}

/* ------------------------------------------------------------------ sales */

.tag-sold { background: #ede4f3; color: #5c3878; }
.table tr.is-sold td { background: #f7f4fa; }
.table tr.is-sold:hover td { background: #f2edf7; }
.panel-sold { border-left: 3px solid #7a52a1; }
.panel-sold .facts { margin-bottom: 0; }
.panel-sold .notes { margin-top: 1rem; }
