@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@600;700&family=Nunito:wght@400;600;700;800&display=swap');

:root {
  /* Warm cream base, per Discover page spec */
  --bg: #fbf2e4;
  --surface: #fffcf6;
  --text: #3b2a1a;
  --text-muted: #8a7863;
  --border: #eee1d0;
  --accent: #4b7c63;        /* muted forest green, used sparingly */
  --accent-text: #ffffff;

  /* Extended palette for categories/decoration */
  --terracotta: #d98b62;
  --peach: #f3c9a0;
  --dusty-pink: #e7b8b8;
  --soft-yellow: #f2d98b;
  --sage: #a9c3a2;

  /* Handwritten heading font + readable sans body font */
  --font-heading: 'Caveat', cursive;
  --font-body: 'Nunito', system-ui, sans-serif;
  --font-size-base: 18px;
  --font-size-sm: 14px;
  --font-size-lg: 24px;
  --font-size-xl: 40px;

  /* Spacing: every gap is a multiple of this */
  --space: 16px;

  /* Rounded corners + subtle shadow, everywhere */
  --radius: 20px;
  --shadow: 0 4px 14px rgba(59, 42, 26, 0.08);

  --nav-height: 68px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  line-height: 1.5;
  padding-bottom: var(--nav-height);
}

h1, h2, h3 {
  margin: 0 0 var(--space);
  font-weight: 700;
}

h1 { font-size: var(--font-size-xl); }
h2 { font-size: var(--font-size-lg); }

a {
  color: var(--accent);
}

.site-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space);
  padding: var(--space);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.site-header h1 {
  margin: 0;
  font-family: var(--font-heading);
  font-size: calc(var(--font-size-xl) * 1.1);
  line-height: 1;
}

.page-intro {
  color: var(--text-muted);
  margin: calc(var(--space) / 4) 0 0;
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: calc(var(--space) * 1.5);
}

.section-title h2 {
  margin: 0;
  font-family: var(--font-heading);
  font-size: calc(var(--font-size-xl) * 0.7);
}

.section-title a {
  font-size: var(--font-size-sm);
  font-weight: 700;
  text-decoration: none;
}

.page {
  position: relative;
  min-width: 0;
  padding: var(--space);
  max-width: 960px;
  margin: 0 auto;
  overflow: hidden;
}

@media (min-width: 640px) {
  .site-header {
    padding: var(--space) calc(var(--space) * 1.5);
  }

  .page {
    padding: calc(var(--space) * 1.5);
  }
}

/* Desktop: wider canvas, top nav instead of bottom tab bar, search bar always visible */
@media (min-width: 1024px) {
  body {
    padding-bottom: 0;
  }

  .site-header {
    padding: var(--space) calc(var(--space) * 2);
  }

  body {
    display: flex;
    flex-direction: column;
  }

  .site-header { order: 1; }
  .bottom-nav { order: 2; }
  .page { order: 3; }

  .page {
    max-width: 1200px;
    padding: calc(var(--space) * 1.5) calc(var(--space) * 2);
  }

  .icon-btn {
    display: none;
  }
}

/* Circular icon button, e.g. header search toggle */
.icon-btn {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: var(--bg);
  color: var(--text);
  font-size: var(--font-size-lg);
  box-shadow: var(--shadow);
  cursor: pointer;
}

/* Search bar: collapsed by default, expands under the circular search button */
.search-bar {
  display: none;
  gap: calc(var(--space) / 2);
  padding: var(--space);
  margin-top: var(--space);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.search-bar.is-open {
  display: flex;
  flex-wrap: wrap;
}

.search-bar input[type="search"] {
  flex: 1 1 100%;
  min-width: 0;
  padding: calc(var(--space) / 2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: var(--font-size-base);
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
}

.search-bar .btn {
  flex: 1 1 100%;
}

@media (min-width: 480px) {
  .search-bar input[type="search"] {
    flex: 1 1 auto;
  }

  .search-bar .btn {
    flex: 0 0 auto;
  }
}

@media (min-width: 1024px) {
  .search-bar {
    display: flex;
    margin-top: 0;
  }
}

/* Pill-style Age / Topic / Area filters */
.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: calc(var(--space) / 2);
  margin-top: var(--space);
}

.filter-pill {
  display: flex;
  align-items: center;
  gap: calc(var(--space) / 4);
  padding: calc(var(--space) / 2) var(--space);
  border: none;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--font-size-sm);
  font-weight: 700;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.filter-pill .pill-value {
  color: var(--text-muted);
  font-weight: 400;
}

.filter-pill[aria-expanded="true"] {
  background: var(--sage);
}

.filter-pill select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.filter-pill {
  position: relative;
}

/* Lesson plan cards: two-column, picture-forward grid */
.lesson-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: calc(var(--space) / 2);
  margin-top: var(--space);
}

@media (min-width: 640px) {
  .lesson-grid {
    gap: var(--space);
  }
}

