/* ---------- tokens ---------- */
:root {
  --paper: #f4f6f3;
  --paper-2: #eaeee9;
  --card: #ffffff;
  --ink: #16302b;
  --ink-soft: #4d605b;
  --line: #cdd7d2;
  --pond: #1e6f5c;
  --pond-soft: #dcebe4;
  --pen: #c2382e;
  --shadow: 0 1px 2px rgba(22, 48, 43, .06), 0 8px 24px -12px rgba(22, 48, 43, .18);
  --sidebar: 268px;
  --measure: 66ch;
  --serif: "EB Garamond", Garamond, "Times New Roman", serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f1b18; --paper-2: #14231f; --card: #182a25;
    --ink: #e7ede9; --ink-soft: #a6b5af; --line: #2b3d38;
    --pond: #6fc3a7; --pond-soft: #1d3a33; --pen: #e8695f;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}
:root[data-theme="kelp"] {
  --paper: #0d2e28; --paper-2: #113830; --card: #154139;
  --ink: #eaf5ee; --ink-soft: #a3c9b6; --line: #27564b;
  --pond: #8fdcb8; --pond-soft: #1f5446; --pen: #f28b74;
  --shadow: 0 1px 2px rgba(0,0,0,.35), 0 8px 24px -12px rgba(0,0,0,.55);
  color-scheme: dark;
}
:root[data-theme="dark"] {
  --paper: #0f1b18; --paper-2: #14231f; --card: #182a25;
  --ink: #e7ede9; --ink-soft: #a6b5af; --line: #2b3d38;
  --pond: #6fc3a7; --pond-soft: #1d3a33; --pen: #e8695f;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.6);
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { animation: none !important; transition: none !important; } }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.2rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--pond); text-decoration-thickness: 1px; text-underline-offset: .15em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--pen); outline-offset: 3px; border-radius: 2px; }
h1, h2, h3 { font-weight: 500; line-height: 1.15; margin: 0 0 .5em; letter-spacing: -.005em; }
h1 { font-size: clamp(2.1rem, 4vw, 2.9rem); }
h2 { font-size: 1.55rem; }
p { margin: 0 0 1em; }
cite { font-style: italic; }
button { font: inherit; color: inherit; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--card); padding: .5rem 1rem; z-index: 100; }
.skip:focus { left: 8px; }

/* ---------- sidebar ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar);
  padding: 2.2rem 1.6rem 1.6rem;
  border-right: 1px solid var(--line);
  background: var(--paper);
  display: flex; flex-direction: column; gap: 1.8rem;
  overflow-y: auto; z-index: 20;
}
.brand { text-decoration: none; color: inherit; display: block; }
.brand-name { display: block; font-size: 1.5rem; font-weight: 500; }
.brand-role { display: block; color: var(--ink-soft); font-style: italic; }
.toc, .toc ol { list-style: none; margin: 0; padding: 0; }
.toc > li + li { margin-top: .2rem; }
.toc ol { margin: .15rem 0 .35rem 1rem; border-left: 1px solid var(--line); padding-left: .8rem; }
.toc ol a { font-size: 1.05rem; color: var(--ink-soft); }
.toc a {
  display: inline-block; position: relative; text-decoration: none; color: var(--ink);
  padding: .15rem 0; line-height: 1.3;
}
.toc a:hover { color: var(--pond); }
.toc a[aria-current="page"] { color: var(--ink); }
.toc a[aria-current="page"]::after {
  content: ""; position: absolute; left: -2px; right: -2px; bottom: 0; height: 3px;
  background: var(--pen); border-radius: 2px 3px 2px 3px;
  transform-origin: left; animation: pen-draw .45s cubic-bezier(.2,.8,.2,1) both;
}
.toc ol a[aria-current="page"] { color: var(--ink); }
@keyframes pen-draw { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: .3rem; font-size: 1rem; color: var(--ink-soft); }
.sidebar-foot a { color: var(--ink-soft); }
.theme-picker { display: inline-flex; align-self: flex-start; margin-top: .6rem; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.theme-picker button { background: none; border: 0; padding: .2rem .7rem; font-size: .95rem; cursor: pointer; color: var(--ink-soft); }
.theme-picker button + button { border-left: 1px solid var(--line); }
.theme-picker button:hover { color: var(--pond); }
.theme-picker button[aria-pressed="true"] { background: var(--pond-soft); color: var(--ink); }

.topbar { display: none; }
.scrim { display: none; }

/* ---------- kelp banner (Kelp theme only) ---------- */
.kelp-band { display: none; }
:root[data-theme="kelp"] .kelp-band {
  display: block; position: relative; height: clamp(150px, 26vh, 280px);
  margin: -3.2rem calc(-1 * clamp(1rem, 5vw, 4.5rem)) 2.6rem;
  background: url(/assets/kelp-banner.jpg) center 40% / cover no-repeat;
}
:root[data-theme="kelp"] .kelp-band::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(13,46,40,.25) 0%, rgba(13,46,40,.15) 55%, var(--paper) 100%);
}
:root[data-theme="kelp"] .sidebar { background: linear-gradient(180deg, rgba(13,46,40,.92), rgba(13,46,40,.97)), url(/assets/kelp-banner.jpg) center / cover no-repeat; }

