/* CHALKLINE — ink on chalk, ruled in amber.
   Humanist serif headings (Fraunces), Karla text, Caveat margin notes.
   The signature motif is a hand-drawn amber underline; cards carry a
   schoolbook margin rule. */

/* ───────── reset & guards ───────── */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body, h1, h2, h3, p, dl, dd, dt, figure { margin: 0; }
img { max-width: 100%; display: block; }
button, input { font: inherit; color: inherit; }

:root {
  --chalk: #F6F2E8;        /* the wall */
  --paper: #FDFBF4;        /* cards */
  --ink: #272B33;
  --ink-soft: #4A4F5B;
  --ink-dim: #62666F;
  --rule: #DCD5C4;
  --amber: #D98A1F;
  --amber-deep: #96600F;
  --amber-wash: #F6E7CB;
  --brick: #8C3A2B;
  --shadow: 0 1px 2px rgba(39, 43, 51, 0.10), 0 6px 18px rgba(39, 43, 51, 0.06);
  --drawn: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 9' preserveAspectRatio='none'%3E%3Cpath d='M2 6.5C22 3.5 44 7.8 62 5.2 80 2.8 102 6.4 118 4.4' fill='none' stroke='%23D98A1F' stroke-width='2.4' stroke-linecap='round'/%3E%3C/svg%3E");
}

body {
  background: var(--chalk);
  color: var(--ink);
  font-family: "Karla", "Segoe UI", sans-serif;
  font-size: 1.0625rem;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, .brand-word {
  font-family: "Fraunces", Georgia, serif;
  font-variation-settings: "opsz" 72;
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.01em;
}

a { color: var(--amber-deep); text-decoration-color: rgba(217, 138, 31, 0.55); text-underline-offset: 3px; }
a:hover { color: var(--ink); }

:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; border-radius: 2px; }

.skip {
  position: absolute; left: -999px; top: 0;
  background: var(--ink); color: var(--chalk); padding: 0.5rem 1rem; z-index: 60;
}
.skip:focus { left: 0.75rem; top: 0.75rem; }

/* the hand-drawn amber underline */
.drawn-u {
  background-image: var(--drawn);
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 100% 0.34em;
  padding-bottom: 0.32em;
}

/* ───────── masthead ───────── */
.mast {
  display: flex; align-items: center; gap: 1.25rem 2rem; flex-wrap: wrap;
  padding: 1.1rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 2px solid var(--ink);
  background: var(--chalk);
}
.brand { text-decoration: none; color: var(--ink); display: flex; flex-direction: column; gap: 0.1rem; }
.brand-word {
  font-size: 1.65rem; font-weight: 700;
  background-image: var(--drawn);
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 100% 0.3em;
  padding-bottom: 0.22em;
  width: fit-content;
}
.brand-sub { font-family: "Caveat", cursive; font-size: 1.05rem; color: var(--ink-dim); letter-spacing: 0.01em; }

.mast-nav { display: flex; gap: 1.4rem; margin-inline: auto; }
.mast-nav a {
  color: var(--ink-soft); text-decoration: none; font-weight: 600; font-size: 1rem;
  padding: 0.2rem 0.05rem; border-bottom: 2px solid transparent;
}
.mast-nav a:hover { color: var(--ink); }
.mast-nav a[aria-current="page"] {
  color: var(--ink);
  border-image: var(--drawn) 30 / 0 0 6px 0 stretch;
  border-bottom: 6px solid transparent;
}

.who { display: flex; align-items: center; gap: 0.75rem; }
.who-in { display: flex; align-items: center; gap: 0.75rem; }
.who-name { font-weight: 700; font-size: 0.98rem; }

/* ───────── page frame ───────── */
main { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: clamp(1.5rem, 4vw, 3rem) clamp(1rem, 4vw, 2.5rem) 3.5rem; }
.view { display: block; }

.cap { margin-bottom: 2rem; max-width: 46rem; }
.cap-h { font-size: clamp(2.3rem, 5.5vw, 3.4rem); font-weight: 600; }
.cap-note {
  font-family: "Caveat", cursive; font-size: clamp(1.2rem, 2.5vw, 1.45rem);
  color: var(--amber-deep); margin-top: 0.65rem; transform: rotate(-0.6deg); width: fit-content;
}
.cap-note:empty { display: none; }
.cap-sub { color: var(--ink-soft); margin-top: 0.55rem; font-size: 1.05rem; }

