/* Copyright (c) 2025-2026 William Chesher | MIT License
 * =============================================================================
 * profile.css — teenyverse profile + perk wallet (PRODUCTION)
 * Drop-in replacement for assets/css/pages/profile.css.
 *
 * Theme-aware: every surface/ink color reads an existing teenyverse.css token
 * (--accent, --bg-primary, --text-primary, --border-light, …) so the page
 * follows light / dark / color-scheme / curated themes with no overrides here.
 * Only tokens teenyverse.css does NOT define are added below (tier hues,
 * --radius, --mono, --font, --ease). Neon hues + --radius-sm already exist.
 * ========================================================================== */

:root {
  /* arc tier hues (additive — not in teenyverse.css) */
  --tier-explorer: #00e5d4;
  --tier-investigator: #00d4ff;
  --tier-analyst: #b14dff;
  --tier-scientist: #ffd23d;
  --tier-member: #2bff88;

  --radius: 12px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

/* lowercase section headings, matched to the rest of admin */
.profile main h1, .stack h2, .stack h3, .stack h4 { text-transform: lowercase; }

/* =============================================================================
 * PAGE STACK — single-column reading order:
 * hero → wallet → (appearance + account) → palette → notifications
 * ========================================================================== */
.stack { display: flex; flex-direction: column; gap: 22px; max-width: 1180px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }

/* shared card primitive */
.card {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 22px;
}
.card > h3 {
  margin: 0 0 16px; padding-bottom: 13px; font-size: 15px; font-weight: 650;
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; gap: 10px; color: var(--text-primary);
}
.card > h3 i { color: var(--accent); font-size: 14px; }
.card-desc { color: var(--text-muted); font-size: 13px; margin: -6px 0 16px; }

/* =============================================================================
 * IDENTITY HERO  (full-width anchor)
 * ========================================================================== */
.hero {
  position: relative; overflow: hidden;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--accent) 5%, transparent), transparent 60%),
    var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 26px 28px;
}
.hero::before { /* accent wash keyed to tier */
  content: ''; position: absolute; right: -60px; top: -80px; width: 360px; height: 280px;
  background: radial-gradient(circle, var(--tier-hue, var(--accent)), transparent 70%);
  opacity: 0.12; pointer-events: none;
}
.hero-top { display: flex; align-items: center; gap: 22px; position: relative; }
.emblem {
  position: relative; flex: 0 0 auto; width: 76px; height: 76px; border-radius: 20px;
  display: grid; place-items: center; font-size: 30px;
  color: var(--tier-hue, var(--accent));
  background: color-mix(in srgb, var(--tier-hue, var(--accent)) 14%, var(--bg-tertiary));
  border: 1.5px solid color-mix(in srgb, var(--tier-hue, var(--accent)) 55%, transparent);
  box-shadow: 0 0 22px color-mix(in srgb, var(--tier-hue, var(--accent)) 35%, transparent);
}
.emblem .ring { position: absolute; inset: -6px; border-radius: 24px; border: 1px solid color-mix(in srgb, var(--tier-hue, var(--accent)) 30%, transparent); }
.hero-id { flex: 1; min-width: 0; }
.hero-name { font-size: 23px; font-weight: 680; margin: 0 0 3px; letter-spacing: -0.02em; color: var(--text-primary); }
.hero-sub { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; color: var(--text-muted); font-size: 13px; }
.hero-sub .em { color: var(--text-secondary); }
.hero-sub .sep { opacity: 0.4; }
.tier-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 4px 12px 4px 9px; border-radius: 999px;
  font: 600 12px var(--font); text-transform: lowercase; margin-top: 9px; white-space: nowrap;
  color: var(--tier-hue, var(--accent));
  background: color-mix(in srgb, var(--tier-hue, var(--accent)) 13%, transparent);
  border: 1px solid color-mix(in srgb, var(--tier-hue, var(--accent)) 40%, transparent);
}
.tier-chip i { font-size: 11px; }
.hero-aside { flex: 0 0 auto; text-align: right; display: flex; flex-direction: column; gap: 4px; }
.hero-aside .pts { font: 700 26px/1 var(--mono); color: var(--text-primary); }
.hero-aside .pts-l { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.1em; }
@media (max-width: 560px) {
  .hero-top { flex-wrap: wrap; }
  .hero-aside { text-align: left; flex-direction: row; align-items: baseline; gap: 8px; width: 100%; margin-top: 4px; }
}