/* ---------- content ---------- */
.content { margin-left: var(--sidebar); padding: 3.2rem clamp(1rem, 5vw, 4.5rem) 4rem; min-height: 100vh; }
.page { display: none; max-width: 62rem; animation: page-in .35s ease both; }
.page.is-active { display: block; }
@keyframes page-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.prose { max-width: var(--measure); }
.prose p.opener { font-size: 1.32rem; }
.prose .pull { font-size: 1.6rem; line-height: 1.25; font-style: italic; margin: 1.6rem 0; padding-left: 1rem; border-left: 3px solid var(--pen); }
.intro { max-width: var(--measure); color: var(--ink-soft); font-size: 1.25rem; margin-bottom: 1.8rem; }
.section-title { margin-top: 3rem; font-size: 1.15rem; font-weight: 500; color: var(--ink-soft); font-style: italic; }
.crumb { display: inline-block; font-size: 1rem; color: var(--ink-soft); margin-bottom: .6rem; }
.crumb::before { content: "↖ "; }
.pager { margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--line); font-size: 1.1rem; }
.foot { margin-top: 5rem; padding-top: 1rem; border-top: 1px solid var(--line); color: var(--ink-soft); font-size: 1rem; }

/* ---------- home ---------- */
.hero { display: grid; grid-template-columns: minmax(220px, 340px) minmax(0, 1fr); gap: clamp(1.5rem, 4vw, 3.5rem); align-items: start; }
.hero-photo { margin: 0; }
.hero-photo img { border-radius: 4px; box-shadow: var(--shadow); aspect-ratio: 3/4; object-fit: cover; }
.hero-photo figcaption, .figure figcaption { font-style: italic; color: var(--ink-soft); font-size: 1.05rem; margin-top: .6rem; }
.display { font-size: clamp(2.6rem, 6vw, 4.2rem); margin-bottom: .1em; }
.role { font-size: 1.5rem; font-style: italic; color: var(--ink-soft); margin-bottom: 1.2rem; }
.license { display: flex; align-items: center; gap: .6rem; margin: -.6rem 0 1.4rem; font-size: 1.05rem; color: var(--ink-soft); }
.stamp { display: inline-grid; place-items: center; width: 3.1rem; height: 3.1rem; border: 2px solid var(--pen); border-radius: 50%; color: var(--pen); font-size: .82rem; font-weight: 600; letter-spacing: .06em; transform: rotate(-8deg); box-shadow: inset 0 0 0 2px var(--paper), inset 0 0 0 3px var(--pen); flex: none; }
.lede { font-size: 1.35rem; max-width: 34ch; }
.contact { display: grid; gap: .5rem; margin: 1.8rem 0 0; font-size: 1.1rem; }
.contact div { display: grid; grid-template-columns: 6rem 1fr; gap: .5rem; }
.contact dt { color: var(--ink-soft); font-style: italic; }
.contact dd { margin: 0; }

