/* ================================================================
   Guru Academy — shared design system for the logged-in app
   (library, settings, account, viewing-activity). One source of
   truth for tokens/components/motion so every page reads as one
   product instead of four separately-styled pages.
   ================================================================ */

@font-face { font-display: swap; }

:root {
  /* ---- dark theme (default) ---- */
  --bg: #03110a;
  --bg-1: #04170d;
  --bg-2: #061f11;
  --surface: rgba(255, 255, 255, 0.045);
  --surface-solid: #0a2417;
  --surface-2: rgba(255, 255, 255, 0.075);
  --surface-hover: rgba(255, 255, 255, 0.09);
  --text: #f4f9f5;
  --muted: rgba(244, 249, 245, 0.62);
  --muted-2: rgba(244, 249, 245, 0.4);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --accent: #b6f500;
  --accent-2: #6be36b;
  --accent-ink: #052b0a;
  --accent-dim: rgba(182, 245, 0, 0.16);
  --accent-glow: rgba(182, 245, 0, 0.35);
  --danger: #ff5d5d;
  --danger-dim: rgba(255, 93, 93, 0.14);
  --shadow-lg: 0 30px 80px -20px rgba(0, 0, 0, 0.65), 0 8px 24px -8px rgba(0, 0, 0, 0.5);
  --shadow-sm: 0 8px 24px -12px rgba(0, 0, 0, 0.5);
  --glow-accent: 0 0 0 1px rgba(182, 245, 0, 0.25), 0 0 40px -8px rgba(182, 245, 0, 0.35);
  --scrim: rgba(2, 8, 5, 0.55);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius: 14px;
  --radius-sm: 10px;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  --font-head: 'Host Grotesk', -apple-system, system-ui, sans-serif;
  --font-body: 'DM Sans', -apple-system, system-ui, sans-serif;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f6f7f4;
  --bg-1: #f1f3ee;
  --bg-2: #ebeee7;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-solid: #ffffff;
  --surface-2: rgba(11, 32, 21, 0.04);
  --surface-hover: rgba(11, 32, 21, 0.055);
  --text: #0b1f14;
  --muted: rgba(11, 31, 20, 0.62);
  --muted-2: rgba(11, 31, 20, 0.42);
  --border: rgba(11, 31, 20, 0.09);
  --border-strong: rgba(11, 31, 20, 0.16);
  --accent: #6f9c00;
  --accent-2: #2f9e5c;
  --accent-ink: #ffffff;
  --accent-dim: rgba(111, 156, 0, 0.12);
  --accent-glow: rgba(111, 156, 0, 0.28);
  --danger: #d64545;
  --danger-dim: rgba(214, 69, 69, 0.1);
  --shadow-lg: 0 30px 70px -24px rgba(11, 31, 20, 0.22), 0 6px 18px -8px rgba(11, 31, 20, 0.12);
  --shadow-sm: 0 10px 26px -14px rgba(11, 31, 20, 0.18);
  --glow-accent: 0 0 0 1px rgba(111, 156, 0, 0.3), 0 0 30px -10px rgba(111, 156, 0, 0.35);
  --scrim: rgba(246, 247, 244, 0.6);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-body);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
::selection { background: var(--accent); color: var(--accent-ink); }

/* subtle animated grain/glow ambient background, sits behind everything */
.app-ambient {
  position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none;
  background:
    radial-gradient(60% 50% at 15% 0%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 60%),
    radial-gradient(50% 45% at 100% 20%, color-mix(in srgb, var(--accent-2) 12%, transparent), transparent 60%),
    var(--bg);
}
[data-theme="light"] .app-ambient {
  background:
    radial-gradient(60% 50% at 15% 0%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 60%),
    radial-gradient(50% 45% at 100% 20%, color-mix(in srgb, var(--accent-2) 8%, transparent), transparent 60%),
    var(--bg);
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--muted-2); }

