/* Reusable components: buttons, forms, cards, panels, tables, tabs, pills,
   toasts, modals, player, and certificate chrome. */

/* ── BUTTONS ──────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  background: var(--gold);
  color: var(--black);
  font-family: inherit;
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: var(--track-btn);
  text-transform: uppercase;
  padding: 11px 20px;
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--gold-bright); border-color: var(--gold-bright); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-ghost { background: transparent; color: var(--text-dim); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); border-color: var(--border-gold); }

.btn-outline { background: transparent; color: var(--gold); border-color: var(--border-gold); }
.btn-outline:hover:not(:disabled) { background: var(--gold-wash); color: var(--gold-bright); }

.btn-danger { background: transparent; color: var(--bad); border-color: rgba(224, 112, 112, 0.32); }
.btn-danger:hover:not(:disabled) { background: var(--bad-wash); color: var(--bad); border-color: var(--bad); }

.btn-sm { padding: 7px 13px; font-size: 9px; }
.btn-block { width: 100%; }

.icon-btn {
  background: none;
  border: none;
  color: var(--text-mute);
  font-size: 22px;
  line-height: 1;
  padding: var(--sp-1) var(--sp-2);
  cursor: pointer;
  transition: color var(--transition);
}
.icon-btn:hover { color: var(--text); }

.link-btn {
  background: none;
  border: none;
  color: var(--gold);
  font: inherit;
  font-size: var(--fs-sm);
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.link-btn:hover { color: var(--gold-bright); }

/* ── FORMS ────────────────────────────────────────────────────────────────── */

.field { margin-bottom: var(--sp-4); }
.field > .label { margin-bottom: var(--sp-2); }
.field-hint { margin-top: var(--sp-2); font-size: var(--fs-sm); color: var(--text-mute); }
.field-error { margin-top: var(--sp-2); font-size: var(--fs-sm); color: var(--bad); }

input[type='text'], input[type='email'], input[type='password'], input[type='number'],
input[type='url'], input[type='date'], input[type='search'], textarea, select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: var(--fs-base);
  font-weight: 300;
  padding: 10px 12px;
  outline: none;
  transition: border-color var(--transition);
}
input:focus, textarea:focus, select:focus { border-color: var(--border-gold); }
input::placeholder, textarea::placeholder { color: var(--text-mute); }
input:disabled, textarea:disabled, select:disabled { opacity: 0.5; cursor: not-allowed; }

textarea { min-height: 88px; resize: vertical; line-height: 1.6; }

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-mute) 50%),
                    linear-gradient(135deg, var(--text-mute) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}

.checkbox { display: flex; gap: var(--sp-2); align-items: flex-start; cursor: pointer; }
.checkbox input { width: auto; margin-top: 3px; accent-color: var(--gold); }
.checkbox span { font-size: var(--fs-sm); color: var(--text-dim); }

/* ── PANELS & CARDS ───────────────────────────────────────────────────────── */

.panel {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  margin-bottom: var(--sp-4);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
  margin-bottom: var(--sp-4);
}
.panel-head h3 {
  font-size: var(--fs-sm);
  font-weight: 700;
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--gold);
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-4);
  transition: border-color var(--transition), transform var(--transition);
}
.card-link { cursor: pointer; }
.card-link:hover { border-color: var(--border-gold); transform: translateY(-2px); }
.card h4 { margin-bottom: var(--sp-1); }
.card-meta { font-size: var(--fs-sm); color: var(--text-mute); }
.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-top: var(--sp-4);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border);
}
.card-price { font-size: var(--fs-md); font-weight: 700; color: var(--gold); }

/* Compact list row — used for videos, assignments, roster entries. */
.item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-2);
}
.item-title { font-size: var(--fs-base); font-weight: 500; }
.item-sub { font-size: var(--fs-sm); color: var(--text-mute); }

/* ── KPI TILES ────────────────────────────────────────────────────────────── */

.kpi {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-left: 2px solid var(--gold);
  border-radius: var(--radius);
  padding: var(--sp-4);
}
.kpi-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--text-mute);
  margin-bottom: var(--sp-2);
}
.kpi-value { font-size: var(--fs-xl); font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi-sub { margin-top: var(--sp-2); font-size: var(--fs-sm); color: var(--text-mute); }

/* ── TABS ─────────────────────────────────────────────────────────────────── */

.tabs {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin-bottom: var(--sp-5);
}
.tab {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-family: inherit;
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  padding: 10px 16px;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
}
.tab:hover { color: var(--text); border-color: var(--border-gold); }
.tab[aria-selected='true'] { color: var(--gold); border-color: var(--gold); background: var(--gold-wash); }
.tab-count {
  display: inline-block;
  margin-left: var(--sp-2);
  padding: 1px 6px;
  border-radius: 8px;
  background: var(--surface-3);
  font-size: 9px;
  color: var(--text-dim);
}

/* ── TABLES ───────────────────────────────────────────────────────────────── */

.table-scroll { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--text-mute);
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: var(--sp-3);
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-base);
  vertical-align: middle;
}
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.actions { white-space: nowrap; text-align: right; }
td.actions .btn { margin-left: var(--sp-1); }