.tiles { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .8rem; }
.tiles a {
  display: block; height: 100%; padding: 1rem 1.1rem 1.1rem; text-decoration: none; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: 6px;
}
.tiles a:hover { border-color: var(--pond); }
.tiles strong { display: block; font-weight: 500; font-size: 1.25rem; }
.tiles span { display: block; color: var(--ink-soft); font-size: 1rem; line-height: 1.35; margin-top: .2rem; }

/* ---------- covers (lesson plans) ---------- */
.covers { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 1.6rem; }
.covers a { display: block; text-decoration: none; color: var(--ink); }
.covers img { aspect-ratio: 3/4; object-fit: cover; border-radius: 3px; box-shadow: var(--shadow); transition: transform .25s ease; }
.covers a:hover img { transform: translateY(-3px) rotate(-.6deg); }
.covers strong { display: block; font-weight: 500; font-size: 1.2rem; margin-top: .8rem; line-height: 1.25; }
.covers span { display: block; color: var(--ink-soft); font-size: 1rem; margin-top: .2rem; }

/* ---------- galleries / figures ---------- */
.gallery { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.gallery img, .figure img { border-radius: 3px; box-shadow: var(--shadow); background: var(--card); }
.figure { margin: 1.5rem 0 2rem; max-width: 46rem; }
.zoomable { cursor: zoom-in; }

/* ---------- pdf frames ---------- */
.pdf-frame { margin: 1.5rem 0; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: var(--card); }
.pdf-bar { display: flex; align-items: center; gap: .6rem; padding: .5rem .8rem; border-bottom: 1px solid var(--line); font-size: 1rem; }
.pdf-bar .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pdf-frame iframe { display: block; width: 100%; height: min(78vh, 900px); border: 0; background: var(--paper-2); }
.pdf-frame.compact iframe { height: 420px; }
.pdf-frame.is-loading iframe { opacity: 0; }
.pdf-note { padding: .6rem .8rem; font-size: .95rem; color: var(--ink-soft); }

.btn { display: inline-block; font-size: 1rem; padding: .3rem .85rem; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--ink); text-decoration: none; cursor: pointer; line-height: 1.4; }
.btn:hover { border-color: var(--pond); color: var(--pond); }
.page-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .8rem 1.5rem; margin-bottom: 1rem; }
.head-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---------- resume ---------- */
.resume { max-width: 52rem; }
.resume-meta { color: var(--ink-soft); font-size: 1.05rem; margin-bottom: 1rem; }
.resume-summary { font-size: 1.2rem; max-width: var(--measure); }
.resume h2 { margin: 2rem 0 .8rem; padding-bottom: .3rem; border-bottom: 1px solid var(--line); font-size: 1.3rem; }
.entry { display: grid; grid-template-columns: 9.5rem 1fr; gap: 1.2rem; margin-bottom: 1.2rem; }
.when { color: var(--ink-soft); font-size: 1.05rem; padding-top: .15rem; }
.what strong { font-weight: 500; }
.what em { display: inline-block; color: var(--ink-soft); }
.what ul { margin: .4rem 0 0; padding-left: 1.2rem; font-size: 1.1rem; }
.what li + li { margin-top: .25rem; }
.skills { columns: 2; gap: 2rem; padding-left: 1.2rem; }

/* ---------- references ---------- */
.refs { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.5rem; }
.ref { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 1.3rem 1.4rem 1rem; }
.ref h2 { margin-bottom: .1em; }
.ref-role { color: var(--ink-soft); font-style: italic; }
.ref dl { margin: 0 0 .5rem; display: grid; gap: .4rem; font-size: 1.05rem; }
.ref dl div { display: grid; grid-template-columns: 7.5rem 1fr; gap: .5rem; align-items: baseline; }
.ref dt { color: var(--ink-soft); }
.ref-contact { margin: 0 0 .5rem; }
.ref dd { margin: 0; overflow-wrap: anywhere; }
.copy { font-size: .85rem; border: 1px solid var(--line); background: none; border-radius: 999px; padding: 0 .55rem; margin-left: .3rem; cursor: pointer; color: var(--ink-soft); vertical-align: middle; }
.copy:hover { color: var(--pond); border-color: var(--pond); }
.reveal-phone { font: inherit; font-size: .95em; border: 1px solid var(--line); background: none; border-radius: 999px; padding: .1rem .7rem; cursor: pointer; color: var(--ink-soft); }
.reveal-phone:hover, .reveal-phone:focus-visible { color: var(--pond); border-color: var(--pond); }
.sidebar-foot .reveal-phone { align-self: flex-start; }
.ref .pdf-frame { margin: 1rem -1.4rem -1rem; border-left: 0; border-right: 0; border-bottom: 0; border-radius: 0 0 6px 6px; }