.backlink {
  display: inline-block; margin-bottom: 1.4rem; font-weight: 600; font-size: 0.95rem;
  color: var(--ink-soft); text-decoration: none;
}
.backlink::before { content: "← "; color: var(--amber-deep); }
.backlink:hover { color: var(--ink); }

/* ───────── buttons & chips ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  border-radius: 6px; border: 1.5px solid var(--ink);
  padding: 0.62rem 1.15rem; font-weight: 700; font-size: 0.98rem;
  cursor: pointer; text-decoration: none; text-align: center;
  transition: transform 120ms ease, box-shadow 120ms ease, background-color 120ms ease, color 120ms ease;
}
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-ink { background: var(--ink); color: var(--chalk); }
.btn-ink:not(:disabled):hover { background: #171a20; box-shadow: var(--shadow); }
.btn-line { background: transparent; color: var(--ink); }
.btn-line:not(:disabled):hover { background: rgba(39, 43, 51, 0.06); }
.btn-sm { padding: 0.42rem 0.85rem; font-size: 0.9rem; }
.btn-wide { width: 100%; }
.btn + .btn { margin-top: 0.6rem; }

.linklike {
  background: none; border: 0; padding: 0; color: var(--amber-deep);
  font-weight: 700; cursor: pointer; text-decoration: underline;
  text-decoration-color: rgba(217, 138, 31, 0.55); text-underline-offset: 3px;
}
.linklike:hover { color: var(--ink); }

.chip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  font-size: 0.82rem; font-weight: 700; letter-spacing: 0.02em;
  padding: 0.18rem 0.6rem; border-radius: 999px; white-space: nowrap;
}
.chip-going { background: var(--amber-wash); color: var(--amber-deep); border: 1px dashed var(--amber); }
.chip-done { background: var(--ink); color: var(--chalk); border: 1px solid var(--ink); }
.chip-done::before { content: "✓"; font-weight: 400; }

/* ───────── course cards ───────── */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.3rem; }

