/* Academia 2.0 — campus-v3
   Carbón + verde señal + ámbar frío. Dark-first. */

:root {
  --v3-bg: #0b0f14;
  --v3-bg-2: #121821;
  --v3-surface: #161d27;
  --v3-surface-2: #1c2533;
  --v3-line: rgba(232, 238, 245, 0.08);
  --v3-line-strong: rgba(232, 238, 245, 0.16);
  --v3-text: #e8eef5;
  --v3-muted: #93a0b4;
  --v3-faint: #6b778c;
  --v3-signal: #3ddc97;
  --v3-signal-dim: rgba(61, 220, 151, 0.14);
  --v3-amber: #f0b429;
  --v3-amber-dim: rgba(240, 180, 41, 0.14);
  --v3-danger: #ff6b6b;
  --v3-radius: 18px;
  --v3-radius-sm: 12px;
  --v3-font: "Sora", system-ui, sans-serif;
  --v3-display: "Syne", "Sora", system-ui, sans-serif;
  --v3-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --v3-ease: cubic-bezier(0.22, 1, 0.36, 1);

  /* Bridge to existing tokens used by academy.css */
  --bg: var(--v3-bg);
  --bg-elevated: var(--v3-surface);
  --text: var(--v3-text);
  --text-muted: var(--v3-muted);
  --border: var(--v3-line);
  --bull: var(--v3-signal);
  --gold: var(--v3-amber);
  --gold-light: #ffd666;
  --navy: #0b0f14;
  --font: var(--v3-font);
  --font-display: var(--v3-display);
}

html[data-theme="light"] {
  --v3-bg: #f4f7fb;
  --v3-bg-2: #e8eef6;
  --v3-surface: #ffffff;
  --v3-surface-2: #f0f4fa;
  --v3-line: rgba(11, 15, 20, 0.08);
  --v3-line-strong: rgba(11, 15, 20, 0.14);
  --v3-text: #0f1722;
  --v3-muted: #5b6b80;
  --v3-faint: #7a889c;
  --v3-signal: #0f9f6e;
  --v3-signal-dim: rgba(15, 159, 110, 0.12);
  --v3-amber: #c8890b;
  --v3-amber-dim: rgba(200, 137, 11, 0.12);
  --v3-shadow: 0 18px 40px rgba(15, 23, 34, 0.08);
}

/* ---------- Shell ---------- */
body.app-shell {
  font-family: var(--v3-font);
  background:
    radial-gradient(1200px 600px at 12% -10%, rgba(61, 220, 151, 0.12), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(240, 180, 41, 0.08), transparent 50%),
    var(--v3-bg);
  color: var(--v3-text);
  min-height: 100vh;
}

body.app-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 0;
}

body.app-shell > * {
  position: relative;
  z-index: 1;
}

h1, h2, h3, .v3-display {
  font-family: var(--v3-display);
  letter-spacing: -0.03em;
}

/* ---------- Topbar ---------- */
.topbar,
.topbar-v2,
.topbar-v3 {
  background: rgba(11, 15, 20, 0.72);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--v3-line);
  box-shadow: none;
}

html[data-theme="light"] .topbar,
html[data-theme="light"] .topbar-v2,
html[data-theme="light"] .topbar-v3 {
  background: rgba(244, 247, 251, 0.85);
}

.topbar-v3 .topbar-brand,
.topbar-v2 .topbar-brand {
  font-family: var(--v3-display);
  font-weight: 700;
  letter-spacing: -0.04em;
  gap: 0.65rem;
}

.topbar-v3 .topbar-brand span::after,
.topbar-brand .v3-badge {
  content: "2.0";
  display: inline-block;
  margin-left: 0.45rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--v3-bg);
  background: var(--v3-signal);
  padding: 0.15rem 0.4rem;
  border-radius: 999px;
  vertical-align: middle;
}

.topbar-nav .nav-link {
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  color: var(--v3-muted);
  font-weight: 500;
  transition: color 0.2s var(--v3-ease), background 0.2s var(--v3-ease);
}

.topbar-nav .nav-link:hover,
.topbar-nav .nav-link.is-active {
  color: var(--v3-text);
  background: var(--v3-signal-dim);
}

.topbar-nav .nav-link.is-active {
  color: var(--v3-signal);
}

.topbar-nav .nav-link-tool {
  opacity: 0.72;
}

/* ---------- Bottom nav ---------- */
.bottom-nav,
.bottom-nav-v2,
.bottom-nav-v3 {
  background: rgba(18, 24, 33, 0.92);
  border-top: 1px solid var(--v3-line);
  backdrop-filter: blur(16px);
}

.bottom-nav-item.on,
.bottom-nav-v3 .bottom-nav-item.on {
  color: var(--v3-signal);
}

