/* AEJ — "Bookcloth & Gilt"
   Layers go from most general to most specific. Later layers win. */
@layer reset, tokens, base, components, pages, print;

/* ---------- Reset ---------- */
@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  body, h1, h2, h3, p, ul { margin: 0; }
  ul { padding: 0; list-style: none; }
  img, svg { display: block; max-width: 100%; }
  button { font: inherit; }
}

/* ---------- Design tokens: change the look here ---------- */
@layer tokens {
  :root {
    /* Library (teaching) side */
    --bottle: #13342C;        /* bookcloth green */
    --bottle-hover: #1F4E42;
    --gilt: #CDA85C;          /* gold on green */
    --gilt-ink: #8C6A24;      /* darker gold, readable on light paper */
    --vellum: #EDE6D1;        /* light text on green */
    --vellum-soft: #D8D0B6;
    --vellum-mute: #BFB79C;

    /* Reading area */
    --sage-ground: #E7EAE3;
    --paper: #FBFBF7;
    --paper-row: #F1F2EC;
    --rule: #D3D6C8;
    --ink: #1E2B26;
    --ink-soft: #34433D;
    --ink-mute: #5C6B64;

    /* Hearth (family) side */
    --butter: #F2DA8B;
    --olive: #2E3215;
    --olive-soft: #4A4B25;

    /* Type */
    --font-display: "Libre Caslon Display", "Iowan Old Style", Georgia, serif;
    --font-text: "Libre Caslon Text", "Iowan Old Style", Georgia, serif;
    --font-ui: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;

    --ease-out: cubic-bezier(.16, 1, .3, 1);
  }
}

/* ---------- Base ---------- */
@layer base {
  html { scroll-padding-top: 110px; }
  body {
    font-family: var(--font-text);
    color: var(--ink);
    background: var(--sage-ground);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
  }
  h1, h2, h3 { text-wrap: balance; }
  p { text-wrap: pretty; }
  a { color: var(--bottle); }
  ::selection { background: var(--gilt); color: var(--bottle); }
  :focus-visible { outline: 3px solid var(--gilt); outline-offset: 3px; }

  .visually-hidden {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip-path: inset(50%); white-space: nowrap;
  }
  .skip-link {
    position: absolute; inset-inline-start: 16px; top: -60px; z-index: 20;
    padding: 12px 18px; border-radius: 8px;
    background: var(--bottle); color: var(--vellum); font-family: var(--font-ui);
  }
  .skip-link:focus { top: 16px; }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: 0.01ms !important; }
  }
}

