/* =====================================================================
   Orlando — Base + components
   Built only from tokens.css. Class names are the public API of the
   design system: modules may use them freely.
   ===================================================================== */

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: var(--t-body); line-height: 1.5;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { font-family: var(--font-display); line-height: 1.1; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: var(--t-h1); font-weight: 800; }
h2 { font-size: var(--t-h2); font-weight: 700; }
h3 { font-size: var(--t-h3); font-weight: 700; }
p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.label { font-size: var(--t-label); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; transition-delay: 0s !important; animation-duration: 0s !important; animation-delay: 0s !important; }
}

/* ---------- Layout ---------- */
.page {
  max-width: var(--page-max); margin: 0 auto; width: 100%;
  padding: var(--s5) max(var(--gutter), env(safe-area-inset-right, 0px)) var(--s7);
  display: flex; flex-direction: column; gap: var(--s5);
}
.stack { display: flex; flex-direction: column; gap: var(--s3); }
.row { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.spacer { flex: 1; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
  padding: max(env(safe-area-inset-top, 0px), var(--s2)) max(var(--gutter), env(safe-area-inset-right, 0px)) var(--s2);
}
.topbar .in { max-width: var(--page-max); margin: 0 auto; display: flex; align-items: center; gap: var(--s3); min-height: var(--tap); }
.topbar .title { font-family: var(--font-display); font-weight: 700; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

/* ---------- Brand mark ---------- */
.logo { display: inline-flex; align-items: center; gap: var(--s2); text-decoration: none; font-family: var(--font-display); font-weight: 800; font-size: 22px; letter-spacing: -0.02em; }
.logo .mark {
  width: 34px; height: 34px; border-radius: 10px; background: var(--brand); color: var(--brand-ink);
  display: grid; place-items: center; transform: rotate(-6deg); font-size: 20px; line-height: 1;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .12);
}
.logo.big { font-size: 40px; gap: var(--s3); }
.logo.big .mark { width: 58px; height: 58px; border-radius: 16px; font-size: 34px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: var(--tap); padding: 0 var(--s5); border-radius: var(--r-md);
  border: var(--border) solid var(--ink); background: var(--surface); color: var(--ink);
  font-weight: 700; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform var(--dur-fast) var(--ease-out), background-color var(--dur-fast), opacity var(--dur-fast);
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .35; cursor: default; transform: none; }
.btn.primary { background: var(--ink); color: var(--on-ink); }
.btn.accent { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--soft); }
.btn.danger { border-color: var(--err); color: var(--err); }
.btn.sm { min-height: 36px; padding: 0 var(--s3); font-size: var(--t-small); border-radius: var(--r-sm); }
.btn.lg { min-height: 60px; padding: 0 var(--s6); font-size: 19px; border-radius: var(--r-lg); }
.btn.icon { padding: 0; width: var(--tap); }
.btn.icon.sm { width: 36px; }
.btn svg { width: 22px; height: 22px; flex: none; }
.btn.sm svg { width: 18px; height: 18px; }

/* ---------- Icon ---------- */
.ico { width: 24px; height: 24px; display: inline-block; flex: none; vertical-align: middle; }

/* ---------- Card ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s5); box-shadow: var(--shadow-1); }
.card.flat { box-shadow: none; }
.card.inset { background: var(--soft); border: 0; box-shadow: none; }
a.card, button.card { display: block; text-align: left; width: 100%; text-decoration: none; cursor: pointer; transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast); }
a.card:hover, button.card:hover { box-shadow: var(--shadow-2); }
a.card:active, button.card:active { transform: scale(.985); }

/* ---------- Discipline tile ---------- */
.tile {
  --c: var(--d-matematica);
  position: relative; overflow: hidden; display: flex; flex-direction: column; gap: var(--s2); min-height: 210px;
  padding: var(--s5); border-radius: var(--r-xl); background: var(--c); color: #fff; text-decoration: none;
  box-shadow: var(--shadow-1); transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast);
}
.tile:hover { box-shadow: var(--shadow-2); }
.tile:active { transform: scale(.98); }
.tile .glyph { position: absolute; right: -10px; bottom: -28px; font-family: var(--font-display); font-weight: 800; font-size: 150px; line-height: 1; opacity: .16; pointer-events: none; }
.tile h2 { font-size: 30px; }
.tile .meta { font-size: var(--t-small); opacity: .9; }
.tile .spacer { min-height: var(--s5); }
.tile .go { align-self: flex-start; display: inline-flex; align-items: center; gap: var(--s1); background: rgba(255, 255, 255, .18); border-radius: var(--r-pill); padding: 6px 14px; font-weight: 700; font-size: var(--t-small); }