/* ---------- classroom culture ---------- */
.culture-grid { display: grid; grid-template-columns: 1fr; gap: 2.5rem; margin-top: 1.5rem; max-width: 46rem; }
.culture-grid .figure { margin: 0; }
.playlist p { font-size: 1.1rem; color: var(--ink-soft); }
.yt-link { margin: .6rem 0 0; font-size: 1rem; }
.yt { position: relative; aspect-ratio: 16/9; border-radius: 6px; overflow: hidden; background: var(--pond-soft); border: 1px solid var(--line); }
.yt iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.yt-thumb { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.yt-play { position: absolute; inset: 0; width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5rem; background: none; border: 0; cursor: pointer; color: var(--ink); }
.yt-play:hover .ring { transform: scale(1.06); }
.yt-play .ring { width: 64px; height: 64px; border-radius: 50%; background: var(--pond); color: #fff; display: grid; place-items: center; transition: transform .2s ease; }
.yt-play .ring svg { margin-left: 4px; }
.yt-play small { font-size: 1rem; color: var(--ink-soft); }
.yt-thumb + .yt-play { background: linear-gradient(to top, rgba(0,0,0,.7), rgba(0,0,0,.2)); color: #fff; }
.yt-thumb + .yt-play small { color: rgba(255,255,255,.88); }
.yt-thumb + .yt-play:hover { background: linear-gradient(to top, rgba(0,0,0,.78), rgba(0,0,0,.3)); }
.drawing { margin: 0; align-self: end; }

/* ---------- lightbox & toast ---------- */
.lightbox { border: 0; padding: 0; background: transparent; max-width: 96vw; max-height: 96vh; }
.lightbox::backdrop { background: rgba(10, 20, 18, .88); }
.lightbox img { max-width: 94vw; max-height: 86vh; width: auto; height: auto; margin: 0 auto; border-radius: 4px; cursor: zoom-out; }
.lightbox p { color: #e7ede9; text-align: center; font-style: italic; margin: .6rem 0 0; }
.lightbox-close { position: fixed; top: .6rem; right: .8rem; background: none; border: 0; color: #fff; font-size: 2.2rem; line-height: 1; cursor: pointer; }
.toast { position: fixed; left: 50%; bottom: 1.4rem; transform: translate(-50%, 20px); opacity: 0; background: var(--ink); color: var(--paper); padding: .45rem 1rem; border-radius: 999px; font-size: 1rem; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  body { font-size: 1.12rem; }
  .topbar { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 30; background: var(--paper); border-bottom: 1px solid var(--line); padding: .7rem 16px; }
  .topbar-name { text-decoration: none; color: var(--ink); font-size: 1.25rem; font-weight: 500; }
  .menu-btn { background: none; border: 1px solid var(--line); border-radius: 999px; padding: .25rem .9rem; cursor: pointer; }
  .sidebar { transform: translateX(-100%); transition: transform .25s ease; width: min(84vw, 320px); box-shadow: none; z-index: 40; }
  .sidebar.open { transform: none; box-shadow: var(--shadow); }
  .scrim { display: block; position: fixed; inset: 0; background: rgba(10,20,18,.45); z-index: 35; }
  .scrim[hidden] { display: none; }
  .content { margin-left: 0; padding: 1.6rem 16px 3rem; }
  :root[data-theme="kelp"] .kelp-band { height: 150px; margin: -1.6rem -16px 1.6rem; }
  .hero { grid-template-columns: 1fr; }
  .hero-photo { max-width: 300px; }
  .entry { grid-template-columns: 1fr; gap: .1rem; }
  .skills { columns: 1; }
  .contact div, .ref dl div { grid-template-columns: 1fr; gap: 0; }
  .pdf-frame iframe { height: 70vh; }
}
