/* Skyttelogg. Mobile first, light with automatic dark mode. */

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --text: #131820;
  --muted: #5d6675;
  --border: #e1e5eb;
  --accent: #1f5bd6;
  --accent-strong: #1747ae;
  --accent-soft: #e7eefc;
  --on-accent: #ffffff;
  --danger: #c4302b;
  --danger-soft: #fdeceb;
  --success: #17804a;
  --success-soft: #e5f5ec;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, .12);
  --radius: 14px;
  --radius-sm: 10px;
  --tabbar-h: 64px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --surface: #171b22;
    --surface-2: #1f242d;
    --text: #edf0f4;
    --muted: #98a2b1;
    --border: #2a303b;
    --accent: #6d9cff;
    --accent-strong: #8fb3ff;
    --accent-soft: #1a2944;
    --on-accent: #0b1220;
    --danger: #ff6b63;
    --danger-soft: #3a1c1b;
    --success: #4cc68a;
    --success-soft: #16301f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, .5);
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.1rem; font-weight: 650; }
p { margin: 0; }
.icon { flex: none; vertical-align: middle; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }

/* ---------- App shell ---------- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  max-width: 960px; margin: 0 auto; height: 56px;
  display: flex; align-items: center; gap: 24px; padding: 0 16px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent);
}
.brand-logo, .club-logo { width: 32px; height: 32px; border-radius: 9px; object-fit: contain; flex: none; }
.club-logo { width: 64px; height: 64px; border-radius: 14px; }
.brand small { display: block; font-weight: 500; color: var(--muted); font-size: .72rem; line-height: 1; }
.brand span { line-height: 1.1; }

.topnav { display: none; gap: 4px; flex: 1; }
.topnav a {
  color: var(--muted); font-weight: 550; padding: 8px 12px; border-radius: 999px;
}
.topnav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.topnav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
.user-chip {
  margin-left: auto; display: flex; align-items: center; gap: 6px;
  font-size: .85rem; color: var(--muted); background: var(--surface-2);
  padding: 5px 10px 5px 8px; border-radius: 999px;
}
.user-chip:hover { text-decoration: none; color: var(--text); }
.user-chip-name { max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main.page {
  max-width: 720px; margin: 0 auto;
  padding: 20px 16px calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom));
}
main.page.wide { max-width: 960px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  height: var(--tabbar-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: .7rem; font-weight: 600;
}
.tabbar a:hover { text-decoration: none; }
.tabbar a[aria-current="page"] { color: var(--accent); }
.tabbar .tab-primary span.fab {
  width: 48px; height: 48px; border-radius: 16px; display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-lg);
  margin-top: -10px;
}

@media (min-width: 769px) {
  .topnav { display: flex; }
  .tabbar { display: none; }
  main.page { padding-bottom: 48px; padding-top: 32px; }
}

/* ---------- Layout helpers ---------- */