/* ── PILLS ────────────────────────────────────────────────────────────────── */

.pill {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-mute);
  white-space: nowrap;
}
.pill-ok { color: var(--ok); border-color: rgba(110, 203, 140, 0.3); background: var(--ok-wash); }
.pill-warn { color: var(--warn); border-color: rgba(224, 188, 106, 0.3); background: var(--warn-wash); }
.pill-bad { color: var(--bad); border-color: rgba(224, 112, 112, 0.3); background: var(--bad-wash); }
.pill-mute { color: var(--text-mute); }

/* ── BANNERS ──────────────────────────────────────────────────────────────── */

.banner {
  display: flex;
  gap: var(--sp-3);
  align-items: center;
  flex-wrap: wrap;
  border: 1px solid var(--border-gold);
  border-left-width: 2px;
  border-radius: var(--radius);
  background: var(--gold-wash);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-4);
  font-size: var(--fs-sm);
}
.banner-bad { border-color: var(--bad); background: var(--bad-wash); }
.banner-ok { border-color: var(--ok); background: var(--ok-wash); }
.banner .grow { min-width: 200px; }

/* ── EMPTY & SKELETON ─────────────────────────────────────────────────────── */

.empty {
  padding: var(--sp-7) var(--sp-4);
  text-align: center;
  color: var(--text-mute);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
}
.empty p { font-size: var(--fs-base); color: var(--text-dim); margin-bottom: var(--sp-1); }
.empty span { font-size: var(--fs-sm); }

.skeleton { display: flex; flex-direction: column; gap: var(--sp-2); }
.skeleton-row {
  height: 46px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface-1) 25%, var(--surface-3) 50%, var(--surface-1) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── PROGRESS ─────────────────────────────────────────────────────────────── */

.progress { height: 4px; background: var(--surface-3); border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--gold); transition: width 300ms ease; }

/* ── TOASTS ───────────────────────────────────────────────────────────────── */

.toast-host {
  position: fixed;
  bottom: var(--sp-5);
  right: var(--sp-5);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  pointer-events: none;
  max-width: min(360px, calc(100vw - 2 * var(--sp-5)));
}
.toast {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 2px solid var(--gold);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: var(--fs-base);
  padding: var(--sp-3) var(--sp-4);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 300ms ease, transform 300ms ease;
}
.toast.is-in { opacity: 1; transform: translateY(0); }
.toast-success { border-left-color: var(--ok); }
.toast-error { border-left-color: var(--bad); }

/* ── MODAL ────────────────────────────────────────────────────────────────── */

.modal-host { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: var(--sp-4); }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.72); backdrop-filter: blur(3px); }
.modal {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--surface-1);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.modal-wide { max-width: 820px; }
.modal-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: var(--fs-md); }
.modal-body { padding: var(--sp-5); }
.modal-text { color: var(--text-dim); margin-bottom: var(--sp-5); }
.modal-actions { display: flex; gap: var(--sp-2); justify-content: flex-end; margin-top: var(--sp-5); }

/* ── LESSON PLAYER ────────────────────────────────────────────────────────── */

/* ── LOCKED LESSON PLAYER ─────────────────────────────────────────────────
   Layer order matters: iframe (1) < mask (2) < catcher (3) < big play (4) <
   control bar (5). The catcher spans the whole frame so no click ever reaches
   YouTube; the bar sits above it so our own controls still work. */

.cp {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  outline: none;
}
.cp:focus-visible { border-color: var(--gold); }
.cp:fullscreen { border: 0; border-radius: 0; aspect-ratio: auto; width: 100%; height: 100%; }

.cp-frame { position: absolute; inset: 0; z-index: 1; }
.cp-frame iframe { width: 100%; height: 100%; border: 0; display: block; }

/* Opaque cover. YouTube paints its title/channel facade before first play and a
   suggestion end-screen after the video finishes, both INSIDE the cross-origin
   iframe — those pixels can't be styled from here, so they get painted over. */