/* arc progress rail */
.arc { margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--border-light); }
.arc-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 8px; }
.arc-head .lbl { font: 600 11px var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-muted); }
.arc-head .next { font-size: 12.5px; color: var(--text-secondary); }
.arc-head .next b { color: var(--tier-next, var(--accent)); font-weight: 650; }
.arc-rail { position: relative; display: grid; grid-template-columns: repeat(5, 1fr); }
.arc-line { position: absolute; left: 8%; right: 8%; top: 17px; height: 2px; background: var(--border-default); border-radius: 2px; }
.arc-line-fill {
  position: absolute; left: 8%; top: 17px; height: 2px; border-radius: 2px; width: 0;
  background: linear-gradient(90deg, var(--tier-explorer), var(--tier-investigator));
  box-shadow: 0 0 8px var(--tier-investigator); transition: width 600ms var(--ease);
}
.arc-node { position: relative; display: flex; flex-direction: column; align-items: center; gap: 9px; z-index: 1; }
.arc-dot {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-size: 14px;
  background: var(--bg-tertiary); border: 2px solid var(--border-default); color: var(--text-disabled);
  transition: all 240ms var(--ease);
}
.arc-node .nm { font-size: 11.5px; color: var(--text-disabled); text-transform: lowercase; transition: color 240ms; }
.arc-node.done .arc-dot { color: var(--node-hue); border-color: color-mix(in srgb, var(--node-hue) 60%, transparent); background: color-mix(in srgb, var(--node-hue) 14%, var(--bg-tertiary)); }
.arc-node.done .nm { color: var(--text-secondary); }
.arc-node.current .arc-dot {
  color: var(--text-on-accent); background: var(--node-hue); border-color: var(--node-hue);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--node-hue) 22%, transparent), 0 0 18px color-mix(in srgb, var(--node-hue) 60%, transparent);
  transform: scale(1.12);
}
.arc-node.current .nm { color: var(--node-hue); font-weight: 650; }
@media (max-width: 560px) { .arc-node .nm { font-size: 9.5px; } }

@media (prefers-reduced-motion: reduce) {
  .arc-line-fill, .arc-dot, .acc-body, .acc-chev { transition: none; }
}

/* =============================================================================
 * PERK WALLET  (full-width centerpiece, student/advisor only)
 * ========================================================================== */
.wallet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; flex-wrap: wrap; gap: 8px; }
.wallet-head h2 { font-size: 19px; font-weight: 650; margin: 0; display: flex; align-items: center; gap: 11px; color: var(--text-primary); }
.wallet-head h2 i { color: var(--accent); font-size: 17px; }
.wallet-head .tally { font: 500 12.5px var(--mono); color: var(--text-muted); }
.wallet-head .tally b { color: var(--accent); }
.wallet-sub { color: var(--text-muted); font-size: 13px; margin: 6px 0 18px; }

.accordions { display: flex; flex-direction: column; gap: 12px; }
.acc {
  background: var(--bg-primary); border: 1px solid var(--border-light); border-radius: var(--radius);
  overflow: hidden; transition: border-color 200ms var(--ease);
}
.acc.open { border-color: color-mix(in srgb, var(--cat-hue, var(--accent)) 40%, var(--border-light)); }
.acc-head {
  display: flex; align-items: center; gap: 14px; padding: 15px 18px; cursor: pointer; user-select: none;
  width: 100%; text-align: left; background: transparent; border: 0; color: inherit; font: inherit;
  transition: background 160ms var(--ease);
}
.acc-head:hover { background: var(--bg-hover); }
.acc-head:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.acc-ico {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; font-size: 16px;
  color: var(--cat-hue, var(--accent));
  background: color-mix(in srgb, var(--cat-hue, var(--accent)) 13%, transparent);
  border: 1px solid color-mix(in srgb, var(--cat-hue, var(--accent)) 32%, transparent);
}
.acc-titles { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.acc-name { font-size: 14.5px; font-weight: 600; text-transform: lowercase; color: var(--text-primary); }
.acc-meta { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.acc-count {
  font: 600 11px var(--mono); padding: 3px 9px; border-radius: 999px; color: var(--cat-hue, var(--accent));
  background: color-mix(in srgb, var(--cat-hue, var(--accent)) 12%, transparent);
}
.acc-chev { color: var(--text-muted); transition: transform 240ms var(--ease); font-size: 13px; transform: rotate(-90deg); }
.acc.open .acc-chev { transform: rotate(90deg); }
.acc-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 280ms var(--ease); }
.acc.open .acc-body { grid-template-rows: 1fr; }
.acc-body-inner { overflow: hidden; }
.acc-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 12px;
  padding: 4px 18px 18px;
}