/* ---- motion ---- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: scale(1); } }
@keyframes shimmer { 0% { background-position: -300px 0; } 100% { background-position: 300px 0; } }
@keyframes floatY { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes spin { to { transform: rotate(360deg); } }
.reveal { animation: fadeUp .7s var(--ease) both; }
.reveal-scale { animation: scaleIn .5s var(--ease) both; }
.skeleton-shimmer {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-hover) 37%, var(--surface-2) 63%);
  background-size: 600px 100%; animation: shimmer 1.6s linear infinite;
}

/* ---- typography ---- */
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--accent); }
h1, h2, h3 { font-family: var(--font-head); letter-spacing: -0.03em; margin: 0; }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  padding: 12px 22px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font-family: var(--font-body);
  font-size: 14px; font-weight: 700; cursor: pointer; text-decoration: none;
  transition: border-color .25s, background .25s, color .25s, box-shadow .25s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.btn:active { background: var(--surface-2); }
.btn--primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-ink); border: 0;
  box-shadow: 0 10px 30px -10px var(--accent-glow);
}
.btn--primary:hover { background: linear-gradient(135deg, var(--accent-2), var(--accent)); box-shadow: 0 14px 38px -8px var(--accent-glow); }
.btn--danger { background: var(--danger-dim); color: var(--danger); border-color: rgba(255,93,93,.3); }
.btn--danger:hover { background: rgba(255,93,93,.22); }
.btn--sm { padding: 8px 16px; font-size: 13px; }
.btn--icon { width: 42px; height: 42px; padding: 0; border-radius: 50%; }

/* ---- glass surfaces ---- */
.glass {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-sm);
}

/* ---- switches ---- */
.switch { position: relative; display: inline-block; width: 46px; height: 27px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch__track {
  position: absolute; inset: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px;
  cursor: pointer; transition: background .3s var(--ease), border-color .3s var(--ease);
}
.switch__track::before {
  content: ""; position: absolute; width: 21px; height: 21px; left: 2px; top: 2px; background: var(--muted-2);
  border-radius: 50%; transition: transform .3s var(--ease-spring), background .3s var(--ease);
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.switch input:checked + .switch__track { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; }
.switch input:checked + .switch__track::before { transform: translateX(19px); background: var(--accent-ink); }

/* ---- segmented control with sliding indicator ---- */
.seg { position: relative; display: inline-flex; padding: 4px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); gap: 2px; }
.seg__opt {
  position: relative; z-index: 1; padding: 8px 18px; border-radius: 999px; border: 0; background: transparent;
  color: var(--muted); font-size: 13px; font-weight: 700; cursor: pointer; font-family: var(--font-body);
  transition: color .25s var(--ease);
}
.seg__opt.active { color: var(--accent-ink); }
.seg__thumb {
  position: absolute; top: 4px; bottom: 4px; left: 4px; border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 18px -6px var(--accent-glow);
  transition: transform .4s var(--ease-spring), width .4s var(--ease-spring);
}

/* ---- avatar ---- */
.avatar-ring {
  border-radius: 50%; padding: 2px; background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: inline-flex; flex: 0 0 auto;
}
.avatar-ring__inner {
  width: 100%; height: 100%; border-radius: 50%; background: var(--bg); display: flex; align-items: center;
  justify-content: center; overflow: hidden;
}

/* ---- modal ---- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 300; background: var(--scrim); backdrop-filter: blur(6px);
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.open { display: flex; animation: fadeIn .25s var(--ease); }
.modal {
  width: 100%; max-width: 440px; background: var(--surface-solid); border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: 30px; box-shadow: var(--shadow-lg);
  animation: scaleIn .35s var(--ease-spring);
}

/* ---- toast ---- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--surface-solid); border: 1px solid var(--border); color: var(--text); padding: 12px 20px;
  border-radius: 999px; font-size: 13px; font-weight: 600; box-shadow: var(--shadow-lg); z-index: 400;
  transition: transform .4s var(--ease-spring), opacity .3s var(--ease); pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- account-area subnav: lets you jump between Profile/Account/
   Settings/Viewing Activity without going back through the library
   dropdown first ---- */
.app-subnav {
  display: flex; align-items: center; gap: 4px; overflow-x: auto; scrollbar-width: none;
  padding: 4px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border);
  width: fit-content; max-width: 100%;
}
.app-subnav::-webkit-scrollbar { display: none; }
.app-subnav a, .app-subnav button {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 16px; border-radius: 999px;
  font-size: 13.5px; font-weight: 700; color: var(--muted-2); text-decoration: none; white-space: nowrap;
  transition: all .25s var(--ease); background: none; border: 0; cursor: pointer; font-family: var(--font-body);
}
.app-subnav a:hover, .app-subnav button:hover { color: var(--text); background: var(--surface-hover); }
.app-subnav a.active, .app-subnav button.active { color: var(--accent-ink); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }

/* ---- shared modal content styles (avatar picker, form fields) reused by
   the Manage Profile modal on settings/account/viewing-activity ---- */
.modal__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal__title { font-family: var(--font-head); font-size: 20px; letter-spacing: -0.02em; }
.modal__close {
  background: var(--surface-2); border: 0; color: var(--muted); cursor: pointer;
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; transition: all .2s;
}
.modal__close:hover { color: var(--text); background: var(--surface-hover); }
.modal__field { margin-bottom: 15px; }
.modal__label { display: block; font-size: 13px; color: var(--muted-2); font-weight: 600; margin-bottom: 7px; }
.modal__input {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); font-size: 14px; font-family: var(--font-body); transition: border-color .25s;
}
.modal__input:focus { outline: none; border-color: var(--accent); }
.modal__msg { font-size: 13px; margin-top: 6px; min-height: 18px; font-weight: 600; }
.modal__msg.error { color: var(--danger); }
.modal__msg.success { color: var(--accent-2); }
.modal__submit { width: 100%; margin-top: 8px; justify-content: center; }
.modal__submit:disabled { opacity: 0.55; cursor: default; }
.avatar-grid { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0 20px; }
.avatar-opt {
  width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 22px; background: var(--surface-2); border: 2px solid transparent; cursor: pointer;
  transition: transform .3s var(--ease-spring), border-color .25s;
}
.avatar-opt:hover { transform: translateY(-3px) scale(1.05); }
.avatar-opt.selected { border-color: var(--accent); background: var(--accent-dim); box-shadow: var(--glow-accent); }

/* ---- page transition: fade in on load, fade out just before navigating
   away via a subnav link, so switching between Account/Settings/Viewing
   Activity feels like one continuous surface instead of a hard reload ---- */
body { animation: pageFadeIn .35s var(--ease) both; }
body.page-leaving { opacity: 0; transition: opacity .16s var(--ease); }
@keyframes pageFadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ================= header search + category filters =================
   Lives in .appbar__right on both library.html and course.html. The
   search box grows on focus, glows with the accent color, and drops a
   live results panel; the filter button opens a category grid in the
   same visual language. Both panels share .hdr-panel-enter for the
   open animation. */
.hdr-search { position: relative; flex: 0 1 auto; }
.hdr-search__box {
  display: flex; align-items: center; gap: 9px; width: 220px; height: 40px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2);
  transition: width .45s var(--ease-spring), border-color .3s var(--ease), background .3s var(--ease), box-shadow .3s var(--ease);
}
.hdr-search__box:hover { background: var(--surface-hover); }
.hdr-search__box.focused {
  width: 340px; border-color: var(--accent); background: var(--surface-solid);
  box-shadow: 0 0 0 4px var(--accent-dim), 0 12px 30px -10px rgba(0,0,0,.5);
}
.hdr-search__icon { flex: 0 0 auto; color: var(--muted); transition: color .3s var(--ease), transform .3s var(--ease-spring); }
.hdr-search__box.focused .hdr-search__icon { color: var(--accent); transform: scale(1.1); }
.hdr-search__box input {
  flex: 1; min-width: 0; background: none; border: 0; outline: none; color: var(--text);
  font-family: var(--font-body); font-size: 13.5px; font-weight: 500;
}
.hdr-search__box input::placeholder { color: var(--muted); }
.hdr-search__kbd {
  flex: 0 0 auto; font-family: var(--font-body); font-size: 11px; font-weight: 700; color: var(--muted);
  border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; opacity: .8;
  transition: opacity .2s var(--ease);
}
.hdr-search__box.focused .hdr-search__kbd { opacity: 0; }
.hdr-search__clear {
  flex: 0 0 auto; display: none; align-items: center; justify-content: center; width: 18px; height: 18px;
  border-radius: 50%; border: 0; background: var(--surface-hover); color: var(--muted); cursor: pointer;
  transition: all .2s var(--ease);
}
.hdr-search__clear:hover { color: var(--text); background: var(--border-strong); }
.hdr-search__box.has-value .hdr-search__clear { display: flex; }
.hdr-search__box.has-value .hdr-search__kbd { display: none; }