.cp-mask {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

.cp-catch { position: absolute; inset: 0; z-index: 3; cursor: pointer; }

.cp-big {
  position: relative;
  z-index: 4;
  width: 66px;
  height: 66px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--border-gold);
  background: rgba(201, 168, 76, 0.14);
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}
.cp-big:hover { background: rgba(201, 168, 76, 0.26); transform: scale(1.05); }
.cp-big svg { width: 26px; height: 26px; fill: var(--cream); }

.cp-bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 22px var(--sp-3) var(--sp-2);
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.86) 62%);
  opacity: 0;
  transition: opacity var(--transition);
}
.cp:hover .cp-bar, .cp:focus-within .cp-bar { opacity: 1; }

.cp-btn {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
.cp-btn svg { width: 18px; height: 18px; fill: var(--cream); }
.cp-btn:hover svg { fill: var(--gold); }

.cp-time {
  flex: 0 0 auto;
  font-size: var(--fs-xs);
  color: var(--cream);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cp-seek, .cp-vol {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: rgba(245, 240, 232, 0.28);
  outline: none;
  cursor: pointer;
  padding: 0;
}
.cp-seek { flex: 1; min-width: 60px; }
.cp-vol { flex: 0 0 68px; }
.cp-seek::-webkit-slider-thumb, .cp-vol::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--gold);
  cursor: pointer;
}
.cp-seek::-moz-range-thumb, .cp-vol::-moz-range-thumb {
  width: 12px; height: 12px;
  border: none;
  border-radius: 50%;
  background: var(--gold);
  cursor: pointer;
}

@media (max-width: 560px) {
  .cp-vol { display: none; }
}

.player-empty {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  background: var(--surface-1);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-mute);
  text-align: center;
  padding: var(--sp-5);
}

.lesson {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  text-align: left;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-2);
  cursor: pointer;
  transition: all var(--transition);
}
.lesson:hover:not(:disabled) { border-color: var(--border-gold); background: var(--surface-2); }
.lesson[aria-current='true'] { border-color: var(--gold); background: var(--gold-wash); }
.lesson:disabled { opacity: 0.55; cursor: not-allowed; }
.lesson-num {
  flex: 0 0 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-gold);
  border-radius: 50%;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--gold);
}
.lesson-title { flex: 1; min-width: 0; font-size: var(--fs-base); }
.lesson-lock { font-size: var(--fs-sm); color: var(--text-mute); }

/* ── SIGNATURE PAD ────────────────────────────────────────────────────────── */

.sig-pad {
  width: 100%;
  height: 150px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  touch-action: none;
  cursor: crosshair;
  display: block;
}
.sig-preview {
  max-height: 90px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-2);
}

/* Signature placement stage — a 1:1 slice of the certificate's signature block.
   The sizes below are the certificate's own: it lays the signature out in a
   2970-unit space scaled by R = 1123/2970, capped at 760×260 of those units, which
   is 287×98 real pixels on the card. Reproducing that here (rather than eyeballing
   a preview) is the whole point: what gets nudged is what gets printed.
   The cream background matters too — ink that reads fine on the dark panel can
   vanish against the card. */
.sig-stage {
  width: 320px;
  max-width: 100%;
  padding: var(--sp-3) var(--sp-3) var(--sp-2);
  background: #F6F3EC;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
}
.sig-stage-area {
  position: relative;
  height: 104px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
}
.sig-stage-img { display: block; max-width: none; }
.sig-stage-empty {
  font-size: var(--fs-xs);
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: rgba(13, 13, 13, 0.30);
  align-self: center;
}
.sig-stage-rule { height: 1px; background: rgba(13, 13, 13, 0.35); margin: 4px 0 6px; }
.sig-stage-name { font-size: 12px; font-weight: 700; color: #0D0D0D; }
.sig-stage-role {
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(13, 13, 13, 0.55);
}

.sig-controls { display: grid; gap: var(--sp-2); margin-top: var(--sp-3); }
.sig-controls label {
  display: grid;
  grid-template-columns: 74px 1fr 46px;
  gap: var(--sp-2);
  align-items: center;
  font-size: var(--fs-xs);
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--text-dim);
}
.sig-controls input[type='range'] { width: 100%; accent-color: var(--gold); }
.sig-controls span { font-size: var(--fs-sm); color: var(--text-mute); text-align: right; }

/* ── CERTIFICATE ──────────────────────────────────────────────────────────── */

.cert-shell { background: var(--surface-1); border: 1px solid var(--border-gold); border-radius: var(--radius-lg); padding: var(--sp-4); }
.cert-shell img { border-radius: var(--radius); }
.cert-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: var(--fs-sm);
  letter-spacing: 0.08em;
  color: var(--gold);
}