.bottom-nav-item.on svg {
  filter: drop-shadow(0 0 8px rgba(61, 220, 151, 0.45));
}

/* ---------- Buttons ---------- */
body.app-shell .btn-primary {
  background: var(--v3-signal);
  color: #062016;
  border: 0;
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(61, 220, 151, 0.25);
}

body.app-shell .btn-primary:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

body.app-shell .btn-ghost,
body.app-shell .btn-outline {
  border-color: var(--v3-line-strong);
  color: var(--v3-text);
  background: transparent;
}

body.app-shell .chip-ok {
  background: var(--v3-signal-dim);
  color: var(--v3-signal);
}

body.app-shell .chip-wait {
  background: var(--v3-amber-dim);
  color: var(--v3-amber);
}

/* ---------- Campus 2.0 layout ---------- */
.page-campus .campus-shell,
.page-campus .app-main {
  max-width: 1180px;
}

.v3-campus {
  display: grid;
  gap: 1.75rem;
  padding-bottom: 5rem;
}

.v3-hero {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr;
  gap: 1.5rem;
  align-items: end;
  padding: 1.75rem 0 0.5rem;
  animation: v3Rise 0.7s var(--v3-ease) both;
}

.v3-hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--v3-signal);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}

.v3-hero-kicker i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--v3-signal);
  box-shadow: 0 0 0 6px var(--v3-signal-dim);
  animation: v3Pulse 2s ease-in-out infinite;
}

.v3-hero h1 {
  font-size: clamp(2.4rem, 5vw, 3.6rem);
  line-height: 0.95;
  margin: 0 0 0.85rem;
  max-width: 12ch;
}

.v3-hero p {
  color: var(--v3-muted);
  font-size: 1.05rem;
  line-height: 1.55;
  max-width: 42ch;
  margin: 0 0 1.25rem;
}

.v3-hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.v3-hero-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.v3-stat {
  background: linear-gradient(180deg, var(--v3-surface), var(--v3-bg-2));
  border: 1px solid var(--v3-line);
  border-radius: var(--v3-radius);
  padding: 1.1rem 1rem;
  min-height: 110px;
}

.v3-stat strong {
  display: block;
  font-family: var(--v3-display);
  font-size: 1.85rem;
  letter-spacing: -0.04em;
  margin-bottom: 0.25rem;
}

.v3-stat span {
  color: var(--v3-muted);
  font-size: 0.85rem;
}

.v3-continue {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.15rem 1.35rem;
  border-radius: var(--v3-radius);
  border: 1px solid rgba(61, 220, 151, 0.28);
  background:
    linear-gradient(120deg, var(--v3-signal-dim), transparent 55%),
    var(--v3-surface);
  text-decoration: none;
  color: inherit;
  transition: transform 0.25s var(--v3-ease), border-color 0.25s var(--v3-ease);
  animation: v3Rise 0.8s var(--v3-ease) 0.08s both;
}

.v3-continue:hover {
  transform: translateY(-2px);
  border-color: var(--v3-signal);
}

.v3-continue small {
  display: block;
  color: var(--v3-signal);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.72rem;
  margin-bottom: 0.25rem;
}

.v3-continue strong {
  font-family: var(--v3-display);
  font-size: 1.15rem;
}

.v3-continue em {
  font-style: normal;
  color: var(--v3-muted);
  font-size: 0.9rem;
}

.v3-continue .v3-continue-go {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--v3-signal);
  color: #062016;
  font-weight: 800;
}

.v3-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  animation: v3Rise 0.8s var(--v3-ease) 0.12s both;
}

.v3-tools a {
  text-decoration: none;
  color: var(--v3-muted);
  border: 1px solid var(--v3-line);
  background: var(--v3-surface);
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.v3-tools a:hover {
  color: var(--v3-text);
  border-color: var(--v3-line-strong);
  background: var(--v3-surface-2);
}

.v3-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-radius: var(--v3-radius);
  background: var(--v3-amber-dim);
  border: 1px solid rgba(240, 180, 41, 0.35);
  color: inherit;
  text-decoration: none;
}

.v3-banner strong {
  display: block;
  font-family: var(--v3-display);
}

.v3-banner span {
  color: var(--v3-muted);
  font-size: 0.9rem;
}

/* Phases */
.v3-phases {
  display: grid;
  gap: 2rem;
}

.v3-phase {
  animation: v3Rise 0.75s var(--v3-ease) both;
}

.v3-phase:nth-child(1) { animation-delay: 0.05s; }
.v3-phase:nth-child(2) { animation-delay: 0.12s; }
.v3-phase:nth-child(3) { animation-delay: 0.18s; }
.v3-phase:nth-child(4) { animation-delay: 0.24s; }

.v3-phase-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--v3-line);
}

