/* Teacher Library — white, calm, educational. Palette from the English 8 cover
   (peach band, navy, teal badge) + muted American red. System fonts only. */

:root {
  --navy: #1f2a55;
  --navy-2: #2f3b6b;
  --red: #b5473b;
  --red-soft: #f8e9e6;
  --peach: #f7b572;
  --peach-deep: #e8913a;
  --peach-soft: #fff5ea;
  --teal: #5db4cf;
  --teal-deep: #2b7f9e;
  --ink: #2b3040;
  --muted: #626877;
  --faint: #6b7180;
  --hair: #ebe6de;
  --hair-2: #f3efe9;
  --paper: #ffffff;
  --cream: #fcfaf6;
  --focus: #2b7f9e;

  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;

  --radius: 18px;
  --shadow: 0 1px 2px rgba(31, 42, 85, .05), 0 10px 30px -12px rgba(31, 42, 85, .18);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--navy); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- header ---------- */
.top {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px clamp(16px, 4vw, 48px);
}
.top::before { /* a thin stars-and-stripes thread along the very top */
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: linear-gradient(90deg, var(--navy) 0 22%, transparent 22%),
    repeating-linear-gradient(90deg, var(--red) 0 18px, #fff 18px 24px);
  opacity: .85;
}
.brand {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--navy);
  text-decoration: none;
}
.brand-mark { width: 38px; height: 38px; flex: none; }
.brand-name { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name strong { font: 600 19px/1.15 var(--serif); letter-spacing: .005em; }
.brand-name span { font-size: 12.5px; color: var(--muted); letter-spacing: .01em; }

.top-actions { display: flex; align-items: center; gap: 10px; }
.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--hair);
  border-radius: 999px;
  background: #fff;
  color: var(--navy);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  flex: none;
  transition: border-color .2s, background-color .2s;
}
.link-btn:hover { border-color: #d9d2c6; background: var(--cream); }
.link-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.link-btn .tr { font-weight: 400; color: var(--muted); }

/* ---------- shared bits ---------- */
.eyebrow {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--red);
}
.eyebrow .tr { color: var(--faint); font-weight: 600; }
.tr { color: var(--muted); font-weight: 400; }
.ribbon { display: block; width: 92px; height: 18px; margin: 0 0 16px; }
.ribbon svg { width: 100%; height: 100%; overflow: visible; }