/* ---------- Components ---------- */
@layer components {
  /* Glass navigation bar */
  .site-header {
    position: absolute; top: 20px; inset-inline: 24px; z-index: 10;
  }
  .glass-nav {
    max-width: 1180px; margin-inline: auto;
    display: flex; align-items: center; gap: 16px;
    padding: 8px 8px 8px 20px; border-radius: 14px;
    color: var(--bottle); font-family: var(--font-ui);
    background: rgb(250 247 236 / .62);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    backdrop-filter: blur(20px) saturate(160%);
    border: 1px solid rgb(255 255 255 / .55);
    box-shadow: 0 8px 30px rgb(12 36 31 / .16);
  }
  /* Browsers without blur get a solid bar so text stays readable. */
  @supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .glass-nav { background: rgb(250 247 236 / .96); }
  }
  .brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
  .brand-seal {
    display: inline-grid; place-items: center; width: 34px; height: 34px;
    border-radius: 50%; border: 1.5px solid currentColor;
    font: 15px var(--font-display);
  }
  .brand-name { font: 21px var(--font-display); letter-spacing: .04em; }
  .nav-links { display: flex; gap: 2px; margin-inline-start: auto; font-size: 15px; }
  .nav-link {
    padding: 10px 14px; border-radius: 8px; font-weight: 500;
    color: inherit; text-decoration: none; white-space: nowrap;
  }
  a.nav-link:hover, .nav-link[aria-current="page"] { background: rgb(19 52 44 / .1); }
  .nav-link.is-soon { color: #5F716A; }
  .nav-signin {
    font-weight: 600; font-size: 14px; color: #3E5A52;
    background: transparent; border: 1px solid rgb(19 52 44 / .22);
    border-radius: 8px; padding: 11px 16px; cursor: not-allowed;
  }

  /* Buttons */
  .btn, .btn-sm, .pill {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font-family: var(--font-ui); font-weight: 600; text-decoration: none;
    border-radius: 999px; cursor: pointer;
    transition: background-color .2s, color .2s;
  }
  .btn { min-height: 48px; padding: 0 20px; font-size: 15px; border: 0; }
  .btn-gilt { background: var(--gilt); color: var(--bottle); }
  .btn-gilt:hover { background: #D9B872; }
  .btn-ghost { background: transparent; color: var(--vellum); border: 1px solid rgb(237 230 209 / .4); }
  .btn-ghost:hover { background: rgb(237 230 209 / .08); }

  .btn-sm { min-height: 44px; padding: 0 18px; font-size: 14px; }
  .btn-outline { border: 1.5px solid var(--bottle); color: var(--bottle); }
  .btn-outline:hover { background: rgb(19 52 44 / .08); }
  .btn-solid { background: var(--bottle); color: var(--vellum); }
  .btn-solid:hover { background: var(--bottle-hover); color: #fff; }

  .pill { min-height: 48px; padding: 0 22px; font-size: 15px; }
  .pill-olive { background: var(--olive); color: var(--butter); }
  .pill-gilt { background: var(--gilt); color: var(--bottle); }
}

/* ---------- Pages ---------- */
@layer pages {
  /* Landing: split entry */
  .split { display: flex; height: 100vh; height: 100dvh; min-height: 680px; background: var(--bottle); }
  .split-pane {
    flex: 1 1 0; min-width: 0; position: relative; overflow: hidden;
    display: flex; flex-direction: column;
    text-decoration: none;
    transition: flex-grow .8s var(--ease-out);
  }
  /* Hovering one side grows it to about 60%. */
  @media (hover: hover) {
    .split:hover .split-pane { flex-grow: .667; }
    .split .split-pane:is(:hover, :focus-visible) { flex-grow: 1; }
  }
  .split-pane:focus-visible { outline: 3px solid var(--gilt); outline-offset: -8px; }

  .pane-hearth {
    background: var(--butter); color: var(--olive);
    justify-content: flex-end; padding: 0 64px 72px;
    font-family: var(--font-ui);
  }
  .pane-hearth .pane-copy { position: relative; max-width: 460px; }
  .hearth-title {
    font-size: clamp(56px, 6vw, 84px); line-height: .95;
    font-weight: 750; letter-spacing: -.035em; margin-bottom: 16px;
  }
  .pane-hearth p { font-size: 19px; line-height: 1.5; color: var(--olive-soft); margin-bottom: 28px; }

  .photo-stack { position: absolute; top: 19vh; right: 12%; width: 300px; height: 300px; }
  .photo {
    position: absolute; width: 190px; height: 220px;
    display: flex; align-items: flex-end; justify-content: center; padding-bottom: 14px;
    border-radius: 14px; border: 10px solid #FBF4DA;
    font-size: 13px; transition: transform .8s var(--ease-out);
  }
  .photo-1 { left: 0; top: 30px; background: #E5C566; color: #5F5B2B; rotate: -6deg; }
  .photo-2 { left: 120px; top: 10px; background: #C9C47A; color: #4B4A20; rotate: 7deg; }
  .photo-3 { left: 62px; top: 74px; background: #DFB24A; color: #4A3C10; box-shadow: 0 14px 30px rgb(46 50 21 / .22); }
  .pane-hearth:hover .photo-1 { transform: rotate(-3deg) translate(-18px, -6px); }
  .pane-hearth:hover .photo-2 { transform: rotate(3deg) translate(18px, 4px); }

  .pane-library {
    background: var(--bottle); color: var(--vellum);
    align-items: center; justify-content: center; text-align: center;
    padding: 120px 48px 72px;
  }
  .gilt-frame {
    position: absolute; inset: 108px 48px 40px; pointer-events: none;
    border: 1px solid rgb(205 168 92 / .45); border-radius: 4px;
  }
  .gilt-frame-inner { inset: 116px 56px 48px; border-color: rgb(205 168 92 / .25); border-radius: 2px; }
  .pane-library .pane-copy { position: relative; display: flex; flex-direction: column; align-items: center; gap: 22px; }
  .library-title {
    font-family: var(--font-display); font-size: clamp(60px, 6vw, 88px); line-height: 1;
    color: var(--gilt); letter-spacing: -.01em;
    transition: letter-spacing .8s var(--ease-out);
  }
  .pane-library:hover .library-title { letter-spacing: .01em; }
  .library-sub { font-style: italic; font-size: 20px; line-height: 1.5; color: var(--vellum-soft); max-width: 30ch; }
  .ornament { display: flex; align-items: center; gap: 12px; }
  .ornament i { width: 56px; height: 1px; background: var(--gilt); }
  .ornament b { width: 8px; height: 8px; rotate: 45deg; border: 1px solid var(--gilt); }
  .pane-library .pill { margin-top: 12px; }

  @media (max-width: 760px) {
    .split { flex-direction: column; height: auto; }
    .split-pane { min-height: 70svh; }
    .pane-hearth { padding: 0 28px 48px; }
    .photo-stack { scale: .62; right: 6%; top: 112px; transform-origin: top right; }
    .pane-library { padding: 100px 28px 64px; }
    .gilt-frame { inset: 88px 16px 20px; }
    .gilt-frame-inner { inset: 94px 22px 26px; }
    .nav-signin { display: none; }
    .site-header { inset-inline: 12px; top: 12px; }
    .glass-nav { gap: 8px; padding-inline-start: 12px; }
    .nav-links { font-size: 14px; }
    .nav-link { padding: 10px; }
  }

  /* Library: class page */
  .library { display: flex; flex-wrap: wrap; align-items: stretch; min-height: 100vh; }
  .library-aside {
    flex: 1 1 380px; max-width: 520px;
    background: var(--bottle); color: var(--vellum);
    padding: 140px 48px 56px;
  }
  .bookplate {
    border: 1px solid rgb(205 168 92 / .5); border-radius: 4px;
    padding: 36px 30px 32px; text-align: center; margin-bottom: 40px;
  }
  .bookplate h1 {
    font: 400 clamp(36px, 3.4vw, 46px)/1.08 var(--font-display);
    color: var(--gilt); margin-bottom: 16px;
  }
  .bookplate-schedule { font-style: italic; font-size: 17px; color: var(--vellum-soft); margin-bottom: 6px; }
  .bookplate-dates { font-family: var(--font-ui); font-size: 15px; color: var(--vellum-mute); }
  .aside-intro { font-size: 17px; line-height: 1.7; color: var(--vellum-soft); margin-bottom: 28px; }
  .aside-actions { display: flex; flex-direction: column; gap: 10px; margin-bottom: 48px; }

  .contents-title { font: 400 26px var(--font-display); color: var(--gilt); margin-bottom: 8px; }
  .contents { display: flex; flex-direction: column; }
  .contents a {
    display: flex; gap: 14px; align-items: baseline; padding: 10px 0;
    color: var(--vellum); text-decoration: none;
  }
  .contents a:not(:last-child) { border-bottom: 1px solid rgb(205 168 92 / .22); }
  .contents a:hover { color: var(--gilt); }
  .contents-num { flex: 0 0 34px; font: 20px var(--font-display); color: var(--gilt); }
  .contents-name { flex: 1 1 auto; font-size: 17px; }
  .contents-date { font: 13px var(--font-ui); color: var(--vellum-mute); }

  .library-main {
    flex: 999 1 560px; min-width: 0;
    padding: 140px 56px 96px;
    display: flex; flex-direction: column; gap: 22px;
  }
  .session {
    max-width: 760px;
    background: var(--paper); border: 1px solid var(--rule); border-radius: 12px;
    padding: 36px 40px;
  }
  .session.is-upcoming { background: transparent; }
  .session-head { display: flex; align-items: baseline; gap: 20px; flex-wrap: wrap; margin-bottom: 14px; }
  .session-num { min-width: 72px; font: 64px/.9 var(--font-display); color: var(--gilt-ink); }
  .is-upcoming .session-num { color: #8E978F; }
  .session-title { font: 400 34px/1.1 var(--font-display); color: var(--bottle); margin-bottom: 4px; }
  .session-date { font: 600 14px var(--font-ui); color: var(--ink-mute); }
  .session-summary { font-size: 18px; line-height: 1.75; color: var(--ink-soft); max-width: 60ch; margin-bottom: 24px; }
  .session-note { font-style: italic; font-size: 16px; color: var(--ink-mute); }

  .files { display: flex; flex-direction: column; gap: 10px; }
  .file {
    display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
    padding: 12px 12px 12px 18px; border-radius: 10px;
    background: var(--paper-row); font-family: var(--font-ui);
  }
  .file.is-soon { background: transparent; border: 1px dashed var(--rule); min-height: 68px; }
  .file-info { flex: 1 1 220px; min-width: 0; display: flex; flex-direction: column; }
  .file-name { font-size: 16px; font-weight: 600; color: var(--ink); }
  .file-meta { font-size: 14px; color: var(--ink-mute); }
  .file-actions { display: flex; gap: 8px; flex-wrap: wrap; }

  @media (max-width: 760px) {
    .library-aside { max-width: none; padding: 120px 24px 40px; }
    .library-main { padding: 32px 16px 64px; }
    .session { padding: 28px 22px; }
    .session-num { font-size: 52px; min-width: 0; }
    .session-title { font-size: 28px; }
  }
}

/* ---------- Print: clean, ink-friendly notes page ---------- */
@layer print {
  @media print {
    .site-header, .skip-link, .no-print { display: none !important; }
    body, .library-aside, .session { background: #fff !important; color: #000 !important; }
    .library { display: block; }
    .library-aside { max-width: none; padding: 0 0 16pt; }
    .bookplate { border-color: #999; }
    .bookplate h1, .contents-title, .contents-num, .session-num, .session-title { color: #000 !important; }
    .bookplate-schedule, .bookplate-dates, .aside-intro, .contents a, .contents-date { color: #333 !important; }
    .library-main { padding: 0; }
    .session { border: 0; border-top: 1px solid #999; border-radius: 0; padding: 16pt 0; break-inside: avoid; }
    .session-summary { font-size: 12pt; }
  }
}