.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.stack-lg { display: flex; flex-direction: column; gap: 28px; }
.row { display: flex; align-items: center; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-2 > * { min-width: 0; }
@media (max-width: 420px) { .grid-2.collapse { grid-template-columns: 1fr; } }

.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-header p { margin-top: 4px; }
.back-link { display: inline-flex; align-items: center; gap: 2px; color: var(--muted); font-weight: 550; margin-bottom: 12px; margin-left: -6px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.section-title h2 { font-size: 1rem; }

/* ---------- Cards & lists ---------- */

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px;
}
.card-flush { padding: 0; overflow: hidden; }

.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { border-top: 1px solid var(--border); }
.list-item {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; color: var(--text);
  min-height: 60px;
}
a.list-item:hover { background: var(--surface-2); text-decoration: none; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .sub { color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .chev { color: var(--muted); opacity: .6; }
.list-group-label {
  padding: 18px 4px 8px; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 650;
}

.date-badge {
  width: 46px; flex: none; text-align: center; border-radius: 10px; background: var(--surface-2);
  padding: 5px 0; line-height: 1.1;
}
.date-badge b { display: block; font-size: 1.05rem; }
.date-badge span { font-size: .68rem; text-transform: uppercase; color: var(--muted); font-weight: 650; letter-spacing: .04em; }

.points { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.25rem; }
.points-xl { font-variant-numeric: tabular-nums; font-weight: 750; font-size: 3.2rem; line-height: 1; letter-spacing: -.02em; }

.avatar {
  width: 40px; height: 40px; border-radius: 12px; flex: none; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}

/* ---------- Stats ---------- */

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.stat .value { font-size: 1.6rem; font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat .label { font-size: .78rem; color: var(--muted); font-weight: 600; margin-top: 4px; }

.trend { display: flex; align-items: center; gap: 14px; padding: 14px 16px; }
.trend .grow { flex: 1; min-width: 0; }
.sparkline { width: 110px; height: 36px; flex: none; color: var(--accent); overflow: visible; }

/* ---------- Quick log tiles ---------- */

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile {
  display: flex; flex-direction: column; gap: 10px; padding: 14px; min-height: 108px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); color: var(--text); transition: transform .08s ease, border-color .15s;
}
.tile:hover { text-decoration: none; border-color: var(--accent); }
.tile:active { transform: scale(.98); }
.tile .tile-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.tile b { display: block; line-height: 1.25; }
.tile span { color: var(--muted); font-size: .82rem; }
.tile.tile-add { border-style: dashed; box-shadow: none; background: transparent; color: var(--muted); justify-content: center; align-items: center; text-align: center; }

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

.field { display: flex; flex-direction: column; gap: 6px; }
.field label:not(.checkbox):not(.file-drop), .label { font-size: .875rem; font-weight: 600; }
.input::placeholder { color: var(--muted); opacity: .45; }
.field .hint { font-size: .8rem; color: var(--muted); }
.field-error { font-size: .82rem; color: var(--danger); font-weight: 550; }

.input, .select, .textarea {
  width: 100%; min-height: 48px; padding: 11px 14px;
  font: inherit; font-size: 16px; /* 16px stops iOS from zooming */
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
  appearance: none; -webkit-appearance: none;
}
.textarea { min-height: 160px; resize: vertical; line-height: 1.5; }
.select {
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%238a93a2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
}
.input[aria-invalid="true"] { border-color: var(--danger); }
.input-points { font-size: 2.2rem; font-weight: 750; text-align: center; min-height: 72px; font-variant-numeric: tabular-nums; }

.checkbox { display: flex; align-items: center; gap: 10px; font-weight: 550; cursor: pointer; min-height: 44px; }
.checkbox input { width: 22px; height: 22px; accent-color: var(--accent); }

.file-drop {
  display: flex; align-items: center; gap: 14px; padding: 14px; cursor: pointer;
  border: 1.5px dashed var(--border); border-radius: var(--radius-sm); color: var(--muted);
}
.file-drop:hover { border-color: var(--accent); color: var(--accent); }
.file-drop input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.file-drop img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; }

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

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 12px; border: 1px solid transparent;
  font: inherit; font-weight: 650; cursor: pointer; text-decoration: none !important;
  transition: background .15s, transform .08s, border-color .15s; white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-strong); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-ghost:hover { background: var(--accent-soft); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: .875rem; border-radius: 10px; }
.btn-icon { width: 44px; min-height: 44px; padding: 0; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }

/* ---------- Chips / segmented ---------- */

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; margin: 0 -2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 8px 14px; border-radius: 999px; font-weight: 600; font-size: .9rem;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); cursor: pointer;
}
.chip:hover { text-decoration: none; border-color: var(--accent); }
.chip[aria-current="true"], .chip.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* ---------- Alerts / misc ---------- */

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); font-weight: 550; font-size: .92rem; }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-info { background: var(--accent-soft); color: var(--accent-strong); }

.notice { border-left: 4px solid var(--accent); }
.notice .notice-text { white-space: pre-line; }
.news h2 { font-size: 1.15rem; }
.news-body { white-space: pre-line; overflow-wrap: anywhere; }
.schedule-item .sub { white-space: normal; }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: .72rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-success { background: var(--success-soft); color: var(--success); }

/* Always dark on white, also in dark mode, or phone cameras won't read it. */
.qr { width: min(100%, 300px); aspect-ratio: 1; background: #fff; border-radius: var(--radius-sm); padding: 4px; }
.qr svg { display: block; width: 100%; height: 100%; }

.empty { text-align: center; padding: 36px 20px; color: var(--muted); }
.empty .icon { color: var(--accent); margin-bottom: 8px; }
.empty b { display: block; color: var(--text); font-size: 1.05rem; margin-bottom: 4px; }

.detail-list { display: grid; grid-template-columns: auto 1fr; gap: 10px 20px; margin: 0; }
.detail-list dt { color: var(--muted); font-weight: 550; }
.detail-list dd { margin: 0; font-weight: 600; text-align: right; }

.photo { display: block; width: 100%; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2); }

.copy-field { display: flex; gap: 8px; }
.copy-field .input { font-size: .85rem; min-height: 44px; }

table.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 10px 16px; border-bottom: 1px solid var(--border); }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table tfoot td { border-top: 1px solid var(--border); border-bottom: 0; }
.table-scroll { overflow-x: auto; }

/* ---------- Auth pages ---------- */

.auth {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
  background:
    radial-gradient(1200px 500px at 50% -10%, var(--accent-soft), transparent 70%),
    var(--bg);
}
.auth-card { width: 100%; max-width: 400px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 28px; text-align: center; }
.auth-brand .brand-mark { width: 60px; height: 60px; border-radius: 18px; box-shadow: var(--shadow-lg); }
.auth-brand h1 { font-size: 1.5rem; }
.auth-footer { text-align: center; margin-top: 20px; font-size: .92rem; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 20px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: .9rem;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