/* perk tile */
.perk {
  position: relative; display: flex; flex-direction: column; gap: 11px;
  background: var(--bg-tertiary); border: 1px solid var(--border-light); border-radius: var(--radius-sm);
  padding: 14px;
}
.perk-top { display: flex; align-items: flex-start; gap: 11px; }
.perk-emoji {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-size: 15px;
  color: var(--cat-hue, var(--accent)); background: color-mix(in srgb, var(--cat-hue, var(--accent)) 12%, transparent);
}
.perk-h { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.perk-name { font-size: 13.5px; font-weight: 600; color: var(--text-primary); }
.perk-note { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; line-height: 1.35; }
.granted {
  display: inline-flex; align-items: center; gap: 4px; font: 600 9.5px var(--mono); letter-spacing: 0.06em;
  text-transform: uppercase; padding: 2px 7px; border-radius: 5px; margin-top: 6px;
  color: var(--neon-peach); background: color-mix(in srgb, var(--neon-peach) 12%, transparent); border: 1px solid color-mix(in srgb, var(--neon-peach) 30%, transparent);
}

/* control: choice (radio group) */
.ctl-choice { display: flex; flex-direction: column; gap: 5px; }
.choice-opt {
  display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--border-light); background: var(--bg-primary); transition: all 140ms var(--ease);
  font-size: 12.5px; color: var(--text-secondary);
}
.choice-opt:hover { border-color: var(--border-default); }
.choice-opt:focus-within { border-color: var(--cat-hue, var(--accent)); }
.choice-opt .rad { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--text-disabled); flex: 0 0 auto; transition: all 140ms; }
.choice-opt input { position: absolute; opacity: 0; width: 0; height: 0; }
.choice-opt.on { color: var(--text-primary); border-color: color-mix(in srgb, var(--cat-hue, var(--accent)) 55%, transparent); background: color-mix(in srgb, var(--cat-hue, var(--accent)) 9%, var(--bg-primary)); }
.choice-opt.on .rad { border-color: var(--cat-hue, var(--accent)); background: var(--cat-hue, var(--accent)); box-shadow: inset 0 0 0 2.5px var(--bg-primary); }

