/* ==========================================================================
   Judo Tournament — public app styles (mobile-first)
   ========================================================================== */

:root {
  --c-bg: #f8fafc;
  --c-surface: #ffffff;
  --c-border: #e2e8f0;
  --c-text: #0f172a;
  --c-text-muted: #64748b;
  --c-primary: #0f172a;
  --c-primary-hover: #1e293b;
  --c-accent: #dc2626;       /* judo-red */
  --c-accent-hover: #b91c1c;
  --c-success: #059669;
  --c-disabled-bg: #f1f5f9;
  --c-disabled-text: #94a3b8;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --header-h: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

/* Header ─────────────────────────────────────────────────────────── */

.app-header {
  background: var(--c-primary);
  color: white;
  height: var(--header-h);
  position: sticky;
  top: 0;
  z-index: 10;
  padding-top: env(safe-area-inset-top);
}

.header-inner {
  max-width: 720px;
  margin: 0 auto;
  height: var(--header-h);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  color: white;
  letter-spacing: -0.01em;
  min-width: 0;
  flex: 1;
  text-align: left;
}

.header-logo img {
  height: 32px;
  width: auto;
  max-width: 32px;
  object-fit: contain;
  border-radius: 6px;
  background: white;
  padding: 2px;
}

#event-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lang-switcher {
  display: flex;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 100px;
  padding: 3px;
  flex-shrink: 0;
}

.lang-btn {
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
  border-radius: 100px;
  letter-spacing: 0.04em;
  transition: all 0.15s ease;
}

.lang-btn.active {
  background: white;
  color: var(--c-primary);
}

/* Main ───────────────────────────────────────────────────────────── */

#app {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 48px;
  padding-bottom: calc(48px + env(safe-area-inset-bottom));
}

.screen-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 8px 0 20px;
  color: var(--c-text);
}

.screen-subtitle {
  font-size: 14px;
  color: var(--c-text-muted);
  margin: -16px 0 20px;
}

/* Choice cards (used for age, gender, weight selection) ──────────── */

.choice-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.choice-list.two-col {
  grid-template-columns: 1fr 1fr;
}

.choice-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  font-size: 17px;
  font-weight: 600;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--c-text);
  transition: transform 0.1s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  width: 100%;
  box-shadow: var(--shadow-sm);
}

.choice-card:active {
  transform: scale(0.98);
  background: #f8fafc;
}

.choice-card .arrow {
  flex-shrink: 0;
  color: var(--c-text-muted);
  font-size: 20px;
  line-height: 1;
}

.choice-card.gender-card {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 28px 16px;
  gap: 8px;
  font-size: 18px;
}

.choice-card.gender-card .icon {
  font-size: 32px;
  margin-bottom: 4px;
}

.choice-card.weight-card {
  font-variant-numeric: tabular-nums;
}

/* Back button ────────────────────────────────────────────────────── */

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 500;
  color: var(--c-text-muted);
  padding: 8px 0;
  margin-bottom: 8px;
  margin-left: -4px;
}

.back-btn:active { color: var(--c-text); }

.back-btn .chev { font-size: 18px; line-height: 1; }

/* Detail page (weight category info) ─────────────────────────────── */

.detail-header {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.detail-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 100px;
  background: #f1f5f9;
  color: var(--c-text-muted);
}

.tag.tag-gender { background: #fef2f2; color: var(--c-accent); }

.detail-weight {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  margin: 0;
}

/* Document buttons ───────────────────────────────────────────────── */

.doc-buttons {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.doc-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  border-radius: var(--radius-lg);
  text-decoration: none;
  font-weight: 600;
  font-size: 16px;
  text-align: left;
  transition: transform 0.1s ease, box-shadow 0.15s ease;
  border: 1px solid transparent;
  width: 100%;
  font-family: inherit;
}

.doc-btn:active { transform: scale(0.98); }

.doc-btn.schedule {
  background: var(--c-primary);
  color: white;
  box-shadow: var(--shadow-md);
}

.doc-btn.schedule:active { background: var(--c-primary-hover); }

.doc-btn.result {
  background: var(--c-accent);
  color: white;
  box-shadow: var(--shadow-md);
}

.doc-btn.result:active { background: var(--c-accent-hover); }

.doc-btn.disabled {
  background: var(--c-disabled-bg);
  color: var(--c-disabled-text);
  border-color: var(--c-border);
  box-shadow: none;
  cursor: not-allowed;
  pointer-events: none;
}

.doc-btn .doc-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 22px;
}

.doc-btn.disabled .doc-icon {
  background: rgba(148, 163, 184, 0.15);
}

.doc-btn .doc-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.doc-btn .doc-title { font-size: 16px; font-weight: 600; }
.doc-btn .doc-sub   { font-size: 12px; opacity: 0.85; font-weight: 400; }

.doc-btn .arrow-out {
  margin-left: auto;
  font-size: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}

/* Loader & states ────────────────────────────────────────────────── */

.loader {
  display: flex;
  justify-content: center;
  padding: 80px 0;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--c-border);
  border-top-color: var(--c-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.error-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--c-text-muted);
}

.error-state button {
  margin-top: 16px;
  padding: 10px 20px;
  background: var(--c-primary);
  color: white;
  border-radius: 100px;
  font-weight: 600;
  font-size: 14px;
}

/* Responsive — slightly larger on tablet+ ────────────────────────── */

@media (min-width: 600px) {
  .choice-list { gap: 12px; }
  .choice-list.two-col { gap: 16px; }
  #app { padding: 32px 24px 64px; }
  .screen-title { font-size: 26px; }
}
