/* ===================================================
   Psychology Learning Hub — Design Replica
   Soft purple/blue glassmorphism theme
   =================================================== */

:root {
  --bg:           #f0f3fa;
  --surface:      #ffffff;
  --ink:          #1e293b;
  --ink-2:        #64748b;
  --ink-3:        #94a3b8;
  --purple:       #7b6cf6;
  --purple-light: #ede9fe;
  --purple-grad:  linear-gradient(135deg, #8b7cf8 0%, #6366f1 50%, #818cf8 100%);
  --blue:         #3b82f6;
  --blue-light:   #eff6ff;
  --green:        #10b981;
  --green-light:  #ecfdf5;
  --teal:         #14b8a6;
  --teal-light:   #f0fdfa;
  --shadow-sm:    0 2px 8px rgba(100, 116, 139, 0.08);
  --shadow-md:    0 8px 24px rgba(100, 116, 139, 0.12);
  --shadow-lg:    0 16px 48px rgba(100, 116, 139, 0.15);
  --radius:       16px;
  --radius-lg:    20px;
  --radius-xl:    24px;
  --radius-pill:  999px;
  --safe-top:     env(safe-area-inset-top, 0px);
  --safe-bottom:  env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: 'Noto Sans SC', -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* ===== Background ===== */
.page-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 70% 50% at 20% 0%, rgba(139, 124, 248, 0.12) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 10%, rgba(96, 165, 250, 0.10) 0%, transparent 55%),
    radial-gradient(ellipse 50% 30% at 50% 100%, rgba(110, 231, 183, 0.06) 0%, transparent 50%),
    var(--bg);
}

.app {
  max-width: 960px;
  margin: 0 auto;
  padding: calc(.75rem + var(--safe-top)) 1rem calc(1.5rem + var(--safe-bottom));
}

/* ===== Hero ===== */
.hero {
  padding: .5rem 0 1.25rem;
}

.hero__top { margin-bottom: 1.25rem; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
}

.brand__logo {
  width: 28px;
  height: 28px;
}

.brand__logo svg { width: 100%; height: 100%; }

.brand__text {
  font-size: .78rem;
  font-weight: 500;
  color: var(--ink-2);
}