/* control: toggle */
.ctl-toggle { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ctl-toggle .st { font-size: 12px; color: var(--text-muted); }
.ctl-toggle .st.on { color: var(--cat-hue, var(--accent)); }
.tsw { position: relative; width: 42px; height: 23px; flex: 0 0 auto; cursor: pointer; display: inline-block; }
.tsw input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.tsw .sl { position: absolute; inset: 0; border-radius: 999px; background: var(--bg-primary); border: 1px solid var(--border-default); transition: all 180ms var(--ease); }
.tsw .sl::before { content: ''; position: absolute; left: 3px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; border-radius: 50%; background: var(--text-muted); transition: all 180ms var(--ease); }
.tsw input:checked + .sl { background: color-mix(in srgb, var(--cat-hue, var(--accent)) 22%, var(--bg-primary)); border-color: var(--cat-hue, var(--accent)); }
.tsw input:checked + .sl::before { left: 22px; background: var(--cat-hue, var(--accent)); box-shadow: 0 0 8px var(--cat-hue, var(--accent)); }
.tsw input:focus-visible + .sl { outline: 2px solid var(--accent); outline-offset: 2px; }

/* control: consumable */
.ctl-consume { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.consume-left { font-size: 12px; color: var(--text-muted); }
.consume-left b { color: var(--text-primary); font-family: var(--mono); }
.consume-btn {
  font: 600 12px var(--font); text-transform: lowercase; padding: 7px 14px; border-radius: 7px; cursor: pointer;
  color: var(--cat-hue, var(--accent)); background: color-mix(in srgb, var(--cat-hue, var(--accent)) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--cat-hue, var(--accent)) 45%, transparent); transition: all 140ms var(--ease);
}
.consume-btn:hover:not(:disabled) { background: color-mix(in srgb, var(--cat-hue, var(--accent)) 22%, transparent); }
.consume-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* control: status (earned badge) */
.ctl-status { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--cat-hue, var(--accent)); }
.ctl-status i { font-size: 12px; }
.perk.is-badge { align-items: center; text-align: center; }
.perk.is-badge .perk-top { flex-direction: column; align-items: center; gap: 9px; }
.perk.is-badge .perk-emoji { width: 46px; height: 46px; font-size: 21px; border-radius: 50%; border: 1px solid color-mix(in srgb, var(--cat-hue, var(--accent)) 35%, transparent); }

/* empty category */
.acc-empty { padding: 6px 18px 20px; color: var(--text-muted); font-size: 12.5px; display: flex; align-items: center; gap: 9px; }
.acc-empty i { color: var(--text-disabled); }

/* =============================================================================
 * APPEARANCE + ACCOUNT + SETTINGS
 * ========================================================================== */
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border-light); }
.row:last-child { border-bottom: none; }
.row-l .lbl { font-weight: 550; font-size: 13.5px; color: var(--text-primary); white-space: nowrap; }
.row-l .desc { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

/* accent picker */
.accent-families { display: flex; flex-wrap: wrap; gap: 14px 22px; margin: 10px 0 4px; }
.accent-fam-lbl { font: 600 9.5px var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 7px; }
.accent-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.sw {
  width: 30px; height: 30px; border-radius: 8px; padding: 3px; cursor: pointer;
  border: 2px solid transparent; background: var(--bg-tertiary); transition: all 140ms var(--ease);
}
.sw:hover { transform: scale(1.08); }
.sw:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sw .chip { display: block; width: 100%; height: 100%; border-radius: 5px; }
.sw.on { border-color: var(--text-secondary); box-shadow: 0 0 0 2px var(--accent-bg); }

/* mode toggle (segmented) */
.mode-seg { display: inline-flex; background: var(--bg-tertiary); border: 1px solid var(--border-light); border-radius: 8px; padding: 3px; gap: 2px; }
.mode-seg button { font: 500 12.5px var(--font); color: var(--text-secondary); padding: 6px 14px; border: 0; border-radius: 6px; background: transparent; cursor: pointer; display: flex; align-items: center; gap: 6px; }
.mode-seg button.on { color: var(--text-on-accent); background: var(--accent); }

/* pills */
.pills { display: flex; flex-wrap: wrap; gap: 7px; }
.pill { font-size: 12px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border-default); background: transparent; color: var(--text-secondary); cursor: pointer; transition: all 140ms; }
.pill:hover { border-color: var(--text-muted); color: var(--text-primary); }
.pill.on { background: var(--accent); border-color: var(--accent); color: var(--text-on-accent); }

/* map tile preview grid (kept from production behavior) */
#map-tile-preview .tile-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; margin-top: 10px; border-radius: var(--radius-sm); overflow: hidden; max-width: 320px; border: 1px solid var(--border-light); }
#map-tile-preview .tile-grid img { width: 100%; display: block; }