/* ---------- Module card ---------- */
.modcard, a.card.modcard { --c: var(--d-matematica); display: flex; gap: var(--s4); align-items: flex-start; }
.modcard .badge-ico {
  width: 64px; height: 64px; border-radius: var(--r-lg); background: color-mix(in srgb, var(--c) 14%, var(--surface));
  color: var(--c); display: grid; place-items: center; flex: none; font-family: var(--font-display); font-weight: 800; font-size: 32px;
}
.modcard .body { display: flex; flex-direction: column; gap: var(--s1); min-width: 0; flex: 1; }
.modcard h3 { font-size: 22px; }
.modcard .desc { color: var(--muted); font-size: var(--t-small); }
.modcard .foot { display: flex; align-items: center; gap: var(--s3); margin-top: var(--s2); flex-wrap: wrap; }

/* ---------- Lesson row ---------- */
.lessons { display: flex; flex-direction: column; gap: var(--s2); }
.lesson {
  display: flex; align-items: center; gap: var(--s4); min-height: 72px; padding: var(--s3) var(--s4);
  border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); text-decoration: none;
  transition: transform var(--dur-fast) var(--ease-out), border-color var(--dur-fast);
}
.lesson:hover { border-color: var(--ink); }
.lesson:active { transform: scale(.99); }
.lesson .n {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--soft); font-family: var(--font-display); font-weight: 800; font-size: 18px;
}
.lesson.done .n { background: var(--ok); color: #fff; }
.lesson .txt { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.lesson .t { font-family: var(--font-display); font-weight: 700; font-size: 19px; line-height: 1.2; }
.lesson .s { color: var(--muted); font-size: var(--t-small); }
.lesson .chev { color: var(--muted); flex: none; }

/* ---------- Badge / chip ---------- */
.badge { display: inline-flex; align-items: center; gap: var(--s1); padding: 3px 10px; border-radius: var(--r-pill); font-size: 13px; font-weight: 700; background: var(--soft); color: var(--muted); white-space: nowrap; }
.badge.brand { background: var(--brand); color: var(--brand-ink); }
.badge.ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.badge.err { background: color-mix(in srgb, var(--err) 14%, transparent); color: var(--err); }
.chip { display: inline-flex; align-items: center; min-height: 36px; padding: 0 var(--s3); border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--soft); font-size: var(--t-small); cursor: pointer; text-decoration: none; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }

/* ---------- Segmented control ---------- */
.segctl { display: inline-flex; border: var(--border) solid var(--ink); border-radius: var(--r-md); overflow: hidden; }
.segctl button { min-height: 44px; padding: 0 var(--s4); border: 0; background: var(--surface); font-weight: 700; font-size: var(--t-small); cursor: pointer; }
.segctl button + button { border-left: var(--border) solid var(--ink); }
.segctl button[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); }

/* ---------- Switch ---------- */
.switch { display: inline-flex; align-items: center; gap: var(--s3); cursor: pointer; min-height: var(--tap); }
.switch input { appearance: none; -webkit-appearance: none; margin: 0; width: 52px; height: 32px; border-radius: var(--r-pill); background: var(--line); position: relative; cursor: pointer; transition: background var(--dur); flex: none; }
.switch input::after { content: ""; position: absolute; left: 3px; top: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform var(--dur) var(--ease-spring); }
.switch input:checked { background: var(--ok); }
.switch input:checked::after { transform: translateX(20px); }

/* ---------- Fields ---------- */
.field { display: flex; flex-direction: column; gap: var(--s1); }
.field > label { font-size: 13px; font-weight: 700; color: var(--muted); }
.input, .select, .textarea {
  min-height: var(--tap); padding: 0 var(--s3); border-radius: var(--r-md); border: var(--border) solid var(--line);
  background: var(--soft); width: 100%;
}
.textarea { padding: var(--s3); min-height: 96px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--ink); outline: none; }
.input.num { font-family: var(--font-mono); font-weight: 700; }
.hint { font-size: 13px; color: var(--muted); }
.error { font-size: var(--t-small); color: var(--err); font-weight: 700; }

/* ---------- Progress ---------- */
.meter { height: 8px; border-radius: var(--r-pill); background: var(--line); overflow: hidden; }
.meter > i { display: block; height: 100%; width: calc(var(--v, 0) * 1%); background: var(--ok); border-radius: inherit; transition: width var(--dur-slow) var(--ease-out); }
.dots { display: flex; gap: 5px; }
.dots i { width: 22px; height: 6px; border-radius: 3px; background: var(--line); transition: background var(--dur); }
.dots i.on { background: var(--ink); }

/* ---------- Avatar ---------- */
.avatar {
  --c: var(--d-matematica);
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--c); color: #fff; font-family: var(--font-display); font-weight: 800; font-size: 19px;
}
.avatar.lg { width: 88px; height: 88px; font-size: 38px; }
.avatar.xl { width: 112px; height: 112px; font-size: 48px; }

/* ---------- Who are you? (profile picker) ---------- */
.profiles { display: flex; gap: var(--s5); justify-content: center; flex-wrap: wrap; }
.profile {
  display: flex; flex-direction: column; align-items: center; gap: var(--s3); padding: var(--s5) var(--s6);
  border-radius: var(--r-xl); border: var(--border) solid transparent; background: var(--surface); box-shadow: var(--shadow-1);
  cursor: pointer; min-width: 180px; transition: transform var(--dur-fast) var(--ease-out), border-color var(--dur-fast);
}
.profile:hover { border-color: var(--ink); }
.profile:active { transform: scale(.97); }
.profile .nm { font-family: var(--font-display); font-weight: 700; font-size: 24px; }

