/* StudyPal - Shared Theme */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Shared palette is defined in palette.css. */

}

/* Existing reading layouts retain typography; palette is global. */
body.terracotta-linen {
  --font-ui: 'Nunito Sans', system-ui, sans-serif;
  font-family: var(--font-ui);
}
body.terracotta-linen :is(button, input, select, textarea) { font-family: var(--font-ui); }
body.terracotta-linen :is(a, button, input, select, textarea):focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  min-height: 100vh;
  padding-bottom: 80px;
  -webkit-tap-highlight-color: transparent;
  color: var(--text);
}

/* Shared Navigation - Mobile First */
:is(a, button, input, select, textarea, summary):focus-visible { outline: 3px solid var(--primary-dark); outline-offset: 3px; }
.app-skip-link { position: fixed; top: 8px; left: 8px; z-index: 1000; padding: 12px 18px; background: var(--card); color: var(--text); border: 2px solid var(--primary-dark); border-radius: 6px; }
.app-skip-link:not(:focus) { clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; white-space: nowrap; padding: 0; border: 0; }
[tabindex="-1"] { scroll-margin-top: 120px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }
@media print { .app-nav, .app-footer, .app-skip-link { display: none !important; } }
.app-nav {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 2px rgba(15,23,42,0.03);
}

.app-nav-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  font-size: 17px;
  letter-spacing: 0.02em;
}

.app-nav-logo span { font-size: 1.3em; }

.app-nav-brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.app-build-badge,
.app-footer-build {
  font-size: 0.66rem;
  color: var(--text-light);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.app-nav-links {
  display: none;
}
.app-nav-links.is-open { display: flex; }
.app-nav-links { flex-wrap: wrap; min-width: 0; }
.app-menu-toggle { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 10px 16px; min-height: 44px; cursor: pointer; }
.app-nav-link { color: var(--text-secondary); text-decoration: none; padding: 12px; min-height: 44px; border-radius: 6px; font-size: .9rem; }
.app-nav-link.active { color: var(--primary-dark); background: var(--primary-light); font-weight: 700; }
.app-version { font-size: .75rem; color: var(--text-secondary); }
.app-version summary { cursor: pointer; padding: 4px 0; }
#app-child-switcher { font-size: .85rem; max-width: 100%; }
#app-child-switcher label, #child-switch-status { display: block; }
#childSwitcherSelect { font: var(--ctl-font, inherit); font-weight: 400; padding: 0 8px; min-height: var(--ctl-h, 34px); max-width: 100%; border: 1px solid var(--border); border-radius: 6px; background: var(--card); color: var(--text); }
.app-build-badge { white-space: normal; overflow-wrap: anywhere; max-width: 30ch; }
@media (max-width: 767px) {
  .app-nav-links { width: 100%; max-height: 55dvh; overflow-y: auto; gap: 4px; }
  .app-nav-link { flex: 1 0 40%; }
}

/* Shared Footer - Mobile Optimized */
.app-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 7px 8px max(10px, env(safe-area-inset-bottom));
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
  box-shadow: 0 -1px 6px rgba(15,23,42,0.05);
}

.app-footer-link {
  color: var(--text-secondary);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 0.7em;
  font-weight: 600;
  transition: all 0.2s;
  padding: 4px 8px;
  min-width: 0;
  min-height: 44px;
  flex: 1;
  justify-content: center;
}

.app-footer-link span.icon { font-size: 1.6em; }

.app-footer-link:hover,
.app-footer-link.active {
  color: var(--primary);
}

.app-footer-link.active span.icon {
  transform: scale(1.1);
}

.app-footer {
  flex-wrap: wrap;
}

.app-footer-build {
  width: 100%;
  text-align: center;
  padding-top: 4px;
}

/* Cards */
.card {
  background: var(--card);
  border-radius: 10px;
  padding: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(15,23,42,0.03);
}

/* Buttons - Touch Friendly */
.btn {
  background: var(--action);
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  border: none;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: none;
  min-height: 44px;
  touch-action: manipulation;
}

.btn:hover { transform: none; background: var(--action-hover); }
.btn:active { transform: none; box-shadow: none; }

/* Page container */
.page-content {
  padding: 16px;
  max-width: 100%;
  margin: 0 auto;
}

/* Tablet+ Styles */
@media (min-width: 768px) {
  .app-nav {
    padding: 10px 24px;
  }

  .app-nav-logo {
    font-size: 17px;
  }

  .app-nav-links {
    display: flex;
    gap: 8px;
  }
  .app-menu-toggle { display: none; }

  .app-nav-brand {
    gap: 1px;
  }

  .app-nav-link {
    color: var(--text-light);
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.9em;
    transition: all 0.2s;
  }

  .app-nav-link:hover,
  .app-nav-link.active {
    background: var(--primary-light);
    color: var(--primary);
  }

  .app-nav-link.active {
    background: transparent;
    color: var(--primary);
    box-shadow: inset 0 -2px 0 var(--primary);
    border-radius: 0;
  }

  .app-footer {
    display: none;
  }

  .page-content {
    padding: 24px;
    max-width: 1280px;
  }

  .card {
    padding: 20px;
  }
}

/* Animations */
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(-5deg); }
  50% { transform: translateY(-15px) rotate(5deg); }
}

/* Eleven top-level links was a menu bar nobody could scan. Four that matter,
   and everything else behind More. */
.app-nav-more { position: relative; }
.app-nav-more > summary { list-style: none; cursor: pointer; }
.app-nav-more > summary::-webkit-details-marker { display: none; }
.app-nav-more > summary::after { content: ' \25BE'; font-size: .75em; opacity: .7; }
.app-nav-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 60;
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(28, 25, 23, .12); padding: 6px; min-width: 172px;
  display: flex; flex-direction: column;
}
.app-nav-menu a {
  padding: 8px 12px; border-radius: 6px; text-decoration: none;
  color: var(--text-secondary); font-size: .9rem; white-space: nowrap;
}
.app-nav-menu a:hover { background: var(--card-alt); color: var(--text); }
@media (max-width: 860px) {
  .app-nav-more { position: static; }
  .app-nav-menu { position: static; box-shadow: none; border: 0; padding: 0 0 0 10px; }
}

.app-nav-add { background: var(--action); color: var(--on-action) !important; border-radius: var(--ctl-r, 6px); padding: 0 14px; min-height: var(--ctl-h, 34px); display: inline-flex; align-items: center; font: var(--ctl-font, inherit); font-weight: 700; }
.app-nav-add:hover { background: var(--action-hover); }
.app-footer-add { background: var(--action); color: var(--on-action) !important; border-radius: 10px; margin: 4px 6px; font-weight: 800; }

/* One compact page header. Title and tagline share a line, the way the Day page
   already does; Library, Test Plan and Schedule were each burning ~220px of phone
   screen before the first piece of content. Opt-in class so a hero carrying extra
   furniture (the home stats bar) is left alone. */
body .hero.compact {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px;
  padding: 14px 0 10px; margin-bottom: 14px;
  border-bottom: 1px solid var(--border, #d8e3e1);
}
body .hero.compact h1 { margin: 0; font-size: 1.5rem; line-height: 1.2 }
body .hero.compact > p {
  margin: 0; font-size: .875rem; color: var(--text-secondary, #5b6f76);
  flex: 1 1 12ch; min-width: 0;
}
@media (max-width: 480px) { body .hero.compact h1 { font-size: 1.3rem } }