.hero__body {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.hero__title {
  font-size: clamp(1.65rem, 6vw, 2.25rem);
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: -.02em;
  color: var(--ink);
}

.hero__title-accent {
  background: linear-gradient(135deg, #6366f1, #3b82f6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero__desc {
  font-size: .82rem;
  color: var(--ink-3);
  margin-top: .5rem;
}

.hero__decor {
  position: relative;
  width: 100px;
  height: 90px;
  flex-shrink: 0;
}

.decor {
  position: absolute;
  filter: drop-shadow(0 4px 12px rgba(139, 124, 248, 0.25));
}

.decor--play {
  top: 0; right: 0;
  width: 52px; height: 52px;
  animation: float 4s ease-in-out infinite;
}

.decor--play svg { width: 100%; height: 100%; }

.decor--books {
  bottom: 8px; left: 0;
  width: 40px; height: 40px;
  animation: float 5s ease-in-out infinite -.5s;
}

.decor--books svg { width: 100%; height: 100%; }

.decor--plant {
  bottom: 0; right: 12px;
  width: 28px; height: 36px;
  animation: float 4.5s ease-in-out infinite -1s;
}

.decor--plant svg { width: 100%; height: 100%; }

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* ===== Stats Row ===== */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .65rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: .6rem;
  background: var(--surface);
  border-radius: var(--radius);
  padding: .85rem .75rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(255,255,255,.8);
}

.stat-card__icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-card__icon svg { width: 18px; height: 18px; }

.stat-card--purple .stat-card__icon {
  background: var(--purple-light);
  color: var(--purple);
}

.stat-card--blue .stat-card__icon {
  background: var(--blue-light);
  color: var(--blue);
}

.stat-card--green .stat-card__icon {
  background: var(--green-light);
  color: var(--green);
}

.stat-card__info {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .15rem .3rem;
  min-width: 0;
}

.stat-card__num {
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1;
  color: var(--ink);
}

.stat-card__unit {
  font-size: .72rem;
  font-weight: 600;
  color: var(--ink-2);
}

.stat-card__sub {
  width: 100%;
  font-size: .62rem;
  color: var(--ink-3);
}

/* ===== Search ===== */
.search-section {
  display: flex;
  gap: .6rem;
  margin-bottom: 1rem;
}

.search-bar {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.search-bar__icon {
  position: absolute;
  left: 1rem;
  width: 18px;
  height: 18px;
  color: var(--ink-3);
  pointer-events: none;
}

.search-bar__input {
  width: 100%;
  padding: .82rem 2.5rem .82rem 2.75rem;
  font-size: .88rem;
  font-family: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sm);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

.search-bar__input::placeholder { color: var(--ink-3); }

.search-bar__input:focus {
  border-color: rgba(123, 108, 246, 0.4);
  box-shadow: 0 0 0 3px rgba(123, 108, 246, 0.12);
}

.search-bar__clear {
  position: absolute;
  right: .75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  background: var(--bg);
  border: none;
  border-radius: 50%;
  color: var(--ink-3);
  cursor: pointer;
}

.search-bar__clear svg { width: 14px; height: 14px; }

.filter-btn {
  display: flex;
  align-items: center;
  gap: .35rem;
  padding: 0 1rem;
  font-size: .82rem;
  font-family: inherit;
  font-weight: 500;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.filter-btn svg { width: 16px; height: 16px; }

.filter-btn:active { background: var(--purple-light); color: var(--purple); }

/* ===== Tabs ===== */
.tabs {
  display: flex;
  gap: .5rem;
  overflow-x: auto;
  padding-bottom: .25rem;
  margin-bottom: .5rem;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex-shrink: 0;
  padding: .5rem 1.1rem;
  font-size: .82rem;
  font-family: inherit;
  font-weight: 500;
  color: var(--ink-2);
  background: transparent;
  border: none;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
}

.tab.active {
  color: #fff;
  background: var(--purple-grad);
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(123, 108, 246, 0.35);
}

.result-hint {
  font-size: .75rem;
  color: var(--ink-3);
  margin-bottom: .75rem;
  min-height: 1em;
}

.result-hint strong { color: var(--purple); font-weight: 600; }

/* ===== Course Cards ===== */
.course-list {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.course-card {
  display: flex;
  align-items: stretch;
  gap: .85rem;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(255,255,255,.9);
  animation: rise .45s cubic-bezier(.22,1,.36,1) both;
  transition: box-shadow .25s, transform .25s;
}

@media (hover: hover) {
  .course-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
  }
}

.course-card__thumb {
  flex-shrink: 0;
  width: 72px;
  height: 72px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.course-card__thumb--video {
  background: linear-gradient(135deg, #ddd6fe 0%, #c4b5fd 50%, #a78bfa 100%);
}

.course-card__thumb--audio {
  background: linear-gradient(135deg, #ccfbf1 0%, #99f6e4 50%, #5eead4 100%);
}

.course-card__thumb svg {
  width: 28px;
  height: 28px;
  color: rgba(255,255,255,.95);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.1));
}

.course-card__main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

.course-card__tags {
  display: flex;
  align-items: center;
  gap: .35rem;
  flex-wrap: wrap;
}

.tag {
  font-size: .62rem;
  font-weight: 700;
  padding: .15rem .45rem;
  border-radius: 6px;
  letter-spacing: .02em;
}

.tag--video {
  color: var(--purple);
  background: var(--purple-light);
}

.tag--audio {
  color: var(--teal);
  background: var(--teal-light);
}

.tag--cat {
  color: var(--ink-3);
  background: var(--bg);
  font-weight: 500;
}

.course-card__title {
  font-size: .92rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.course-card__sub {
  font-size: .72rem;
  color: var(--ink-3);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Attachments */
.attachments {
  margin-top: .35rem;
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

.attachment {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .45rem .65rem;
  background: var(--blue-light);
  border-radius: 10px;
  border: 1px dashed rgba(59, 130, 246, 0.25);
}

.attachment__icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: rgba(59, 130, 246, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--blue);
}

.attachment__icon svg { width: 13px; height: 13px; }

.attachment__info { flex: 1; min-width: 0; }

.attachment__label {
  font-size: .62rem;
  color: var(--blue);
  font-weight: 600;
}

.attachment__title {
  font-size: .72rem;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attachment__actions {
  display: flex;
  gap: .3rem;
  flex-shrink: 0;
}

/* Action panel (right side) */
.course-card__actions {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .45rem;
  min-width: 88px;
}

.code-box {
  text-align: center;
  padding: .45rem .55rem;
  border: 1.5px dashed rgba(123, 108, 246, 0.35);
  border-radius: 10px;
  background: rgba(237, 233, 254, 0.4);
  min-width: 80px;
}

.code-box__label {
  font-size: .58rem;
  color: var(--ink-3);
  display: block;
}

.code-box__value {
  font-family: 'SF Mono', Consolas, monospace;
  font-size: .95rem;
  font-weight: 700;
  letter-spacing: .12em;
  color: var(--purple);
  display: block;
  margin-top: .1rem;
}

.action-btns {
  display: flex;
  gap: .35rem;
}

.btn-action {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  transition: transform .15s, box-shadow .15s;
}

.btn-action svg { width: 16px; height: 16px; }

.btn-action:active { transform: scale(.93); }

.btn-action--copy {
  background: var(--bg);
  color: var(--ink-2);
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.btn-action--copy:active {
  background: var(--purple-light);
  color: var(--purple);
}

.btn-action--open {
  background: var(--purple-grad);
  color: #fff;
  box-shadow: 0 3px 10px rgba(123, 108, 246, 0.35);
}

.btn-action--sm {
  width: 28px;
  height: 28px;
  border-radius: 7px;
}

.btn-action--sm svg { width: 13px; height: 13px; }

/* ===== States ===== */
.state-box {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--ink-3);
}

.state-box--empty { padding: 2.5rem 1rem; }

.state-box__spinner {
  width: 28px;
  height: 28px;
  margin: 0 auto .75rem;
  border: 2.5px solid rgba(123, 108, 246, 0.2);
  border-top-color: var(--purple);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}

.state-box__title {
  font-size: .92rem;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: .25rem;
}

.state-box__sub {
  font-size: .8rem;
  margin-bottom: 1rem;
}

.btn-outline {
  padding: .5rem 1.25rem;
  font-size: .82rem;
  font-family: inherit;
  font-weight: 600;
  color: var(--purple);
  background: var(--purple-light);
  border: none;
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.hidden { display: none !important; }

/* ===== Footer ===== */
.site-footer {
  margin-top: 1.5rem;
}

.footer-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .85rem 1rem;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(148, 163, 184, 0.12);
  flex-wrap: wrap;
}

.footer-banner__left {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .75rem;
  color: var(--ink-2);
  flex: 1;
  min-width: 0;
}

.footer-banner__left svg {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: var(--purple);
}

.footer-banner__btn {
  flex-shrink: 0;
  padding: .45rem .9rem;
  font-size: .75rem;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
  background: var(--purple-grad);
  border-radius: var(--radius-pill);
  box-shadow: 0 3px 10px rgba(123, 108, 246, 0.3);
  white-space: nowrap;
}

.footer-copy {
  text-align: center;
  font-size: .68rem;
  color: var(--ink-3);
  margin-top: .75rem;
  opacity: .7;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: calc(1.25rem + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: .45rem;
  padding: .65rem 1.2rem;
  font-size: .85rem;
  font-weight: 500;
  color: #fff;
  background: var(--purple-grad);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  transition: opacity .3s, transform .3s;
}

.toast.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(16px);
  pointer-events: none;
}

.toast svg { width: 16px; height: 16px; }

/* ===== Animations ===== */
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes spin { to { transform: rotate(360deg); } }

.noscript {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 9999;
}

/* ===== Mobile card layout ===== */
@media (max-width: 600px) {
  .course-card {
    flex-wrap: wrap;
    gap: .75rem;
  }

  .course-card__thumb {
    width: 56px;
    height: 56px;
  }

  .course-card__thumb svg { width: 22px; height: 22px; }

  .course-card__actions {
    width: 100%;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    min-width: unset;
    padding-top: .5rem;
    border-top: 1px solid rgba(148, 163, 184, 0.12);
  }

  .code-box { flex: 1; }

  .hero__decor { display: none; }

  .stats-row { gap: .5rem; }

  .stat-card { padding: .7rem .55rem; }

  .stat-card__num { font-size: 1.1rem; }

  .footer-banner {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }

  .footer-banner__left { justify-content: center; }

  .footer-banner__btn { text-align: center; }
}

@media (min-width: 768px) {
  .app { padding-left: 1.5rem; padding-right: 1.5rem; }
  .course-list { gap: .85rem; }
}
