/* ============================================================================
   layout.css · app shell (header, sidebar, content, footer) + home + syllabus
   ============================================================================ */

/* ============================ HEADER ====================================== */
.site-header {
  position: sticky; top: 0; z-index: 90;
  height: var(--header-h);
  display: flex; align-items: center; gap: var(--s-4);
  padding: 0 var(--s-5) 0 var(--s-4);
  background: color-mix(in srgb, var(--white) 86%, transparent);
  -webkit-backdrop-filter: saturate(170%) blur(14px);
  backdrop-filter: saturate(170%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.site-header::after { /* reading progress */
  content:""; position: absolute; left: 0; bottom: -1px; height: 3px;
  width: var(--read-progress, 0%);
  background: linear-gradient(90deg, var(--ocean-400), var(--ocean-600));
  box-shadow: 0 0 12px rgba(0,174,214,.6); transition: width .12s linear;
}
.brand-lockup { display: flex; align-items: center; gap: var(--s-3); text-decoration: none; }
.brand-lockup img { width: 40px; height: 40px; filter: drop-shadow(0 2px 4px rgba(12,63,77,.25)); }
.brand-lockup .brand-name {
  font-family: var(--font-display); font-size: 1.02rem; line-height: 1.05;
  color: var(--ink); letter-spacing: -.01em;
}
.brand-lockup .brand-name b { color: var(--ocean-700); font-weight: 700; }
.brand-lockup .brand-sub {
  display: block; font-family: var(--font-accent); font-size: .66rem;
  letter-spacing: .22em; color: var(--text-muted); text-transform: uppercase;
}
.header-spacer { flex: 1; }
.header-nav { display: flex; align-items: center; gap: var(--s-2); }
.header-nav a {
  font-family: var(--font-display); font-size: .9rem; color: var(--text-soft);
  padding: .5em .8em; border-radius: var(--r-sm);
  transition: background var(--t-fast), color var(--t-fast);
}
.header-nav a:hover { background: var(--ice-100); color: var(--ocean-800); }
.header-nav a.is-active { color: var(--ocean-800); background: var(--ice-100); }

.menu-toggle {
  display: none; width: 42px; height: 42px; border-radius: var(--r-sm);
  background: var(--white); border: 1px solid var(--line);
  align-items: center; justify-content: center; cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform var(--t-fast) var(--ease-out);
}
/* a touch more travel than the 0.97 house value — it's a large 42px tap target */
.menu-toggle:active { transform: scale(.94); }
.menu-toggle svg { width: 22px; height: 22px; stroke: var(--ink); }

/* ============================ APP SHELL =================================== */
.app-shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); align-items: start; }
body.layout-page .app-shell { grid-template-columns: 1fr; }

/* ============================ SIDEBAR ===================================== */
.sidebar {
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto; overscroll-behavior: contain;
  padding: var(--s-6) var(--s-4) var(--s-9) var(--s-6);
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, var(--ice-50), var(--white) 220px);
  scrollbar-width: thin; scrollbar-color: var(--slate-300) transparent;
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--slate-300); border-radius: 9px; }

.sidebar-head { margin-bottom: var(--s-5); }
.sidebar-progress-label {
  font-family: var(--font-display); font-size: .7rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--text-muted); margin-bottom: var(--s-2);
  display: flex; justify-content: space-between;
}
.progress-track { height: 8px; border-radius: 99px; background: var(--slate-200); overflow: hidden; }
.progress-fill {
  height: 100%; width: 0%; border-radius: 99px;
  background: linear-gradient(90deg, var(--ice-400), var(--ocean-500));
  transition: width var(--t-slow) var(--ease-out);
}

.nav-track { margin-bottom: var(--s-5); }
.nav-track-title {
  display: flex; align-items: center; gap: .5em;
  font-family: var(--font-display); font-size: .72rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ocean-700);
  padding: 0 0 var(--s-2) 0; margin-top: var(--s-4);
}
.nav-track-title .rule { flex: 1; height: 1px; background: var(--line); }

.nav-unit { margin-bottom: 2px; }
.nav-unit-btn {
  width: 100%; display: flex; align-items: center; gap: .5em;
  background: none; border: 0; cursor: pointer; text-align: left;
  padding: .5em .55em; border-radius: var(--r-sm); color: var(--text-soft);
  font-family: var(--font-display); font-size: .9rem;
  transition: background var(--t-fast), transform var(--t-fast) var(--ease-out);
}
.nav-unit-btn:hover { background: var(--ice-100); }
/* deliberately the subtlest press in the system — sidebar nav is a tens-of-times-a-day surface */
.nav-unit-btn:active { transform: scale(.98); }
.nav-unit-btn .chev { width: 16px; height: 16px; stroke: var(--slate-400); transition: transform var(--t-med) var(--ease-spring); flex: none; }
.nav-unit[aria-expanded="false"] .chev { transform: rotate(-90deg); }
.nav-unit-num {
  font-family: var(--font-accent); font-size: .72rem; color: var(--ocean-700);
  background: var(--ice-100); border-radius: 6px; padding: .1em .42em; flex: none;
}
.nav-unit-name { flex: 1; }
.nav-unit[aria-expanded="false"] .nav-lessons { display: none; }

