/* Shared components. Every value comes from tokens.css; no colour or shadow is defined here. */

/* ---------- Base ---------- */

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

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  font-weight: var(--w-regular);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

h1,
h2,
h3,
p {
  margin: 0;
}

ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

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

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

/* The page behind an open sheet stays still. */
body:has(dialog[open]) {
  overflow: hidden;
}

.topbar + main,
.topbar + .state,
.topbar + .state--card {
  margin-top: 12px;
}

.icon {
  flex-shrink: 0;
  display: block;
}

.num {
  font-variant-numeric: tabular-nums;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Page column ---------- */

.page {
  width: 100%;
  max-width: var(--column);
  margin: 0 auto;
  padding-top: calc(12px + env(safe-area-inset-top));
  padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
  padding-bottom: calc(40px + env(safe-area-inset-bottom));
}

/* Leaves room for the dock: its height (64 + 2×8, or as measured into --dock-space), its float above the bottom
   edge (24px, or the safe area) and a 24px gap, so the last row never hides under it. */
.page--dock {
  padding-bottom: calc(var(--dock-space, var(--dock-height)) + max(24px, calc(8px + env(safe-area-inset-bottom))) + 24px);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 24px 0 8px;
}

.title {
  font-size: 26px;
  font-weight: var(--w-semibold);
  letter-spacing: -0.02em;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.meta {
  font-size: 13px;
  color: var(--ink-2);
}

.secondary {
  font-size: 14px;
  color: var(--ink-2);
}

/* ---------- Label ---------- */

.lbl {
  font-size: 11px;
  font-weight: var(--w-semibold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.3;
}

.lbl--muted {
  color: var(--ink-2);
}

/* ---------- Top bar ---------- */

.topbar {
  display: grid;
  grid-template-columns: var(--touch) 1fr var(--touch);
  align-items: center;
  min-height: var(--touch);
  margin: 0 -12px;
}

.topbar__title {
  text-align: center;
  min-width: 0;
}

.topbar__title strong {
  display: block;
  font-size: 15px;
  font-weight: var(--w-semibold);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__title span {
  display: block;
  font-size: 12px;
  color: var(--ink-2);
}

.topbar--brand {
  grid-template-columns: 1fr var(--touch);
  margin-left: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: var(--w-semibold);
  letter-spacing: -0.01em;
}

.brand__mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--accent-ink);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--touch);
  min-width: var(--touch);
  padding: 0 20px;
  border: 0;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--ink);
  font-size: 15px;
  font-weight: var(--w-semibold);
  line-height: 1.2;
  text-align: center;
  transition: background-color var(--dur-enter) var(--ease-out), opacity var(--dur-enter) var(--ease-out);
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn--primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn--tint {
  background: var(--neutral-tint);
  color: var(--ink);
}

.btn--danger {
  background: var(--negative-tint);
  color: var(--negative);
}

.btn--block {
  display: flex;
  width: 100%;
}

.btn--lg {
  min-height: 56px;
  border-radius: var(--radius-button-lg);
  font-size: 16px;
}

.btn--icon {
  padding: 0;
  width: var(--touch);
  border-radius: var(--radius-full);
}

.btn--link {
  padding: 0 4px;
  color: var(--accent);
  font-size: 14px;
}

@media (hover: hover) {
  .btn--tint:hover,
  .btn--icon:hover {
    background: var(--neutral-tint);
  }
}

.btn:active:not(:disabled) {
  opacity: 0.85;
}

.spin {
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Card ---------- */

.card {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card--pad {
  padding: 20px;
}

.card--scoreboard {
  border-radius: var(--radius-scoreboard);
  padding: 20px;
}

/* Rows inside a card, divided by hairlines. */
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: var(--row-min);
  padding: 12px 16px;
  border: 0;
  background: transparent;
  text-align: left;
}

.row + .row,
li + li > .row {
  border-top: 1px solid var(--line);
}

a.row,
button.row {
  transition: background-color var(--dur-enter) var(--ease-out);
}

@media (hover: hover) {
  a.row:hover,
  button.row:hover {
    background: var(--bg);
  }
}

.row:focus-visible {
  outline-offset: -2px;
}

.row__main {
  flex: 1;
  min-width: 0;
}

.row__title {
  display: block;
  font-size: 16px;
  font-weight: var(--w-semibold);
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row__aside {
  color: var(--ink-2);
  flex-shrink: 0;
}

/* ---------- Tile (40px event / type square) ---------- */

.tile {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-tile);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--neutral-tint);
  color: var(--ink-2);
}

.tile--positive {
  background: var(--positive-tint);
  color: var(--positive);
}

.tile--negative {
  background: var(--negative-tint);
  color: var(--negative);
}

.tile--neutral {
  background: var(--neutral-tint);
  color: var(--ink-2);
}

.tile--warn {
  background: var(--warn-tint);
  color: var(--warn-ink);
}

/* ---------- Pills ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 24px;
  padding: 0 10px;
  border-radius: var(--radius-full);
  background: var(--neutral-tint);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: var(--w-semibold);
  white-space: nowrap;
}

.pill--accent {
  background: var(--accent);
  color: var(--accent-ink);
}

/* Avatar + name + number. Tappable. */
.player-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: var(--touch);
  padding: 0 14px 0 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  background: var(--surface);
  font-size: 15px;
  font-weight: var(--w-medium);
  flex-shrink: 0;
}

