/* ------------------------------------------------------------------ */
/*  OctoberOche — darts score tracker                                  */
/*  Finli brand: dark blue, light blue, orange on a light surface.     */
/*  The latest-scores chalkboard keeps its pub-chalkboard look.        */
/* ------------------------------------------------------------------ */

:root {
  --navy: #06526C;          /* Finli dark blue                      */
  --sky: #6FBBDC;           /* Finli light blue                     */
  --orange: #F47920;        /* Finli orange                         */
  --page: #f3f8fb;          /* pale blue-white page background      */
  --surface: #ffffff;       /* cards                                */
  --surface-2: #f3f8fb;     /* rows inside cards                    */
  --line: #d5e8f1;
  --text: #06526C;
  --text-dim: #5d8595;
  --radius: 16px;
  --shadow: 0 6px 20px rgba(6, 82, 108, 0.10);
  --font-display: 'Open Sans', Inter, system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--page);
  min-height: 100vh;
}

a { color: var(--orange); }

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 48px);
  background: #fff;
  border-bottom: 4px solid var(--orange);
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; text-decoration: none; }
.brand-logo { height: 64px; width: auto; display: block; }
@media (max-width: 640px) {
  .topbar { justify-content: center; gap: 12px; }
  .brand-logo { height: 48px; }
}

.nav { display: flex; gap: 8px; flex-wrap: wrap; }
.nav a {
  text-decoration: none;
  color: var(--navy);
  font-weight: 600;
  font-size: 14px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  transition: all 0.15s ease;
}
.nav a:hover { background: var(--surface-2); }
@media (max-width: 640px) {
  .nav { width: 100%; justify-content: center; gap: 6px; }
  .nav a { font-size: 13px; padding: 8px 12px; }
}
.nav a.active {
  background: var(--orange);
  border-color: var(--orange);
  color: #fff;
}

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

.wrap {
  max-width: 1320px;
  margin: 0 auto;
  padding: clamp(20px, 4vw, 44px);
}

.hero-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(30px, 5.5vw, 58px);
  line-height: 1.05;
  margin: 0 0 8px;
  text-transform: uppercase;
  color: var(--navy);
}
.hero-title span { color: var(--orange); }
.hero-sub { color: var(--text-dim); margin: 0 0 28px; max-width: 60ch; }

/* front-page banner: title on the left, branded dartboard on the right */
.hero {
  display: grid;
  grid-template-columns: 1fr minmax(260px, 380px);
  align-items: center;
  gap: 24px;
  margin: 0 0 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 6px solid var(--orange);
  border-radius: var(--radius);
  padding: 0 0 0 32px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.hero .hero-sub { margin-bottom: 0; }
.hero-art { width: 100%; height: 270px; object-fit: cover; object-position: 60% 55%; display: block; }
@media (max-width: 800px) {
  .hero { grid-template-columns: 1fr; gap: 0; padding: 22px 20px 0; }
  .hero-art { height: 200px; margin-top: 8px; object-position: 55% 50%; }
}

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--orange);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 14px 26px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s ease, filter 0.12s ease;
}
.btn:hover { transform: translateY(-2px); filter: brightness(1.08); }
.btn.secondary { background: var(--navy); }
.btn.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--navy);
  box-shadow: none;
}

/* ---- cards -------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}

/* ---- front screen: dartboard + chalkboard + standings + top teams -- */

.scoreboard {
  display: grid;
  grid-template-columns: 260px 340px 1fr 1fr;
  gap: 24px;
  align-items: stretch;
}
/* keep grid items inside their tracks (defeats default min-width:auto) */
.scoreboard > * { min-width: 0; }
@media (max-width: 1180px) {
  .scoreboard { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .scoreboard { grid-template-columns: 1fr; }
}

.panel-title {
  margin: 0 0 14px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 22px;
  color: var(--navy);
}

/* ---- dartboard progress pie --------------------------------------- */

.dart-progress {
  width: 100%;
  max-width: 240px;
  margin: 14px auto 6px;
}
.dart-progress svg { width: 100%; height: auto; display: block; }

/* ---- pub chalkboard (latest scores) ------------------------------- */

.chalkboard { display: flex; min-width: 0; }
.chalk-frame {
  flex: 1;
  min-width: 0;
  position: relative;
  display: flex;
  border-radius: 14px;
  padding: 16px;
  background:
    linear-gradient(180deg, #7a4a25, #4f3016),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.16) 0 1px, transparent 1px 7px);
  background-blend-mode: multiply;
  box-shadow: var(--shadow), inset 0 0 0 2px rgba(0, 0, 0, 0.25),
    inset 0 2px 6px rgba(255, 255, 255, 0.12);
}
.chalk-frame .screw {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #d9c7a2, #6b5327 70%);
  box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.6);
}
.chalk-frame .screw::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-top: 1px solid rgba(0, 0, 0, 0.55);
  transform: rotate(35deg);
}
.chalk-frame .screw.tl { top: 7px; left: 7px; }
.chalk-frame .screw.tr { top: 7px; right: 7px; }
.chalk-frame .screw.bl { bottom: 7px; left: 7px; }
.chalk-frame .screw.br { bottom: 7px; right: 7px; }