/* ---------- login ---------- */
.login {
  position: relative;
  z-index: 2;
  flex: 1 0 auto;
  display: grid;
  place-items: center;
  padding: 12px 16px 0;
}
.login::before, .shelf-page::before { /* faint dotted exercise-book paper behind the content */
  content: "";
  position: absolute;
  inset: -90px 0 0;
  z-index: -1;
  background-image: radial-gradient(circle, #e4ddd1 1.1px, transparent 1.4px);
  background-size: 24px 24px;
  -webkit-mask-image: radial-gradient(ellipse 60% 70% at 50% 35%, #000 20%, transparent 75%);
  mask-image: radial-gradient(ellipse 60% 70% at 50% 35%, #000 20%, transparent 75%);
  pointer-events: none;
}
.card {
  width: 100%;
  max-width: 452px;
  padding: 34px 36px 30px;
  background: rgba(255, 255, 255, .96);
  border: 1px solid var(--hair);
  border-radius: 22px;
  box-shadow: var(--shadow);
}
.card h1 {
  margin: 0 0 8px;
  font: 600 clamp(28px, 3.2vw, 34px)/1.15 var(--serif);
  color: var(--navy);
  letter-spacing: -.005em;
}
.lead { margin: 0 0 22px; color: var(--muted); font-size: 15px; }
.lead .tr { display: block; margin-top: 2px; font-size: 13.5px; color: var(--faint); }

.field { display: block; margin: 0 0 16px; }
.field-label { display: block; margin: 0 0 6px; font-size: 14px; font-weight: 600; color: var(--navy); }
.field-label .tr { font-weight: 400; font-size: 13px; color: var(--faint); }
.input-wrap { position: relative; display: block; }
.field input {
  width: 100%;
  height: 50px;
  padding: 0 16px;
  border: 1px solid #ddd6cb;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font: 16px var(--sans);
  transition: border-color .2s, box-shadow .2s;
}
.field input::placeholder { color: #a5a9b4; }
.field input:hover { border-color: #cdc4b6; }
.field input:focus { outline: none; border-color: var(--navy-2); box-shadow: 0 0 0 4px rgba(247, 181, 114, .35); }
.field input[aria-invalid="true"] { border-color: var(--red); }
.has-toggle input { padding-right: 52px; }
.toggle {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.toggle:hover { background: var(--hair-2); color: var(--navy); }
.toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.toggle .eye-off { display: none; }
.toggle[aria-pressed="true"] .eye { display: none; }
.toggle[aria-pressed="true"] .eye-off { display: block; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 50px;
  padding: 0 22px;
  border: 0;
  border-radius: 12px;
  background: var(--navy);
  color: #fff;
  font: 600 16px var(--sans);
  text-decoration: none;
  cursor: pointer;
  transition: background-color .2s, transform .2s;
}
.btn:hover { background: var(--navy-2); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .25s; }
.btn:hover svg { transform: translateX(3px); }
.btn .tr { color: rgba(255, 255, 255, .72); font-weight: 400; }
.btn[disabled] { opacity: .7; cursor: progress; }
.btn-block { width: 100%; margin-top: 6px; }

.alert {
  display: flex;
  gap: 12px;
  margin: 0 0 18px;
  padding: 12px 14px;
  border: 1px solid #efcfc9;
  border-radius: 12px;
  background: var(--red-soft);
  color: #7c2d24;
  font-size: 14px;
  line-height: 1.45;
}
.alert[hidden] { display: none; }
.alert svg { flex: none; width: 20px; height: 20px; margin-top: 1px; fill: none; stroke: var(--red); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.alert strong { display: block; color: #6a241c; }
.alert span { display: block; color: #8f4a41; }

.note {
  display: flex;
  gap: 10px;
  margin: 20px 0 0;
  padding-top: 18px;
  border-top: 1px dashed var(--hair);
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}
.note svg { flex: none; width: 18px; height: 18px; margin-top: 1px; fill: none; stroke: var(--teal-deep); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.note .tr { display: block; color: var(--faint); }

/* ---------- scene (line-art panorama, built by scene.js) ---------- */
.scene {
  position: relative;
  z-index: 1;
  width: 100%;
  margin-top: -80px;
  pointer-events: none;
  user-select: none;
}
.scene svg { width: 100%; height: auto; max-height: 360px; overflow: hidden; }
.scene-library { margin-top: 8px; }

.ln { fill: none; stroke: var(--navy); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.ln-thin { stroke-width: 1; opacity: .7; }
.ln-far { stroke: #a9b0c6; stroke-width: 1.2; }
.ln-teal { stroke: var(--teal-deep); }
.ln-red { stroke: var(--red); }
.ln-peach { stroke: var(--peach-deep); }
.fill-peach { fill: var(--peach); }
.fill-peach-soft { fill: var(--peach-soft); }
.fill-white { fill: #fff; }
.fill-navy { fill: var(--navy); }
.fill-red { fill: var(--red); }
.water { stroke: var(--teal); stroke-width: 1.4; stroke-linecap: round; opacity: .55; }
.lane { stroke: #c9c3b8; stroke-width: 1.6; stroke-dasharray: 18 16; stroke-linecap: round; }

/* draw-in: scene.js sets each stroke's dasharray/dashoffset to its length; it traces itself once, staggered by --d */
.draw { animation: draw var(--t, 2.4s) cubic-bezier(.45, .05, .25, 1) var(--d, 0s) forwards; }
.fade { opacity: 0; animation: fade 1.6s ease var(--d, 0s) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fade { to { opacity: 1; } }
.water-drift { animation: drift 7s ease-in-out infinite alternate; }
.water-drift.b { animation-duration: 9s; animation-delay: -3s; }
@keyframes drift { from { transform: translateX(-7px); } to { transform: translateX(7px); } }

/* ---------- library ---------- */
.shelf-page {
  position: relative;
  z-index: 2;
  flex: 1 0 auto;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: clamp(20px, 4vw, 44px) clamp(16px, 4vw, 48px) 0;
}
.shelf-head { margin: 0 0 30px; }
.shelf-head h1 {
  margin: 0;
  font: 600 clamp(32px, 4.2vw, 46px)/1.1 var(--serif);
  color: var(--navy);
  letter-spacing: -.01em;
}
.shelf-head h1 .tr { display: block; margin-top: 6px; font: 400 clamp(17px, 1.8vw, 20px)/1.3 var(--sans); color: var(--faint); letter-spacing: 0; }
.shelf-head p:not(.eyebrow) { margin: 14px 0 0; max-width: 620px; color: var(--muted); }

.books {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 470px), 1fr));
  gap: 24px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.book {
  position: relative;
  display: grid;
  grid-template-columns: 158px 1fr;
  grid-template-areas: "cover body" "cover open";
  grid-template-rows: auto 1fr;
  column-gap: 26px;
  align-items: start;
  padding: 24px;
  background: #fff;
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform .35s cubic-bezier(.2, .7, .2, 1), box-shadow .35s;
}
.book:hover { transform: translateY(-3px); box-shadow: 0 1px 2px rgba(31, 42, 85, .05), 0 18px 40px -16px rgba(31, 42, 85, .26); }
.cover {
  position: relative;
  grid-area: cover;
  display: block;
  aspect-ratio: 1575 / 2048;
  border-radius: 3px 8px 8px 3px;
  background: var(--peach) linear-gradient(180deg, var(--peach) 0 44%, #fff 44% 46.5%, var(--teal) 46.5%);
  box-shadow: 0 1px 1px rgba(0, 0, 0, .08), 4px 10px 22px -10px rgba(31, 42, 85, .45);
  overflow: hidden;
  transform: perspective(700px) rotateY(-7deg);
  transform-origin: left center;
  transition: transform .45s cubic-bezier(.2, .7, .2, 1);
}
.book:hover .cover { transform: perspective(700px) rotateY(-2deg); }
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover::after { /* spine crease */
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 9px;
  background: linear-gradient(90deg, rgba(0, 0, 0, .18), rgba(255, 255, 255, .25) 55%, rgba(0, 0, 0, 0));
}
.book-body { grid-area: body; display: flex; flex-direction: column; }
.badge {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0 12px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  background: #eaf5f9;
  color: var(--teal-deep);
  font-size: 12.5px;
  font-weight: 600;
}
.badge b { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--teal-deep); color: #fff; font-size: 12px; }
.book h2 { margin: 0; font: 600 28px/1.15 var(--serif); color: var(--navy); }
.book .level { margin: 6px 0 0; color: var(--ink); font-weight: 600; font-size: 15px; }
.book .by { margin: 10px 0 0; color: var(--muted); font-size: 14px; font-style: italic; }
.book .feats { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 14px 0 0; padding: 0; list-style: none; color: var(--muted); font-size: 13px; }
.book .feats li { display: inline-flex; align-items: center; gap: 6px; }
.book .feats svg { width: 15px; height: 15px; fill: none; stroke: var(--peach-deep); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.book .open { grid-area: open; align-self: end; padding-top: 20px; }
.book .open .btn { min-height: 46px; }

.book-soon {
  display: grid;
  place-items: center;
  min-height: 260px;
  padding: 24px;
  border: 1.5px dashed #e3ddd2;
  border-radius: var(--radius);
  background: transparent;
  color: var(--faint);
  text-align: center;
  font-size: 14px;
}
.book-soon svg { width: 46px; height: 46px; margin: 0 auto 12px; fill: none; stroke: #c4bcae; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.book-soon strong { display: block; color: var(--muted); font: 600 17px/1.3 var(--serif); }

.status { color: var(--muted); }

/* ---------- footer ---------- */
.foot {
  position: relative;
  z-index: 2;
  padding: 4px 16px 14px;
  background: #fff;
  color: var(--faint);
  font-size: 12.5px;
  text-align: center;
}

/* ---------- small screens ---------- */
@media (max-width: 560px) {
  .top { padding-top: 16px; padding-bottom: 12px; }
  .brand-mark { width: 34px; height: 34px; }
  .brand-name strong { font-size: 17px; }
  .link-btn .tr { display: none; }
  .card { padding: 26px 20px 22px; border-radius: 18px; }
  .scene { margin-top: 0; }
  .login::before { display: none; }
  .brand-name span { font-size: 11px; max-width: 160px; }
  .book { grid-template-columns: 104px 1fr; grid-template-areas: "cover body" "open open"; column-gap: 16px; padding: 18px; }
  .book h2 { font-size: 23px; }
  .book .feats { display: none; }
  .book .open { padding-top: 18px; }
  .book .open .btn { width: 100%; }
  .book-soon { min-height: 150px; }
}

/* ---------- large boards ---------- */
@media (min-width: 1700px) {
  body { font-size: 17px; }
  .card { max-width: 480px; }
  .shelf-page { max-width: 1280px; }
}

@media (prefers-reduced-motion: reduce) {
  .draw { animation: none; stroke-dasharray: none !important; stroke-dashoffset: 0 !important; }
  .fade { animation: none; opacity: 1; }
  .water-drift { animation: none; }
  .book, .cover, .btn, .btn svg { transition: none; }
}