.v3-phase-head .phase-meta {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.v3-phase-index {
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--v3-signal);
  font-weight: 700;
}

.v3-phase-head h2 {
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 2rem);
}

.v3-phase-head p {
  margin: 0;
  color: var(--v3-muted);
  font-size: 0.95rem;
}

.v3-phase-count {
  color: var(--v3-faint);
  font-size: 0.85rem;
  white-space: nowrap;
}

.v3-module-list {
  display: grid;
  gap: 0.65rem;
}

.v3-module {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: 1rem 1.1rem;
  border-radius: var(--v3-radius-sm);
  border: 1px solid var(--v3-line);
  background: var(--v3-surface);
  transition: transform 0.25s var(--v3-ease), border-color 0.25s var(--v3-ease), background 0.25s var(--v3-ease);
}

.v3-module:hover {
  transform: translateX(4px);
  border-color: var(--v3-line-strong);
  background: var(--v3-surface-2);
}

.v3-module.is-current {
  border-color: rgba(61, 220, 151, 0.45);
  box-shadow: inset 3px 0 0 var(--v3-signal);
}

.v3-module.locked {
  opacity: 0.55;
}

.v3-module-index {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-family: var(--v3-display);
  font-weight: 700;
  background: var(--v3-bg);
  border: 1px solid var(--v3-line);
  color: var(--v3-muted);
}

.v3-module.is-current .v3-module-index {
  background: var(--v3-signal-dim);
  color: var(--v3-signal);
  border-color: transparent;
}

.v3-module-main h3 {
  margin: 0 0 0.2rem;
  font-size: 1.05rem;
}

.v3-module-main p {
  margin: 0;
  color: var(--v3-muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.v3-module-label {
  display: inline-block;
  font-size: 0.72rem;
  color: var(--v3-amber);
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-bottom: 0.15rem;
}

.v3-module-progress {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.55rem;
  font-size: 0.78rem;
  color: var(--v3-faint);
}

.v3-module-progress-track {
  flex: 1;
  max-width: 160px;
  height: 4px;
  border-radius: 999px;
  background: var(--v3-line);
  overflow: hidden;
}

.v3-module-progress-track i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--v3-signal), var(--v3-amber));
  border-radius: inherit;
}

.v3-module-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.45rem;
}

/* Hide legacy campus chrome when v3 is active */
.page-campus .campus-ticker,
.page-campus .campus-sidebar,
.page-campus .campus-playbook,
.page-campus .campus-program-summary,
.page-campus .campus-actions,
.page-campus .campus-method,
.page-campus .campus-layout {
  /* kept for safety if old markup remains */
}

.page-campus.v3-active .campus-ticker {
  display: none;
}

/* ---------- Module page ---------- */
.page-module .app-main,
.page-watch .app-main {
  max-width: 1100px;
}

.v3-mod-header {
  padding: 1.5rem 0 1rem;
  animation: v3Rise 0.65s var(--v3-ease) both;
}

.v3-mod-header .breadcrumb a {
  color: var(--v3-muted);
}

.v3-mod-phase {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.85rem 0 0.55rem;
  color: var(--v3-signal);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.v3-mod-header h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.9rem, 4vw, 2.8rem);
  max-width: 18ch;
}

.v3-mod-header > p {
  color: var(--v3-muted);
  max-width: 56ch;
}

.v3-mod-progress {
  margin-top: 1.15rem;
  max-width: 420px;
}

.v3-mod-progress .prog-track {
  height: 6px;
  background: var(--v3-line);
  border-radius: 999px;
  overflow: hidden;
}

.v3-mod-progress .prog-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--v3-signal), var(--v3-amber));
}

.v3-mod-progress .prog-label {
  margin-top: 0.4rem;
  color: var(--v3-faint);
  font-size: 0.85rem;
}

.v3-lesson-list {
  display: grid;
  gap: 0.55rem;
  margin-top: 1.25rem;
}

.v3-lesson {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: 0.95rem 1.05rem;
  border-radius: var(--v3-radius-sm);
  border: 1px solid var(--v3-line);
  background: var(--v3-surface);
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s var(--v3-ease), border-color 0.2s;
  animation: v3Rise 0.55s var(--v3-ease) both;
}

a.v3-lesson:hover {
  transform: translateX(3px);
  border-color: rgba(61, 220, 151, 0.35);
}

.v3-lesson.is-done {
  border-color: rgba(61, 220, 151, 0.25);
}

.v3-lesson.is-locked {
  opacity: 0.5;
}

.v3-lesson-index {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-family: var(--v3-display);
  font-weight: 700;
  background: var(--v3-bg);
  color: var(--v3-muted);
  font-size: 0.85rem;
}

.v3-lesson.is-done .v3-lesson-index {
  background: var(--v3-signal-dim);
  color: var(--v3-signal);
}