.player-pill__no {
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  margin-left: 2px;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--neutral-tint);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 13px;
  font-weight: var(--w-semibold);
  font-variant-numeric: tabular-nums;
}

.avatar--lg {
  width: 40px;
  height: 40px;
  font-size: 14px;
}

/* ---------- Status dot ---------- */

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-2);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--ink-2);
  flex-shrink: 0;
}

.dot--accent {
  background: var(--accent);
}

.status--live {
  color: var(--accent);
}

/* ---------- "Maça dön" (home: the live match on this phone) ---------- */

.resume {
  margin-top: 8px;
}

.resume__tile {
  background: var(--accent-soft);
  color: var(--accent);
}

.resume .status {
  margin-top: 2px;
}

/* ---------- Scoreboard (inside .card--scoreboard; the match screen and the public page) ---------- */

.scoreboard__teams {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
}

.scoreboard__side {
  flex: 1;
  min-width: 0;
}

.scoreboard__side--them {
  text-align: right;
}

.scoreboard__side--them .scoreboard__name {
  justify-content: flex-end;
}

.scoreboard__name {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  min-width: 0;
}

.scoreboard__name .lbl {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score {
  font-size: var(--score-size);
  font-weight: var(--score-weight);
  letter-spacing: var(--score-tracking);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.scoreboard__side--them .score {
  color: var(--ink-2);
}

.score--changed {
  animation: score-in 300ms var(--ease-out);
}

@keyframes score-in {
  from {
    opacity: 0;
  }
}

.scoreboard__rule {
  width: 1px;
  height: 48px;
  margin: 0 16px 4px;
  background: var(--line);
  flex-shrink: 0;
}

.scoreboard__status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 20px;
}

.scoreboard__point,
.scoreboard__net {
  display: flex;
  align-items: center;
  gap: 8px;
}

.scoreboard__net {
  gap: 6px;
}

.scoreboard__net .dot {
  width: 6px;
  height: 6px;
}

.dot--positive {
  background: var(--positive);
}

.dot--warn {
  background: var(--warn-ink);
}

.progress {
  display: flex;
  gap: 4px;
  margin-top: 12px;
}

/* On the match screen the progress line is a button: it opens "Tüm sayılar". The padding is its touch area. */
.progress--button {
  width: 100%;
  margin-top: 3px;
  padding: 9px 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.progress__seg {
  flex: 1;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--ink-15);
}

.progress__seg--us {
  background: var(--accent);
}

.progress__seg--open {
  background: var(--ink-5);
  box-shadow: inset 0 0 0 1px var(--ink-15);
}

/* ---------- Segmented control (radio group) ---------- */

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  padding: 4px;
  margin: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: var(--neutral-tint);
  min-width: 0;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--touch);
  padding: 0 8px;
  border-radius: var(--radius-full);
  color: var(--ink-2);
  font-size: 14px;
  font-weight: var(--w-medium);
  text-align: center;
  line-height: 1.2;
  cursor: pointer;
  transition: background-color var(--dur-enter) var(--ease-out), color var(--dur-enter) var(--ease-out);
}

.segmented input:checked + label {
  background: var(--surface);
  color: var(--ink);
  font-weight: var(--w-semibold);
  box-shadow: var(--shadow);
}

.segmented input:focus-visible + label {
  outline: 2px solid var(--accent);
  outline-offset: 0;
}

/* The selected option is raised onto a white surface and set in a heavier weight: not colour alone. */

/* ---------- Forms ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.field > .lbl {
  color: var(--ink-2);
}

.input {
  width: 100%;
  min-height: 52px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-tile);
  background: var(--neutral-tint);
  color: var(--ink);
  font-size: 16px;
  font-weight: var(--w-medium);
  appearance: none;
  transition: background-color var(--dur-enter) var(--ease-out), border-color var(--dur-enter) var(--ease-out);
}

.input::placeholder {
  color: var(--ink-2);
  font-weight: var(--w-regular);
  opacity: 1;
}

.input:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.input[aria-invalid='true'] {
  background: var(--negative-tint);
  border-color: var(--negative);
}

.field-error {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  color: var(--negative);
  font-size: 14px;
  font-weight: var(--w-medium);
  line-height: 1.35;
}

.field-error .icon {
  margin-top: 1px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 104px;
  gap: 12px;
}

/* Native checkbox restyled as a switch; the label text says what on means. */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: var(--row-min);
  cursor: pointer;
}