.nav-lessons { list-style: none; padding: 2px 0 6px 0; margin-left: 14px; border-left: 1.5px solid var(--line); }
.nav-lessons a {
  display: flex; align-items: center; gap: .55em;
  padding: .4em .6em .4em .8em; margin-left: -1.5px;
  border-left: 1.5px solid transparent; color: var(--text-soft);
  font-size: .92rem; line-height: 1.3; border-radius: 0 var(--r-sm) var(--r-sm) 0;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.nav-lessons a:hover { background: var(--ice-50); color: var(--ocean-800); }
.nav-lessons a.is-current {
  background: var(--ice-100); color: var(--ocean-900); font-weight: 600;
  border-left-color: var(--ocean-500);
}
.nav-check {
  width: 17px; height: 17px; border-radius: 50%; flex: none;
  border: 1.5px solid var(--slate-300); display: grid; place-items: center;
  background: var(--white); transition: all var(--t-fast);
}
.nav-check svg { width: 11px; height: 11px; stroke: #fff; opacity: 0; }
a.is-done .nav-check { background: var(--good); border-color: var(--good); }
a.is-done .nav-check svg { opacity: 1; }
a.is-locked { opacity: .5; }
.nav-lessons a .nav-lock { width: 13px; height: 13px; stroke: var(--slate-400); margin-left: auto; }

/* ============================ CONTENT ==================================== */
.content { min-width: 0; padding: var(--s-8) var(--s-8) var(--s-12); }
.content-inner { max-width: var(--content-max); margin-inline: auto; }
body.layout-page .content { padding: 0; }

/* ============================ FOOTER ===================================== */
.site-footer {
  background:
    radial-gradient(120% 140% at 100% 0%, var(--ocean-500), transparent 60%),
    linear-gradient(180deg, var(--ocean-600), var(--ocean-800));
  color: #eaf9fd; padding: var(--s-9) 0 var(--s-6);
}
.site-footer .container { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: var(--s-8); }
.footer-brand { display: flex; gap: var(--s-4); align-items: flex-start; }
.footer-brand img { width: 64px; height: 64px; background: rgba(255,255,255,.12); border-radius: var(--r-md); padding: 6px; }
.footer-brand h3 { color: #fff; font-size: 1.2rem; margin-bottom: .2em; }
.footer-brand p { color: #cdeef6; font-size: .92rem; max-width: 34ch; }
.footer-col h4 { color: #bdeaf4; font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; margin-bottom: var(--s-3); font-family: var(--font-display); }
.footer-col a { display: block; color: #e7f8fc; padding: .25em 0; font-size: .94rem; opacity: .92; }
.footer-col a:hover { color: #fff; opacity: 1; padding-left: 4px; transition: padding var(--t-fast); }
.footer-bottom {
  margin-top: var(--s-8); padding-top: var(--s-5); border-top: 1px solid rgba(255,255,255,.18);
  display: flex; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap;
  color: #bfe9f3; font-size: .85rem;
}
.footer-bottom .u-mono { color: #dff6fb; }

/* ============================ MOBILE ===================================== */
.scrim { position: fixed; inset: 0; background: rgba(12,40,48,.46); opacity: 0; pointer-events: none; transition: opacity var(--t-med); z-index: 95; }
@media (max-width: 980px) {
  :root { --sidebar-w: 290px; }
  .app-shell { grid-template-columns: 1fr; }
  .menu-toggle { display: inline-flex; }
  .header-nav { display: none; }
  .sidebar {
    position: fixed; top: var(--header-h); left: 0; z-index: 96;
    width: 86vw; max-width: 340px; height: calc(100vh - var(--header-h));
    transform: translateX(-104%); transition: transform var(--t-med) var(--ease-out);
    box-shadow: var(--shadow-xl);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .scrim { opacity: 1; pointer-events: auto; }
  .content { padding: var(--s-6) var(--s-5) var(--s-10); }
  .site-footer .container { grid-template-columns: 1fr; gap: var(--s-6); }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  .brand-lockup .brand-sub { display: none; }
  .content { padding: var(--s-5) var(--s-4) var(--s-9); }
}