/* ---------- PIN pad ---------- */
.pin { display: flex; flex-direction: column; align-items: center; gap: var(--s5); }
.pindots { display: flex; gap: var(--s4); height: 22px; align-items: center; }
.pindots i { width: 18px; height: 18px; border-radius: 50%; border: var(--border) solid var(--ink); transition: background var(--dur-fast), transform var(--dur-fast) var(--ease-spring); }
.pindots i.on { background: var(--ink); transform: scale(1.1); }
.pindots.bad { animation: shake .45s; }
.pindots.bad i { border-color: var(--err); }
.pindots.bad i.on { background: var(--err); }
.pinpad { display: grid; grid-template-columns: repeat(3, 84px); gap: var(--s4); }
.key {
  height: 84px; border-radius: 50%; border: 0; background: var(--surface); box-shadow: var(--shadow-key), var(--shadow-1);
  font-family: var(--font-display); font-weight: 700; font-size: 32px; cursor: pointer; display: grid; place-items: center;
  touch-action: manipulation; user-select: none; -webkit-user-select: none; transition: transform 80ms, background 80ms;
}
.key:active, .key.press { transform: translateY(2px) scale(.96); background: var(--soft); box-shadow: 0 1px 0 var(--line); }
.key.blank { visibility: hidden; }
.key.fn { background: transparent; box-shadow: none; font-size: 15px; font-family: var(--font-body); color: var(--muted); }
.key svg { width: 28px; height: 28px; }
@keyframes shake { 10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(5px); } 30%, 50%, 70% { transform: translateX(-9px); } 40%, 60% { transform: translateX(9px); } }

/* ---------- Menu (popover) ---------- */
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 220px; padding: var(--s2);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-2);
  display: flex; flex-direction: column; animation: pop var(--dur) var(--ease-out);
}
.menu .who { padding: var(--s2) var(--s3) var(--s3); border-bottom: 1px solid var(--line); margin-bottom: var(--s1); }
.menu a, .menu button { display: flex; align-items: center; gap: var(--s3); min-height: 44px; padding: 0 var(--s3); border-radius: var(--r-sm); border: 0; background: none; text-decoration: none; cursor: pointer; text-align: left; font-weight: 700; font-size: var(--t-small); }
.menu a:hover, .menu button:hover { background: var(--soft); }
.menu svg { width: 20px; height: 20px; color: var(--muted); }

/* ---------- Toast ---------- */
.toasts { position: fixed; left: 50%; bottom: max(var(--s5), env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: var(--s2); align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: var(--on-ink); padding: var(--s3) var(--s5); border-radius: var(--r-pill); font-weight: 700; box-shadow: var(--shadow-2); animation: pop var(--dur) var(--ease-out); }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: var(--s7) var(--s5); color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: var(--s3); }
.empty .big { font-family: var(--font-display); font-weight: 800; font-size: 56px; color: var(--line); line-height: 1; }

/* ---------- Hero / greeting ---------- */
.hello { display: flex; flex-direction: column; gap: var(--s1); }
.hello h1 { font-size: var(--t-hero); }
.hello h1 em { font-style: normal; background: linear-gradient(transparent 62%, var(--brand) 62% 92%, transparent 92%); padding: 0 2px; }

/* ---------- Discipline header ---------- */
.dhead { --c: var(--d-matematica); border-radius: var(--r-xl); background: var(--c); color: #fff; padding: var(--s6) var(--s5); position: relative; overflow: hidden; }
.dhead .glyph { position: absolute; right: 10px; bottom: -40px; font-family: var(--font-display); font-weight: 800; font-size: 180px; opacity: .14; line-height: 1; }
.dhead .label { color: rgba(255, 255, 255, .85); }

/* ---------- Lesson player frame ---------- */
.player-shell { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--bg); }
.player-shell iframe { flex: 1; width: 100%; border: 0; background: var(--bg); }

/* ---------- Crumbs ---------- */
.crumbs { display: flex; align-items: center; gap: var(--s1); font-size: var(--t-small); color: var(--muted); flex-wrap: wrap; }
.crumbs a { text-decoration: none; font-weight: 700; }
.crumbs a:hover { color: var(--ink); }

@keyframes pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fadein { from { opacity: .5; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.view { animation: fadein var(--dur) var(--ease-out); }

@media (max-width: 600px) {
  .pinpad { grid-template-columns: repeat(3, 72px); gap: var(--s3); }
  .key { height: 72px; font-size: 28px; }
  .profile { min-width: 140px; padding: var(--s4) var(--s5); }
}

/* Gentle pulse to point at the next step (e.g. "next lesson" after finishing one) */
.nudge { animation: nudge 1.6s var(--ease-out) 3; }
@keyframes nudge { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--brand) 70%, transparent); } 50% { box-shadow: 0 0 0 10px transparent; } }