.chalk-surface {
  flex: 1;
  min-width: 0;
  min-height: 340px;
  position: relative;
  overflow: hidden;
  border-radius: 6px;
  padding: 14px 18px 8px;
  background:
    radial-gradient(120% 80% at 25% 15%, rgba(255, 255, 255, 0.05), transparent 60%),
    #0c1512;
  box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.7);
  color: #eef3ee;
  font-family: 'Caveat', 'Comic Sans MS', cursive;
}
/* faint chalk-dust streaks */
.chalk-surface::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.03) 0 2px, transparent 2px 26px);
  pointer-events: none;
}
/* older scores fade off the bottom of the board */
.chalk-surface::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 64px;
  background: linear-gradient(transparent, #0c1512);
  pointer-events: none;
}

.chalk-title {
  text-align: center;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #fdfdf5;
  text-shadow: 0 0 1px rgba(255, 255, 255, 0.5);
  margin-bottom: 4px;
}

/* header + every row share the same track widths so columns line up */
.chalk-head, .chalk-row {
  display: grid;
  grid-template-columns: 1fr 56px 76px;
  gap: 6px;
  align-items: baseline;
}
.chalk-head {
  font-family: var(--font-body);
  font-size: 12px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #9fb2a4;
  padding-bottom: 5px;
  margin-bottom: 6px;
  border-bottom: 2px solid rgba(238, 243, 238, 0.4);
}
.chalk-head span:not(:first-child) { text-align: right; }

@media (max-width: 400px) {
  .chalk-surface { padding: 12px 12px 8px; }
  .chalk-head, .chalk-row { grid-template-columns: 1fr 44px 64px; }
  .chalk-row { font-size: 19px; }
  .chalk-row.latest { font-size: 20px; }
}

.chalk-list { display: flex; flex-direction: column; gap: 4px; }
.chalk-row {
  font-size: 21px;
  line-height: 1.2;
  position: relative;
  color: #eef3ee;
}
.chalk-row .c-team { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chalk-row .c-score,
.chalk-row .c-total { text-align: right; }
.chalk-row .c-score { font-weight: 700; text-shadow: 0 0 1px rgba(255, 255, 255, 0.35); }
.chalk-row .c-total { color: #dfe9e0; font-weight: 700; }

/* newest score sits proud at the top */
.chalk-row.latest {
  font-size: 23px;
  color: #fffdf3;
}
.chalk-row.latest .c-total { color: var(--orange); }
.chalk-row.latest .c-team::before {
  content: '➤ ';
  color: var(--orange);
  font-family: var(--font-body);
  font-size: 14px;
}
@keyframes chalkIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; } }