.course-card {
  position: relative; display: flex; flex-direction: column; gap: 0.55rem;
  background: var(--paper);
  border: 1px solid var(--rule); border-radius: 8px;
  padding: 1.35rem 1.35rem 1.15rem 1.7rem;
  text-decoration: none; color: var(--ink);
  box-shadow: 0 1px 0 rgba(39, 43, 51, 0.05);
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}
/* the schoolbook margin rule */
.course-card::before {
  content: ""; position: absolute; top: 0.9rem; bottom: 0.9rem; left: 1.05rem;
  width: 2px; background: var(--amber); opacity: 0.55; border-radius: 2px;
}
.course-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: #C9C1AC; }
.course-card:hover .cc-name {
  background-image: var(--drawn);
  background-repeat: no-repeat; background-position: 0 100%; background-size: 100% 0.3em;
}
.cc-code {
  font-size: 0.82rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--amber-deep); display: flex; align-items: baseline; gap: 0.6rem;
}
.cc-off {
  font-family: "Caveat", cursive; text-transform: none; letter-spacing: 0.02em;
  font-size: 1rem; font-weight: 600; color: var(--brick);
}
.cc-name { font-size: 1.45rem; font-weight: 600; padding-bottom: 0.24em; width: fit-content; }
.cc-desc { color: var(--ink-soft); font-size: 0.97rem; flex: 1; }
.cc-foot {
  display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap;
  border-top: 1px solid var(--rule); padding-top: 0.75rem; margin-top: 0.35rem;
  font-size: 0.9rem; color: var(--ink-dim); font-weight: 600;
}
.cc-open { margin-left: auto; color: var(--amber-deep); font-weight: 700; }
.course-card--off { background: #F5F1E6; }
.course-card--off .cc-name { color: var(--ink-soft); }

/* ───────── one course ───────── */
.course-sheet {
  background: var(--paper); border: 1px solid var(--rule); border-radius: 10px;
  box-shadow: 0 1px 0 rgba(39, 43, 51, 0.05);
  padding: clamp(1.5rem, 4vw, 2.6rem);
}
.cs-code { font-size: 0.9rem; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; color: var(--amber-deep); }
.cs-name { font-size: clamp(1.9rem, 4.5vw, 2.9rem); margin-top: 0.4rem; max-width: 24ch; }
.cs-meta { margin-top: 0.9rem; color: var(--ink-dim); font-weight: 600; font-size: 0.98rem; }
.cs-body {
  display: grid; grid-template-columns: 1.55fr 1fr; gap: 2.2rem;
  margin-top: 1.8rem; padding-top: 1.6rem; border-top: 1px solid var(--rule);
}
.sub-head {
  font-size: 1.05rem; font-weight: 700; margin-bottom: 0.6rem;
  font-family: "Karla", sans-serif; letter-spacing: 0.01em;
}
.cs-about p { color: var(--ink-soft); font-size: 1.02rem; max-width: 58ch; }
.cs-standing {
  background: var(--chalk); border: 1px solid var(--rule); border-radius: 8px;
  padding: 1.2rem 1.25rem; align-self: start;
}
.st-chiprow { margin-bottom: 0.6rem; }
.st-line { color: var(--ink-soft); font-size: 0.98rem; margin-bottom: 0.9rem; }
.st-dim { color: var(--ink-dim); font-size: 0.88rem; margin-top: 0.7rem; }

/* ───────── my learning ───────── */
.entries { display: flex; flex-direction: column; gap: 1rem; }
.entry {
  display: flex; align-items: center; gap: 1.5rem; justify-content: space-between;
  background: var(--paper); border: 1px solid var(--rule); border-radius: 8px;
  padding: 1.1rem 1.3rem 1.1rem 1.65rem; position: relative;
  box-shadow: 0 1px 0 rgba(39, 43, 51, 0.05);
}
.entry::before {
  content: ""; position: absolute; top: 0.8rem; bottom: 0.8rem; left: 1rem;
  width: 2px; background: var(--amber); opacity: 0.55; border-radius: 2px;
}
.entry--done { background: #F5F1E6; }
.entry--done::before { background: var(--ink); opacity: 0.35; }
.e-code { font-size: 0.78rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--amber-deep); }
.e-name { font-size: 1.3rem; margin-top: 0.15rem; }
.e-name a { color: var(--ink); text-decoration: none; }
.e-name a:hover { text-decoration: underline; text-decoration-color: var(--amber); text-underline-offset: 4px; }
.e-when { color: var(--ink-dim); font-size: 0.9rem; margin-top: 0.25rem; font-weight: 600; }
.e-side { display: flex; align-items: center; gap: 0.9rem; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }

/* ───────── the gate (a slate) ───────── */
.gate { display: flex; justify-content: center; padding-top: 0.5rem; }
.slate {
  width: 100%; max-width: 27.5rem;
  background: var(--ink); color: var(--chalk);
  border-radius: 12px; border: 1px solid #171a20;
  box-shadow: var(--shadow);
  padding: clamp(1.6rem, 4vw, 2.4rem);
}
.sl-eyebrow { font-size: 0.8rem; font-weight: 800; letter-spacing: 0.18em; text-transform: uppercase; color: rgba(246, 242, 232, 0.6); }
.sl-h { font-size: 2.2rem; margin-top: 0.5rem; color: var(--chalk); }
.sl-lede { color: rgba(246, 242, 232, 0.78); font-size: 0.98rem; margin-top: 0.8rem; margin-bottom: 1.4rem; }

.slate .field { margin-bottom: 0.95rem; }
.slate label { display: block; font-size: 0.85rem; font-weight: 700; letter-spacing: 0.04em; margin-bottom: 0.3rem; color: rgba(246, 242, 232, 0.85); }
.slate input {
  width: 100%; border-radius: 6px;
  border: 1.5px solid rgba(246, 242, 232, 0.35);
  background: rgba(246, 242, 232, 0.07);
  color: var(--chalk); padding: 0.6rem 0.75rem;
}
.slate input:focus { outline: 2px solid var(--amber); outline-offset: 1px; border-color: transparent; }
.slate .btn-ink { background: var(--amber); border-color: var(--amber); color: #241a08; }
.slate .btn-ink:not(:disabled):hover { background: #E39A35; }
.slate .btn-line { color: var(--chalk); border-color: rgba(246, 242, 232, 0.5); }
.slate .btn-line:not(:disabled):hover { background: rgba(246, 242, 232, 0.1); }

.demo-slot {
  margin-top: 1.5rem; padding: 1rem 1.1rem;
  border: 1px dashed rgba(246, 242, 232, 0.4); border-radius: 8px;
}
.ds-tag { font-family: "Caveat", cursive; font-size: 1.25rem; color: var(--amber); margin-bottom: 0.5rem; }
.ds-rows { display: flex; flex-direction: column; gap: 0.25rem; margin-bottom: 0.85rem; }
.ds-rows div { display: flex; gap: 0.7rem; align-items: baseline; flex-wrap: wrap; }
.ds-rows dt { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: rgba(246, 242, 232, 0.6); min-width: 5.2rem; }
.ds-rows dd { font-size: 0.95rem; overflow-wrap: anywhere; }

.sl-alt { margin-top: 1.4rem; font-size: 0.95rem; color: rgba(246, 242, 232, 0.78); margin-bottom: 0.9rem; }
.form-err { color: #F3B7A9; font-size: 0.92rem; margin: -0.2rem 0 0.7rem; font-weight: 600; }

/* ───────── states ───────── */
.state { margin-bottom: 1.2rem; }

.board-load {
  display: flex; align-items: center; gap: 0.5rem;
  color: var(--ink-dim); font-weight: 600; font-size: 0.98rem;
  padding: 1.4rem 0.2rem;
}
.bl-dash {
  width: 2rem; height: 4px; border-radius: 3px; background: var(--amber);
  opacity: 0.4; animation: chalkPulse 1.1s ease-in-out infinite;
}
.bl-dash:nth-child(2) { animation-delay: 0.18s; }
.bl-dash:nth-child(3) { animation-delay: 0.36s; }
.bl-text { margin-left: 0.4rem; }
@keyframes chalkPulse {
  0%, 100% { opacity: 0.25; transform: scaleX(0.75); }
  50% { opacity: 0.9; transform: scaleX(1); }
}

.empty {
  border: 1.5px dashed #C9C1AC; border-radius: 10px;
  padding: 2.2rem 1.6rem; text-align: center; max-width: 34rem; margin: 0 auto;
  background: rgba(253, 251, 244, 0.6);
}
.empty strong { font-family: "Fraunces", Georgia, serif; font-size: 1.35rem; font-weight: 600; display: block; margin-bottom: 0.5rem; }
.empty p { color: var(--ink-soft); font-size: 0.98rem; margin-bottom: 1rem; }
.empty .btn { margin-top: 0.2rem; }
.empty--err { border-color: rgba(140, 58, 43, 0.5); }
.empty--err strong { color: var(--brick); }

.cs-standing .board-load { padding: 0.4rem 0; }
.cs-standing .empty { padding: 1.2rem 1rem; }

/* ───────── toast ───────── */
.toast {
  position: fixed; left: 50%; bottom: 1.4rem; transform: translateX(-50%);
  background: var(--ink); color: var(--chalk);
  border-radius: 8px; padding: 0.75rem 1.2rem; font-weight: 600; font-size: 0.95rem;
  box-shadow: var(--shadow); z-index: 50; max-width: min(92vw, 30rem); text-align: center;
}
.toast--err { background: var(--brick); }

/* ───────── footer ───────── */
.foot {
  border-top: 1px solid var(--rule);
  padding: 1.6rem clamp(1rem, 4vw, 2.5rem) 2rem;
  color: var(--ink-soft); font-size: 0.95rem;
}
.foot-dim { color: var(--ink-dim); font-size: 0.85rem; margin-top: 0.3rem; }

/* ───────── small screens ───────── */
@media (max-width: 860px) {
  .cs-body { grid-template-columns: 1fr; gap: 1.6rem; }
}
@media (max-width: 640px) {
  .mast { gap: 0.9rem 1.2rem; }
  .mast-nav { order: 3; width: 100%; margin-inline: 0; gap: 1.1rem; }
  .who { margin-left: auto; }
  .entry { flex-direction: column; align-items: stretch; gap: 0.9rem; }
  .e-side { justify-content: flex-start; }
  .cc-open { display: none; }
}

/* ───────── motion respect ───────── */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .bl-dash { opacity: 0.7; }
  html { scroll-behavior: auto; }
}