.switch-row__text strong {
  display: block;
  font-size: 16px;
  font-weight: var(--w-semibold);
}

.switch {
  appearance: none;
  flex-shrink: 0;
  position: relative;
  width: 52px;
  height: 32px;
  margin: 0;
  border-radius: var(--radius-full);
  background: var(--neutral-tint);
  box-shadow: inset 0 0 0 1px var(--line);
  cursor: pointer;
  transition: background-color var(--dur-enter) var(--ease-out);
}

.switch::after {
  content: '';
  position: absolute;
  top: 4px;
  left: 4px;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: transform var(--dur-enter) var(--ease-out);
}

.switch:checked {
  background: var(--accent);
}

.switch:checked::after {
  transform: translateX(20px);
}

/* ---------- Dock (floating bottom bar) ---------- */

.dock {
  position: fixed;
  z-index: 40;
  left: 0;
  right: 0;
  bottom: max(24px, calc(8px + env(safe-area-inset-bottom)));
  margin: 0 auto;
  width: calc(100% - 24px);
  max-width: calc(var(--column) - 24px);
  padding: 8px;
  border-radius: var(--radius-dock);
  background: var(--surface);
  box-shadow: var(--shadow-float);
  display: flex;
  gap: 8px;
}

.dock > .btn {
  flex: 1;
  min-height: var(--dock-button);
  border-radius: var(--radius-button-lg);
  font-size: 16px;
}

/* ---------- Sheet (bottom dialog) ---------- */

.sheet {
  position: fixed;
  inset: auto 0 0 0;
  width: 100%;
  max-width: var(--column);
  max-height: calc(100dvh - 24px);
  margin: 0 auto;
  padding: 8px var(--gutter) calc(20px + env(safe-area-inset-bottom));
  border: 0;
  border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-float);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sheet[open] {
  animation: sheet-in var(--dur-enter) var(--ease-out);
}

.sheet::backdrop {
  background: var(--backdrop);
}

@keyframes sheet-in {
  from {
    transform: translateY(24px);
    opacity: 0;
  }
}

.sheet__grabber {
  width: 40px;
  height: 6px;
  margin: 4px auto 12px;
  border-radius: var(--radius-full);
  background: var(--ink-15);
}

.sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--touch);
}

/* The close button: a tinted circle, as in the mockups. */
.sheet__close {
  background: var(--neutral-tint);
  flex-shrink: 0;
}

.sheet__title {
  font-size: 22px;
  font-weight: var(--w-semibold);
  letter-spacing: -0.01em;
  min-width: 0;
  overflow-wrap: anywhere;
}

.sheet__body {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 12px;
}

/* ---------- Screen states ---------- */

.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 48px 24px;
  text-align: center;
  color: var(--ink-2);
}

.state__title {
  color: var(--ink);
  font-size: 17px;
  font-weight: var(--w-semibold);
}

.state--card {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
}

/* ---------- Key form (locked) ---------- */

.unlock {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin-top: 12vh;
}

.unlock__intro {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.unlock .tile {
  margin-bottom: 8px;
}

/* ---------- Teams (home) ---------- */

.team__head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 16px;
}

.team__name {
  display: block;
  font-size: 17px;
  font-weight: var(--w-semibold);
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.team__matches {
  border-top: 1px solid var(--line);
}

.match-row__score {
  font-size: 17px;
  font-weight: var(--w-semibold);
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.match-row .status {
  width: 64px;
  justify-content: flex-end;
  flex-shrink: 0;
}

.empty-row {
  padding: 16px;
  font-size: 14px;
  color: var(--ink-2);
}

/* ---------- Roster ---------- */

.roster-row .row__title {
  font-weight: var(--w-semibold);
}

.roster-row--inactive .row__title,
.roster-row--inactive .avatar {
  color: var(--ink-2);
}

.add-player {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---------- Finished match (team page) ---------- */

.ended-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.ended-card__link {
  color: var(--accent);
  font-weight: var(--w-semibold);
  overflow-wrap: anywhere;
}

.ended-card__actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* A match on the team page: the row, then its links (public page, per-player comments). */
.team-match__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  padding: 0 12px 8px;
  margin-top: -4px;
}

.team-match__actions .btn--link {
  min-height: 40px;
  gap: 6px;
}

li + li > .team-match {
  border-top: 1px solid var(--line);
}

/* The roster inside the comments sheet sits on the sheet's surface: a hairline instead of a shadow. */
.comments-pick {
  box-shadow: none;
  border: 1px solid var(--line);
}