@media (min-width: 1024px) {
  .lesson-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.lesson-card {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.lesson-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  background: var(--border);
}

.lesson-card-body {
  padding: calc(var(--space) / 2) var(--space) var(--space);
}

.lesson-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: calc(var(--space) / 4);
}

.save-btn {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--text-muted);
  font-size: var(--font-size-lg);
  line-height: 1;
  cursor: pointer;
}

.save-btn[aria-pressed="true"] {
  color: var(--terracotta);
}

.lesson-card-title {
  font-family: var(--font-heading);
  font-size: calc(var(--font-size-lg) * 1.1);
  font-weight: 700;
  line-height: 1.1;
  margin: 0;
  color: inherit;
  text-decoration: none;
}

.lesson-card-meta {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin: calc(var(--space) / 4) 0 0;
}

.lesson-card-stats {
  display: flex;
  gap: var(--space);
  margin: calc(var(--space) / 2) 0 0;
  padding-top: calc(var(--space) / 2);
  border-top: 1px solid var(--border);
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

/* Buttons: single accent color, used sparingly */
.btn {
  display: inline-block;
  padding: calc(var(--space) / 2) var(--space);
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-text);
  font-size: var(--font-size-base);
  cursor: pointer;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

/* Persistent bottom navigation on mobile; becomes a top nav bar on desktop */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--nav-height);
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 10px rgba(59, 42, 26, 0.06);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: var(--font-size-sm);
  font-weight: 700;
  text-decoration: none;
}

.nav-item .nav-icon {
  font-size: var(--font-size-lg);
}

.nav-item.is-active {
  color: var(--accent);
}

@media (min-width: 1024px) {
  .bottom-nav {
    position: static;
    height: auto;
    justify-content: flex-end;
    gap: calc(var(--space) * 1.5);
    padding: var(--space) calc(var(--space) * 2) 0;
    border-top: none;
    box-shadow: none;
  }

  .nav-item {
    flex: 0 0 auto;
    flex-direction: row;
    gap: calc(var(--space) / 4);
  }
}

/* Lesson detail page */
.header-title-row {
  display: flex;
  align-items: center;
  gap: var(--space);
}

.header-actions {
  display: flex;
  gap: calc(var(--space) / 2);
  flex: 0 0 auto;
}

.detail-title {
  font-family: var(--font-heading);
  font-size: calc(var(--font-size-xl) * 1.1);
  line-height: 1;
  margin: 0;
}

.lesson-detail-hero {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: block;
}

.lesson-detail-gallery {
  display: flex;
  gap: calc(var(--space) / 2);
  margin-top: calc(var(--space) / 2);
}

.lesson-detail-gallery img {
  flex: 1;
  min-width: 0;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.lesson-detail-info {
  margin-top: calc(var(--space) * 1.5);
}

.lesson-detail-badges {
  display: flex;
  flex-wrap: wrap;
  gap: calc(var(--space) / 2);
  margin: 0 0 var(--space);
}

.badge {
  display: inline-block;
  padding: calc(var(--space) / 4) calc(var(--space) / 1.5);
  border-radius: 999px;
  background: var(--sage);
  color: var(--text);
  font-size: var(--font-size-sm);
  font-weight: 700;
}

.lesson-detail-list {
  padding-left: 1.25em;
  margin: 0 0 var(--space);
}

.lesson-detail-list li {
  margin-bottom: calc(var(--space) / 4);
}

.section-optional {
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: var(--font-size-sm);
  font-weight: 400;
}

.lesson-audio {
  width: 100%;
}

.mark-complete-btn {
  display: block;
  width: 100%;
  margin-top: calc(var(--space) / 2);
}

.lesson-meta-line {
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  margin: 0 0 var(--space);
}

.lesson-summary {
  background: var(--bg);
  border-radius: var(--radius);
  padding: var(--space);
  margin: 0 0 var(--space);
  color: var(--text);
}

.skills-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: calc(var(--space) / 2);
  margin: 0 0 calc(var(--space) * 1.5);
}

.skill-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(var(--space) / 4);
  text-align: center;
}

.skill-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--category-color, var(--sage));
  font-size: var(--font-size-lg);
}

.skill-label {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

.checklist {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--space);
}

.checklist li {
  margin-bottom: calc(var(--space) / 2);
}

.checklist label {
  display: flex;
  align-items: center;
  gap: calc(var(--space) / 2);
  cursor: pointer;
}

.checklist input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
  flex: 0 0 auto;
}

.steps-list {
  list-style: none;
  counter-reset: step;
  padding: 0;
  margin: 0 0 var(--space);
}

.steps-list li {
  position: relative;
  padding-left: calc(var(--space) * 2);
  margin-bottom: var(--space);
  counter-increment: step;
  min-height: 28px;
}