.hdr-panel-enter {
  position: absolute; top: calc(100% + 12px); right: 0; z-index: 260;
  background: var(--surface-solid); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); opacity: 0; visibility: hidden; transform: translateY(-8px) scale(.98);
  transition: opacity .25s var(--ease), transform .3s var(--ease-spring), visibility .25s;
  pointer-events: none;
}
.hdr-panel-enter.open { opacity: 1; visibility: visible; transform: translateY(0) scale(1); pointer-events: auto; }

.hdr-results { width: 380px; max-height: 420px; overflow-y: auto; padding: 8px; }
.hdr-results__empty { padding: 30px 16px; text-align: center; color: var(--muted); font-size: 13px; }
.hdr-results__hint { padding: 10px 12px 6px; font-size: 11px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.hdr-result {
  display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 12px; cursor: pointer;
  text-decoration: none; color: var(--text); opacity: 0; transform: translateX(-6px);
  animation: hdrResultIn .35s var(--ease) forwards;
}
@keyframes hdrResultIn { to { opacity: 1; transform: translateX(0); } }
.hdr-result:hover, .hdr-result.active { background: var(--surface-2); }
.hdr-result__cover { width: 64px; height: 40px; border-radius: 8px; object-fit: cover; flex: 0 0 auto; background: var(--accent-dim); }
.hdr-result__body { min-width: 0; flex: 1; }
.hdr-result__title { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hdr-result__meta { font-size: 11px; color: var(--muted); margin-top: 2px; display: flex; align-items: center; gap: 6px; }
.hdr-result__dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
.hdr-result__chevron { flex: 0 0 auto; color: var(--muted); opacity: 0; transform: translateX(-3px); transition: all .2s var(--ease); }
.hdr-result:hover .hdr-result__chevron { opacity: 1; transform: translateX(0); }

.hdr-filter-wrap { position: relative; }
.hdr-filter-btn {
  display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); cursor: pointer;
  transition: all .25s var(--ease);
}
.hdr-filter-btn:hover, .hdr-filter-btn.open { color: var(--accent); border-color: var(--accent-dim); background: var(--surface-hover); }
.hdr-filter-btn.open svg { transform: rotate(90deg); }
.hdr-filter-btn svg { transition: transform .3s var(--ease-spring); }
.hdr-filters { width: 300px; padding: 16px; }
.hdr-filters__title { font-size: 11px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; }
.hdr-filters__grid { display: flex; flex-wrap: wrap; gap: 8px; }
.hdr-filters__chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--muted-2);
  font-size: 12.5px; font-weight: 700; font-family: var(--font-body); cursor: pointer;
  transition: all .25s var(--ease); opacity: 0; transform: scale(.92); animation: hdrChipIn .3s var(--ease) forwards;
}
@keyframes hdrChipIn { to { opacity: 1; transform: scale(1); } }
.hdr-filters__chip:hover { color: var(--text); border-color: var(--border-strong); transform: translateY(-2px) scale(1); }
.hdr-filters__dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
@media (max-width: 860px) {
  .hdr-search__box { width: 40px; padding: 0; justify-content: center; border-radius: 50%; }
  .hdr-search__box input, .hdr-search__kbd { display: none; }
  .hdr-search__box.focused { width: 240px; border-radius: 999px; padding: 0 14px; justify-content: flex-start; }
  .hdr-search__box.focused input { display: block; }
  .hdr-results, .hdr-filters { width: min(90vw, 340px); }
}