.v3-lesson.is-watched {
  border-color: rgba(61, 220, 151, 0.18);
}

.v3-lesson.is-watched .v3-lesson-index {
  background: var(--v3-signal-dim);
  color: var(--v3-signal);
  font-size: 1.05rem;
}

.v3-lesson.is-progress {
  border-color: rgba(240, 180, 41, 0.3);
}

.v3-lesson.is-progress .v3-lesson-index {
  background: var(--v3-amber-dim);
  color: var(--v3-amber);
}

.v3-lesson.is-progress .v3-lesson-cta {
  color: var(--v3-amber);
}

.v3-lesson-progress {
  display: block;
  height: 3px;
  margin-top: 0.45rem;
  border-radius: 3px;
  background: var(--v3-line-strong);
  overflow: hidden;
  max-width: 260px;
}

.v3-lesson-progress span {
  display: block;
  height: 100%;
  background: var(--v3-amber);
}

.sb-item.in-progress .sb-n {
  background: var(--v3-amber-dim);
  color: var(--v3-amber);
}

.player {
  position: relative;
}

.video-resume-note {
  position: absolute;
  left: 50%;
  bottom: 64px;
  transform: translateX(-50%);
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  background: rgba(11, 15, 20, 0.82);
  color: #fff;
  font-size: 0.82rem;
  pointer-events: none;
  transition: opacity 0.6s;
  z-index: 5;
}

.video-resume-note.is-hiding {
  opacity: 0;
}

.v3-lesson-main h3 {
  margin: 0 0 0.15rem;
  font-size: 1rem;
}

.v3-lesson-main p {
  margin: 0;
  color: var(--v3-muted);
  font-size: 0.85rem;
}

.v3-lesson-cta {
  color: var(--v3-signal);
  font-weight: 700;
  font-size: 0.85rem;
}

.v3-module-workspace {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 1.25rem;
  align-items: start;
}

.v3-side {
  display: grid;
  gap: 0.75rem;
  position: sticky;
  top: 5.5rem;
}

.v3-side-box {
  padding: 1.1rem;
  border-radius: var(--v3-radius);
  border: 1px solid var(--v3-line);
  background: var(--v3-surface);
}

.v3-side-box .kicker {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--v3-faint);
  margin: 0 0 0.4rem;
}

.v3-side-box strong {
  font-family: var(--v3-display);
  font-size: 1.8rem;
  display: block;
}

.v3-side-box span,
.v3-side-box p {
  color: var(--v3-muted);
  font-size: 0.88rem;
}

.v3-side-exam.is-ready {
  border-color: rgba(61, 220, 151, 0.4);
}

.v3-side-exam.is-done {
  border-color: rgba(61, 220, 151, 0.25);
}

/* ---------- Watch page ---------- */
.page-watch.v3-active .watch-grid {
  gap: 1.25rem;
}

.page-watch.v3-active .player-shell,
.page-watch.v3-active .player {
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--v3-line);
  background: #000;
  box-shadow: var(--v3-shadow);
}

.page-watch.v3-active .watch-meta h1 {
  font-family: var(--v3-display);
  letter-spacing: -0.03em;
}

.page-watch.v3-active .video-mode-tab.is-active {
  color: var(--v3-signal);
  border-bottom-color: var(--v3-signal);
}

.page-watch .v3-watch-top {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  margin-bottom: 0.85rem;
  animation: v3Rise 0.5s var(--v3-ease) both;
}

.page-watch .v3-watch-top .phase-tag {
  color: var(--v3-signal);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.page-watch .v3-watch-top h1 {
  margin: 0.25rem 0 0;
  font-size: clamp(1.35rem, 3vw, 1.85rem);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--v3-line);
  color: var(--v3-faint);
  background: transparent;
}

/* Motion */
@keyframes v3Rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes v3Pulse {
  0%, 100% { box-shadow: 0 0 0 4px var(--v3-signal-dim); }
  50% { box-shadow: 0 0 0 8px rgba(61, 220, 151, 0.08); }
}

/* Responsive */
@media (max-width: 900px) {
  .v3-hero {
    grid-template-columns: 1fr;
  }

  .v3-hero-stats {
    grid-template-columns: repeat(3, 1fr);
  }

  .v3-module-workspace {
    grid-template-columns: 1fr;
  }

  .v3-side {
    position: static;
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .v3-hero h1 {
    max-width: none;
  }

  .v3-hero-stats {
    grid-template-columns: 1fr;
  }

  .v3-module {
    grid-template-columns: auto 1fr;
  }

  .v3-module-side {
    grid-column: 2;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .v3-side {
    grid-template-columns: 1fr;
  }

  .v3-phase-head {
    flex-direction: column;
    align-items: flex-start;
  }
}