/* notifications table */
.notif-tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.notif-tbl th { text-align: center; font: 600 10px var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); padding: 8px; border-bottom: 1px solid var(--border-default); }
.notif-tbl th:first-child { text-align: left; }
.notif-tbl .cat-row td { font: 600 10px var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); padding: 12px 8px 5px; }
.notif-tbl td { padding: 7px 8px; border-bottom: 1px solid var(--border-light); color: var(--text-secondary); }
.notif-tbl td:first-child { color: var(--text-primary); }
.notif-tbl td:not(:first-child) { text-align: center; }
.tsw.sm { width: 34px; height: 18px; }
.tsw.sm .sl::before { width: 12px; height: 12px; }
.tsw.sm input:checked + .sl::before { left: 18px; }

/* quiet hours + test channels */
.quiet { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border-light); }
.quiet .lbl { font-weight: 550; font-size: 13px; color: var(--text-primary); }
.timeinput { background: var(--bg-tertiary); border: 1px solid var(--border-default); border-radius: 6px; color: var(--text-primary); padding: 5px 9px; font-family: var(--mono); font-size: 12px; }
.btn-ghost { font: 500 12.5px var(--font); color: var(--text-secondary); background: var(--bg-tertiary); border: 1px solid var(--border-default); border-radius: 7px; padding: 7px 14px; cursor: pointer; }
.btn-ghost:hover { color: var(--text-primary); border-color: var(--text-muted); }
.btn-ghost:disabled { opacity: 0.55; cursor: progress; }

/* password form */
.fg { margin-bottom: 13px; }
.fg label { display: block; font-size: 12.5px; color: var(--text-secondary); margin-bottom: 5px; }
.fg input { width: 100%; padding: 9px 11px; background: var(--bg-tertiary); border: 1px solid var(--border-default); border-radius: var(--radius-sm); color: var(--text-primary); font-family: inherit; font-size: 13.5px; }
.fg .hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.fg input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-bg); }
.btn-primary { font: 600 13px var(--font); text-transform: lowercase; padding: 9px 18px; border-radius: var(--radius-sm); cursor: pointer; color: var(--text-on-accent); background: var(--accent); border: 0; box-shadow: var(--accent-glow); }
.btn-primary:hover { background: var(--accent-hover); }

/* alerts (reuse admin alert palette via tokens) */
.alert { padding: 9px 13px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 12px; }
.alert.hidden { display: none; }
.alert.success, .alert-success { color: var(--success); background: var(--success-bg); border: 1px solid color-mix(in srgb, var(--success) 35%, transparent); }
.alert.error, .alert-error { color: var(--error); background: var(--error-bg); border: 1px solid color-mix(in srgb, var(--error) 35%, transparent); }

/* palette tiles (operator) */
.pal-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 11px; }
.pal-tile { display: flex; gap: 12px; padding: 13px; border: 1px solid var(--border-light); border-radius: var(--radius-sm); background: var(--bg-tertiary); cursor: pointer; transition: all 140ms; text-align: left; }
.pal-tile:hover { border-color: var(--border-default); }
.pal-tile.active, .pal-tile.pending { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-bg); }
.palette-swatches, .pal-sw { display: flex; flex-direction: column; gap: 4px; flex: 0 0 auto; }
.palette-swatch, .pal-sw span { width: 26px; height: 26px; border-radius: 6px; }
.palette-meta .palette-name, .pal-meta .nm { font-weight: 600; font-size: 13.5px; color: var(--text-primary); }
.palette-subtitle, .pal-meta .sub { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.palette-stats { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.palette-badge { display: inline-block; font: 600 9.5px var(--mono); padding: 2px 6px; border-radius: 4px; }
.palette-badge-active { color: var(--text-on-accent); background: var(--accent); }
.palette-badge-wcag { color: var(--success); background: var(--success-bg); }
.palette-badge-contrast { color: var(--text-muted); background: var(--bg-hover); }
.palette-colorblind { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.palette-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.palette-saved { font-size: 12px; color: var(--text-muted); font-family: var(--mono); }
.palette-btn { font: 600 13px var(--font); text-transform: lowercase; padding: 9px 18px; border-radius: var(--radius-sm); cursor: pointer; border: 1px solid var(--border-default); background: var(--bg-tertiary); color: var(--text-primary); }
.palette-btn-primary { color: var(--text-on-accent); background: var(--accent); border-color: var(--accent); box-shadow: var(--accent-glow); }
.palette-btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
