/* =========================================================
   Judolingo — Design tokens
   Palette: Ink #14181F (mat-at-night), Surface #1E2430,
            Paper #ECE8DD (obi text), Gold #C99A3B (kyu belt),
            Moss #4B7A5A (go/confirm), Belt-red #B4463A (admin/alert)
   Display: "Big Shoulders Display" (condensed, mat-signage feel)
   Body:    "Inter"
   Mono:    "IBM Plex Mono" (times, counts, data)
   Signature: the "obi" belt-stripe divider + rank-colored dots
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Big+Shoulders+Display:wght@600;700;800&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root{
  --ink:        #14181f;
  --ink-2:      #1b212b;
  --surface:    #1e2430;
  --surface-2:  #262e3c;
  --border:     #333c4d;
  --paper:      #ece8dd;
  --paper-dim:  #a9a89f;
  --gold:       #c99a3b;
  --gold-ink:   #241c0c;
  --moss:       #4b7a5a;
  --moss-ink:   #0d1a12;
  --red:        #b4463a;
  --red-ink:    #2a0f0c;
  --white-belt: #f4f2ea;
  --yellow-belt:#e0b93f;
  --orange-belt:#d97b34;
  --green-belt: #4b7a5a;
  --blue-belt:  #3d6fa6;
  --brown-belt: #7a5230;
  --black-belt: #17181b;

  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --nav-h: 64px;
  --font-display: 'Big Shoulders Display', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

*{ box-sizing: border-box; }
html,body{ height:100%; }
body{
  margin:0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
h1,h2,h3,.display{
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: .01em;
  text-transform: uppercase;
  color: var(--paper);
  margin: 0;
}
.mono{ font-family: var(--font-mono); }
a{ color: inherit; }
button{ font-family: inherit; }

/* focus visibility */
:focus-visible{ outline: 2px solid var(--gold); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce){
  *{ animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ---------- App shell ---------- */
#app{
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.topbar{
  position: sticky; top:0; z-index: 40;
  display:flex; align-items:center; justify-content:space-between;
  padding: 14px 18px;
  background: linear-gradient(180deg, var(--ink) 70%, transparent);
  backdrop-filter: blur(6px);
}
.brand{
  display:flex; align-items:center; gap:10px;
}
.brand-mark{
  width:34px; height:34px; border-radius: 8px;
  background: conic-gradient(from 220deg, var(--white-belt) 0 20%, var(--yellow-belt) 20% 40%, var(--orange-belt) 40% 55%, var(--green-belt) 55% 70%, var(--blue-belt) 70% 85%, var(--black-belt) 85% 100%);
  flex: none;
}
.brand-logo-badge{
  width:40px; height:40px; flex:none; border-radius:8px;
  background: var(--paper); display:flex; align-items:center; justify-content:center; padding:5px;
}
.brand-logo-badge img{ width:100%; height:100%; object-fit:contain; }

.brand-title{ font-family: var(--font-display); font-size: 22px; letter-spacing: .02em; }
.brand-title small{ display:block; font-family: var(--font-mono); font-size: 10px; letter-spacing: .18em; color: var(--paper-dim); text-transform: uppercase; }

.lang-switch{
  display:flex; border:1px solid var(--border); border-radius: 999px; overflow:hidden;
  font-family: var(--font-mono); font-size: 12px;
}
.lang-switch button{
  background: transparent; color: var(--paper-dim); border:none; padding: 7px 12px; cursor:pointer;
}
.lang-switch button.active{ background: var(--gold); color: var(--gold-ink); font-weight: 700; }

/* Obi divider — the signature element: a belt-stripe rule */
.obi{
  height: 6px; width: 100%; flex: none;
  background: linear-gradient(90deg,
    var(--white-belt) 0 14%, var(--yellow-belt) 14% 28%, var(--orange-belt) 28% 42%,
    var(--green-belt) 42% 56%, var(--blue-belt) 56% 70%, var(--brown-belt) 70% 84%, var(--black-belt) 84% 100%);
}

main{ flex:1; padding: 18px 16px calc(var(--nav-h) + 28px); max-width: 720px; width:100%; margin: 0 auto; }

/* ---------- Bottom nav (mobile) / rail (desktop) ---------- */
.nav{
  position: fixed; left:0; right:0; bottom:0; z-index: 30;
  height: var(--nav-h);
  display:flex; justify-content: space-around; align-items:center;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav button{
  background:none; border:none; color: var(--paper-dim);
  display:flex; flex-direction:column; align-items:center; gap:4px;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .06em; text-transform: uppercase;
  cursor:pointer; padding: 6px 10px; border-radius: var(--radius-sm);
}
.nav button .ic{ display:flex; align-items:center; justify-content:center; position:relative; }
.nav button.active{ color: var(--gold); }

.nav-badge-dot{
  position:absolute; top:-3px; right:-5px; width:8px; height:8px; border-radius:50%;
  background: var(--red); border: 1.5px solid var(--surface);
  opacity:0; transform: scale(.4); transition: opacity .15s ease, transform .15s ease;
}
.nav-badge-dot.show{ opacity:1; transform: scale(1); }

/* ---------- Cards & primitives ---------- */
.card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card-head{ display:flex; align-items:baseline; justify-content:space-between; gap:10px; margin-bottom:8px; }
.eyebrow{ font-family: var(--font-mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); }
.muted{ color: var(--paper-dim); }
.tiny{ font-size: 12px; }

.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  border-radius: 999px; border: 1px solid transparent;
  padding: 11px 18px; font-weight: 700; font-size: 14px; cursor:pointer;
  font-family: var(--font-body);
  transition: transform .12s ease, filter .12s ease;
}
.btn:active{ transform: scale(.97); }
.btn-gold{ background: var(--gold); color: var(--gold-ink); }
.btn-gold:hover{ filter: brightness(1.08); }
.btn-moss{ background: var(--moss); color: #eafff1; }
.btn-red{ background: var(--red); color: #ffece9; }
.btn-ghost{ background: transparent; color: var(--paper); border-color: var(--border); }
.btn-block{ width:100%; }
.btn[disabled]{ opacity:.5; cursor:not-allowed; }

.pill{
  display:inline-flex; align-items:center; gap:6px;
  font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing:.06em;
  padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); color: var(--paper-dim);
}
.pill.joined{ background: rgba(75,122,90,.18); color:#9cd6ae; border-color: rgba(75,122,90,.4); }
.pill.admin{ background: rgba(180,70,58,.18); color:#f2a89e; border-color: rgba(180,70,58,.4); }
.pill.trainer{ background: rgba(201,154,59,.18); color:#e8c789; border-color: rgba(201,154,59,.4); }

input, textarea, select{
  width:100%; background: var(--ink-2); color: var(--paper);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 11px 12px; font-family: var(--font-body); font-size: 15px;
}
textarea{ min-height: 160px; resize: vertical; line-height:1.5; }
label{ display:block; font-family: var(--font-mono); font-size:11px; text-transform:uppercase; letter-spacing:.08em; color: var(--paper-dim); margin: 12px 0 6px; }
.field:first-child label{ margin-top:0; }

.session{
  display:flex; gap:12px; align-items:flex-start;
}
.session .when{
  flex: none; width: 58px; text-align:center; font-family: var(--font-mono);
  border-right: 1px solid var(--border); padding-right: 12px;
}
.session .when .wd{ font-size: 9px; font-family: var(--font-mono); text-transform:uppercase; letter-spacing:.06em; color: var(--paper-dim); margin-bottom:2px; }
.session .when .d{ font-size: 20px; font-weight:700; color: var(--gold); }
.session .when .m{ font-size: 10px; text-transform:uppercase; color: var(--paper-dim); }
.session .body{ flex:1; min-width:0; }
.session .title{ font-weight: 700; font-size: 16px; }
.session .time{ font-family: var(--font-mono); font-size: 12px; color: var(--paper-dim); margin-top:2px; }

.card.today{
  border-color: var(--gold);
  background: linear-gradient(180deg, rgba(201,154,59,.12), var(--surface) 60%);
  box-shadow: 0 0 0 1px var(--gold), var(--shadow);
}
.today-pill{
  background: var(--gold); color: var(--gold-ink); border-color: var(--gold);
  font-weight:700; vertical-align: middle;
}

.terms-box{
  white-space: pre-line; max-height: 240px; overflow-y:auto; line-height:1.5;
  border:1px solid var(--border); border-radius: var(--radius-sm); padding:12px;
  background: var(--ink-2); margin-top:8px;
}

.reply-box{ margin-top:14px; padding-top:12px; border-top: 1px solid var(--border); }
.reply-box textarea{ min-height:64px; font-size:14px; }
.reply-list{ margin-top:14px; display:flex; flex-direction:column; gap:8px; }
.reply-item{
  background: var(--ink-2); border:1px solid var(--border); border-radius: var(--radius-sm); padding:8px 10px;
}
.reply-author{ display:block; font-family: var(--font-mono); font-size:10px; text-transform:uppercase; letter-spacing:.06em; color: var(--gold); margin-bottom:2px; }
.reply-body{ font-size:13px; white-space:pre-line; }

.avatars{ display:flex; flex-wrap:wrap; gap:6px; margin-top:10px; }
.avatar{
  width:28px; height:28px; border-radius:50%; display:flex; align-items:center; justify-content:center;
  font-family: var(--font-mono); font-size:11px; font-weight:700; color: var(--ink);
  border: 2px solid var(--ink);
}
.avatar.me{ box-shadow: 0 0 0 2px var(--gold); }

.checkrow{
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.checkrow:last-child{ border-bottom:none; }
.switch{ position:relative; width:42px; height:24px; flex:none; }
.switch input{ opacity:0; width:100%; height:100%; margin:0; position:absolute; cursor:pointer; }
.switch .track{ position:absolute; inset:0; background: var(--border); border-radius:999px; transition:.15s; }
.switch .track:after{ content:''; position:absolute; width:18px; height:18px; border-radius:50%; background:var(--paper); top:3px; left:3px; transition:.15s; }
.switch input:checked + .track{ background: var(--moss); }
.switch input:checked + .track:after{ transform: translateX(18px); background:#eafff1; }

/* Notification banner (top-3, shown on every screen) */
.notif-banner{ display:flex; gap:8px; overflow-x:auto; margin: 0 0 16px; padding-bottom:2px; -webkit-overflow-scrolling:touch; }
.notif-chip{
  flex: none; max-width: 240px; text-align:left; cursor:pointer;
  background: var(--surface-2); border:1px solid var(--border); border-left: 3px solid var(--gold);
  border-radius: var(--radius-sm); padding: 8px 12px; color: var(--paper);
}
.notif-chip:hover{ filter: brightness(1.1); }
.notif-chip-cat{ display:block; font-family: var(--font-mono); font-size:10px; text-transform:uppercase; letter-spacing:.06em; color: var(--gold); }
.notif-chip-msg{ display:block; font-size:12px; margin-top:2px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

.notif-card.highlight{
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--gold), var(--shadow);
  animation: pulseHighlight 1.8s ease-in-out 1;
}
@keyframes pulseHighlight{
  0%{ background: rgba(201,154,59,.3); }
  100%{ background: var(--surface); }
}

.notifyCatCheckbox, .trainerCatCheckbox{ width:18px; height:18px; accent-color: var(--gold); cursor:pointer; flex:none; }

/* Collapsible section (e.g. the categories list on Alerts) */
.collapsible-head{
  width:100%; background:none; border:none; color: var(--paper); cursor:pointer;
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  padding: 2px 0; text-align:left;
}
.collapsible-head .chevron-wrap{ display:flex; align-items:center; gap:4px; flex:none; white-space:nowrap; }
.collapsible-head .chevron{ display:inline-block; transition: transform .18s ease; }
.collapsible-head.open .chevron{ transform: rotate(180deg); }
.collapsible-body{
  margin-top:10px; padding-top:10px; padding-right: 14px;
  border-top: 1px solid var(--border);
  max-height: 60vh; overflow-y:auto;
  scrollbar-gutter: stable;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.collapsible-body::-webkit-scrollbar{ width:8px; }
.collapsible-body::-webkit-scrollbar-track{ background: transparent; }
.collapsible-body::-webkit-scrollbar-thumb{ background: var(--border); border-radius: 999px; }
.collapsible-body::-webkit-scrollbar-thumb:hover{ background: var(--paper-dim); }

.terms-box, .collapsible-body{
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.terms-box::-webkit-scrollbar{ width:8px; }
.terms-box::-webkit-scrollbar-track{ background: transparent; }
.terms-box::-webkit-scrollbar-thumb{ background: var(--border); border-radius: 999px; }

.empty{ text-align:center; padding: 34px 12px; color: var(--paper-dim); }
.empty .ic{ font-size: 30px; margin-bottom:8px; }

.toast{
  position: fixed; left:50%; bottom: calc(var(--nav-h) + 16px); transform: translateX(-50%) translateY(20px);
  background: var(--surface-2); border:1px solid var(--border); color: var(--paper);
  padding: 10px 16px; border-radius: 999px; font-size: 13px; box-shadow: var(--shadow);
  opacity:0; pointer-events:none; transition: .2s ease; z-index: 50;
}
.toast.show{ opacity:1; transform: translateX(-50%) translateY(0); }

.loading-overlay{
  position: fixed; inset:0; z-index: 60;
  background: rgba(15,18,24,.55); backdrop-filter: blur(1.5px);
  display:flex; align-items:center; justify-content:center;
  opacity:0; pointer-events:none; transition: opacity .12s ease;
}
.loading-overlay.show{ opacity:1; pointer-events:all; }
.loading-overlay .spinner{
  width:42px; height:42px; border-radius:50%;
  border: 3px solid rgba(255,255,255,.18); border-top-color: var(--gold);
  animation: judolingo-spin .7s linear infinite;
}
@keyframes judolingo-spin{ to{ transform: rotate(360deg); } }

/* Door QR modal — deliberately above the loading overlay */
.door-modal{
  position: fixed; inset:0; z-index: 70;
  background: rgba(8,10,14,.92);
  display:flex; align-items:center; justify-content:center;
  padding: 20px;
}
.door-modal-card{
  background: var(--surface); border:1px solid var(--border); border-radius: var(--radius);
  padding: 22px; max-width: 440px; width:100%; box-shadow: var(--shadow);
}
.door-qr-wrap{
  background: #fff; border-radius: 12px; padding: 18px;
  display:flex; align-items:center; justify-content:center; min-height:220px;
}
.door-qr-wrap canvas{ display:block; max-width:100%; height:auto; }

.tabs{ display:flex; gap:6px; margin-bottom:14px; overflow-x:auto; padding-bottom:2px; }
.tabs button{
  flex:none; background: var(--surface); border:1px solid var(--border); color: var(--paper-dim);
  padding: 8px 14px; border-radius:999px; font-size:13px; cursor:pointer; font-weight:600;
}
.tabs button.active{ background: var(--gold); color: var(--gold-ink); border-color: var(--gold); }

.center-screen{
  min-height: 100%; display:flex; align-items:center; justify-content:center; padding: 24px;
}
.auth-card{ width:100%; max-width: 380px; }
.auth-card .obi{ margin: -16px -16px 16px; width: calc(100% + 32px); border-radius: var(--radius) var(--radius) 0 0; }

.perm-badge{ font-family: var(--font-mono); font-size:10px; }

::placeholder{ color: var(--paper-dim); opacity:.7; }

@media (min-width: 860px){
  .nav{
    top:0; bottom:0; left:0; right:auto; width: 220px; height:100%;
    flex-direction: column; justify-content:flex-start; align-items:stretch; gap:4px;
    padding: 90px 12px 12px; border-top:none; border-right: 1px solid var(--border);
  }
  .nav button{ flex-direction:row; justify-content:flex-start; gap:10px; font-size:12px; padding:10px 12px; }
  main{ margin-left: 220px; max-width: 760px; padding: 24px 28px 60px; }
  .topbar{ padding-left: 28px; }
}