/* older scores are crossed off as newer ones arrive above them */
.chalk-row.done { color: #aebfb2; }
.chalk-row.done::after {
  content: '';
  position: absolute;
  left: -3px; right: -3px; top: 55%;
  height: 2px;
  background: rgba(230, 240, 235, 0.6);
  border-radius: 2px;
}
.chalk-row.done:nth-child(2n)::after { transform: rotate(-1.4deg); }
.chalk-row.done:nth-child(2n+1)::after { transform: rotate(1deg); }

.chalk-empty {
  text-align: center;
  color: #aebfb2;
  font-size: 22px;
  margin-top: 24px;
}

.thermo-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}
.thermo-total {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 60px;
  line-height: 1;
}
.thermo-total small {
  display: block;
  font-family: var(--font-body);
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #b9dcec;
  margin-bottom: 12px;
}
.thermo-goal { color: #b9dcec; font-size: 14px; margin-top: 6px; }

/* region breakdown */
.breakdown { display: flex; flex-direction: column; gap: 12px; }
.region-row {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left-width: 5px;
}
.region-row .swatch { display: none; }
.region-row .r-name { font-weight: 600; overflow-wrap: anywhere; } /* lets "Functions/Hybrid" break */
.region-row .r-meta { font-size: 12px; color: var(--text-dim); }
.region-row .r-score {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 28px;
  text-align: right;
  line-height: 1;
}
.region-bar {
  grid-column: 1 / -1;
  height: 7px;
  border-radius: 999px;
  background: #e2eef4;
  overflow: hidden;
}
.region-bar > span { display: block; height: 100%; border-radius: 999px; }

/* ---- top teams leaderboard ---------------------------------------- */

.leaderboard { display: flex; flex-direction: column; gap: 8px; }
.lb-row {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left-width: 5px;
}
.lb-rank {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 18px;
  line-height: 1;
  text-align: center;
  color: var(--text-dim);
}
.lb-team {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lb-score {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 21px;
  line-height: 1;
  text-align: right;
}
.lb-empty { color: var(--text-dim); padding: 8px 2px; }

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

.form-grid { display: flex; flex-direction: column; gap: 18px; max-width: 620px; }
label { display: block; font-weight: 600; margin-bottom: 6px; }
label .req { color: var(--orange); }
input[type="text"],
input[type="number"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 16px; /* 16px stops iOS zooming into the field */
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(244, 121, 32, 0.2);
}
textarea { min-height: 96px; resize: vertical; }
select option { color: #000; }

.file-drop {
  border: 2px dashed var(--line);
  border-radius: 12px;
  padding: 18px;
  text-align: center;
  color: var(--text-dim);
  cursor: pointer;
}
.file-drop:hover { border-color: var(--orange); }
.file-preview { margin-top: 12px; }
.file-preview img {
  max-width: 100%;
  max-height: 240px;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.flash {
  padding: 14px 16px;
  border-radius: 12px;
  margin-bottom: 18px;
  font-weight: 600;
}
.flash.ok { background: rgba(111, 187, 220, 0.2); border: 1px solid var(--sky); }
.flash.err { background: rgba(244, 121, 32, 0.12); border: 1px solid var(--orange); }

/* ---- teams list --------------------------------------------------- */

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.chip {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--navy);
  padding: 10px 16px; /* comfortable tap target on phones */
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.chip.active { color: #fff; border-color: transparent; }

.entries { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 18px; }
.entry {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  border-left: 6px solid var(--line);
  background: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.entry .entry-photo { width: 100%; height: 180px; object-fit: cover; display: block; background: #000; }
.entry .entry-body { padding: 16px; }
.entry .entry-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.entry .entry-team { font-size: 18px; font-weight: 700; margin: 0; }
.entry .entry-score {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 30px;
  line-height: 1;
}
.entry .region-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #fff;
  padding: 4px 10px;
  border-radius: 999px;
  margin: 8px 0;
}
.entry .entry-comments { color: var(--text-dim); font-size: 14px; margin: 8px 0 0; white-space: pre-wrap; }
.entry .entry-date { color: var(--text-dim); font-size: 12px; margin-top: 10px; }

.empty { text-align: center; color: var(--text-dim); padding: 60px 20px; }

.footer { text-align: center; color: var(--text-dim); font-size: 12px; padding: 30px; }

/* ---- admin -------------------------------------------------------- */

.admin-bar { display: flex; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.admin-bar input { flex: 1; min-width: 200px; }
.admin-list { display: flex; flex-direction: column; gap: 10px; }
.admin-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 14px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left-width: 5px;
}
.admin-row .a-team { font-weight: 700; overflow-wrap: anywhere; }
.admin-row .a-meta { font-size: 13px; color: var(--text-dim); overflow-wrap: anywhere; }
.admin-row .a-score { font-family: var(--font-display); font-weight: 800; font-size: 24px; }
.btn.danger { background: #b3261e; padding: 10px 18px; font-size: 14px; }
.btn:disabled { opacity: 0.6; cursor: default; transform: none; }
@media (max-width: 520px) {
  .admin-row { grid-template-columns: minmax(0, 1fr) auto; }
  .admin-row .btn.danger { grid-column: 1 / -1; justify-content: center; }
}