.steps-list li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--terracotta);
  color: var(--accent-text);
  font-size: var(--font-size-sm);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cta-save-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: calc(var(--space) / 2);
  width: 100%;
  font-weight: 700;
}

.cta-save-btn[aria-pressed="true"] {
  background: var(--sage);
  color: var(--text);
}

@media (min-width: 1024px) {
  .lesson-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: calc(var(--space) * 2);
    align-items: start;
  }

  .lesson-detail-info {
    margin-top: 0;
  }
}

/* My Week page */
.week-tabs {
  display: flex;
  gap: calc(var(--space) / 4);
  padding: calc(var(--space) / 4);
  background: var(--surface);
  border-radius: 999px;
  box-shadow: var(--shadow);
}

.week-tab {
  flex: 1;
  padding: calc(var(--space) / 2) var(--space);
  border: none;
  border-radius: 999px;
  background: none;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: var(--font-size-sm);
  font-weight: 700;
  cursor: pointer;
}

.week-tab[aria-selected="true"] {
  background: var(--bg);
  color: var(--text);
}

.week-list {
  display: flex;
  flex-direction: column;
  gap: calc(var(--space) / 2);
  margin-top: var(--space);
}

.week-list[hidden] {
  display: none;
}

.week-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space);
  padding: calc(var(--space) / 2);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.week-card-thumb {
  flex: 0 0 auto;
  display: block;
  width: 72px;
  height: 72px;
  border-radius: var(--radius);
  overflow: hidden;
}

.week-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.week-card-body {
  flex: 1;
  min-width: 0;
}

.week-card .save-btn {
  flex: 0 0 auto;
}

.week-card[hidden] {
  display: none;
}

.week-card-body {
  text-decoration: none;
  color: inherit;
  display: block;
}

.card-menu {
  position: relative;
  flex: 0 0 auto;
}

.card-menu-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--text-muted);
  font-size: var(--font-size-lg);
  line-height: 1;
  cursor: pointer;
}

.card-menu-panel {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 5;
  min-width: 180px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: calc(var(--space) / 4);
}

.card-menu-item {
  display: block;
  width: 100%;
  padding: calc(var(--space) / 2) var(--space);
  border: none;
  background: none;
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--font-size-sm);
  text-align: left;
  border-radius: calc(var(--radius) / 2);
  cursor: pointer;
}

.card-menu-item:hover {
  background: var(--bg);
}

.week-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space);
}

.fab {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  font-size: var(--font-size-xl);
  line-height: 1;
  text-decoration: none;
  box-shadow: var(--shadow);
}

.week-quote {
  font-family: var(--font-heading);
  font-size: var(--font-size-lg);
  text-align: center;
  color: var(--text-muted);
  margin-top: calc(var(--space) * 2);
}

.pml-toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-height) + var(--space));
  transform: translateX(-50%);
  background: var(--text);
  color: var(--surface);
  padding: calc(var(--space) / 2) var(--space);
  border-radius: 999px;
  font-size: var(--font-size-sm);
  box-shadow: var(--shadow);
  z-index: 20;
}

/* Account page */
.account-card {
  display: flex;
  align-items: center;
  gap: var(--space);
  padding: var(--space);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

#switch-account-link {
  display: block;
  width: 100%;
  text-align: center;
  text-decoration: none;
  margin-top: var(--space);
}

.account-fields {
  min-width: 0;
}

.account-photo {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 auto;
}

.account-name {
  font-family: var(--font-heading);
  font-size: calc(var(--font-size-xl) * 0.7);
  margin: 0;
  line-height: 1.1;
}

.account-email {
  color: var(--text-muted);
  margin: calc(var(--space) / 4) 0 var(--space);
  overflow-wrap: break-word;
}

.history-list {
  list-style: none;
  margin: var(--space) 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: calc(var(--space) / 2);
}

.history-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space);
  padding: var(--space);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.history-title {
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

.history-date {
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

/* Login / switch-account page */
.login-list {
  display: flex;
  flex-direction: column;
  gap: var(--space);
  margin-top: var(--space);
}

.login-card {
  display: flex;
  align-items: center;
  gap: var(--space);
  padding: var(--space);
  border: 2px solid transparent;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-family: var(--font-body);
  cursor: pointer;
  text-align: left;
}

.login-card.is-active {
  border-color: var(--accent);
}

.login-photo {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 auto;
}

.login-name {
  flex: 1;
  font-family: var(--font-heading);
  font-size: var(--font-size-lg);
  color: var(--text);
}

/* Decorative watercolor botanical shapes, purely visual */
.watercolor-decor {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 120px;
  pointer-events: none;
  z-index: -1;
  background:
    radial-gradient(circle at 10% 100%, var(--sage) 0%, transparent 60%),
    radial-gradient(circle at 50% 100%, var(--peach) 0%, transparent 55%),
    radial-gradient(circle at 90% 100%, var(--dusty-pink) 0%, transparent 60%);
  opacity: 0.25;
}
