/* Kalamrasa Book Club
   Layout: an annotated book page. A reading column sits beside a narrow margin
   column that holds each section's Malay label, the way notes sit in the margin
   of a well-read book. The library date slip is the one loud element; the rest
   stays quiet. Corners are square, like paper. The round date stamp is the only
   curve on the site.

   Main colours: Cloud Dancer #F0EFEB, Baltic Sea #79B6D8, Hematite #756F6A,
   Cloud Cover #9A9393. Hematite is a little light for small text (4.3:1 on
   Cloud Dancer), so body text and buttons use deeper Hematite shades. Baltic
   Sea is too light for text, so it carries the logo, stamp and accent rules. */

:root {
  --paper: #F0EFEB;       /* Cloud Dancer, page ground */
  --paper-deep: #E7E5E0;  /* deeper Cloud Dancer, tonal band */
  --card: #F7F6F3;        /* the date slip and table */
  --ink: #403B37;         /* deep Hematite, body text, 9.6:1 */
  --ink-muted: #5E5954;   /* Hematite shade for small secondary text, 6:1 */
  --hematite: #756F6A;    /* Hematite, headings and large labels */
  --cover: #9A9393;       /* Cloud Cover, structural rules */
  --rule: #D6D3CD;        /* hairlines */
  --baltic: #79B6D8;      /* Baltic Sea, logo colour and accents */
  --tint: #DCEBF4;        /* Baltic Sea tint, support panel */
  --button: #5E5954;
  --button-hover: #403B37;
  --button-text: #F0EFEB;
  --focus: #4A6275;       /* Blue Fusion from the wider palette, focus ring */
  --error: #9B3A2C;       /* form errors */

  /* Type: the logo carries Dalton White. Fraunces for headings, Plus Jakarta Sans for reading */
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Plus Jakarta Sans", "Segoe UI", "Helvetica Neue", sans-serif;
  --step--1: 0.875rem;
  --step-0: 1.0625rem;
  --step-1: 1.25rem;
  --step-2: 1.625rem;
  --step-3: clamp(1.75rem, 1.35rem + 1.5vw, 2.375rem);
  --step-4: clamp(2.25rem, 1.5rem + 3.2vw, 3.75rem);

  /* Space */
  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2.5rem;
  --space-5: 4rem;
  --space-6: 6rem;
  --measure: 38rem;
  --page: 72rem;
  --margin-col: 11rem;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #242220;
    --paper-deep: #2C2A27;
    --card: #2A2825;
    --ink: #EDEBE6;
    --ink-muted: #BDB7B1;
    --hematite: #D9D4CE;
    --cover: #6E6864;
    --rule: #423E3A;
    --baltic: #79B6D8;
    --tint: #263845;
    --button: #D9D4CE;
    --button-hover: #F0EFEB;
    --button-text: #242220;
    --focus: #9FCBE4;
    --error: #F2A493;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #242220;
  --paper-deep: #2C2A27;
  --card: #2A2825;
  --ink: #EDEBE6;
  --ink-muted: #BDB7B1;
  --hematite: #D9D4CE;
  --cover: #6E6864;
  --rule: #423E3A;
  --baltic: #79B6D8;
  --tint: #263845;
  --button: #D9D4CE;
  --button-hover: #F0EFEB;
  --button-text: #242220;
  --focus: #9FCBE4;
  --error: #F2A493;
  color-scheme: dark;
}

/* Base */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--step-0);
  font-weight: 400;
  line-height: 1.65;
}

img { display: block; max-width: 100%; height: auto; }

a {
  color: var(--ink);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

h1, h2, h3 {
  margin: 0;
  font-family: var(--font-display);
  font-variation-settings: "SOFT" 100;
  font-weight: 500;
  line-height: 1.15;
  text-wrap: balance;
}

h1, h2 { color: var(--hematite); }

p, ul, ol, dl, figure { margin: 0; }

.wrap {
  width: 100%;
  max-width: calc(var(--page) + 5rem);
  margin-inline: auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

@media (min-width: 48rem) {
  .wrap {
    padding-left: max(2.5rem, env(safe-area-inset-left, 0px));
    padding-right: max(2.5rem, env(safe-area-inset-right, 0px));
  }
}

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

.skip:focus {
  left: max(16px, env(safe-area-inset-left, 0px));
  top: max(8px, env(safe-area-inset-top, 0px));
}

/* Header */

.site-header { border-bottom: 1px solid var(--rule); }

.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem var(--space-4);
  padding-block: var(--space-2);
}

.logo { display: inline-block; }
.logo img { width: 9.5rem; }

@media (min-width: 48rem) {
  .site-header .logo img { width: 11rem; }
}

.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.25rem;
  padding: 0;
  list-style: none;
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-decoration: none;
}

.site-nav a:hover { text-decoration: underline; }

.site-nav a[aria-current="page"] {
  text-decoration: underline;
  text-decoration-color: var(--baltic);
  text-decoration-thickness: 3px;
  text-underline-offset: 0.4em;
}

/* Shared pieces */

.name-note {
  font-family: var(--font-display);
  font-size: var(--step-1);
  font-style: italic;
  color: var(--ink-muted);
}

.lead {
  max-width: 36rem;
  font-size: var(--step-1);
  line-height: 1.55;
}

.byline {
  font-size: var(--step--1);
  color: var(--ink-muted);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
}

.button {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  padding: 0.75rem 1.25rem;
  border: 1px solid var(--button);
  border-radius: 0;
  background: var(--button);
  color: var(--button-text);
  font-weight: 600;
  text-decoration: none;
}

.button:hover {
  border-color: var(--button-hover);
  background: var(--button-hover);
}

.text-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-weight: 600;
}

.section { padding-block: var(--space-5); }
.section--tight { padding-block: var(--space-4); }
.section--band { background: var(--paper-deep); }
.section h2 { font-size: var(--step-3); }

/* Margin-note layout */

.annotated {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-2) var(--space-4);
}

@media (min-width: 56rem) {
  .annotated { grid-template-columns: var(--margin-col) minmax(0, 1fr); }
  .annotated > .note { grid-column: 1; }
  .annotated > .body { grid-column: 2; max-width: 44rem; }
}

.note {
  font-size: var(--step--1);
  color: var(--ink-muted);
}

.ms-label {
  display: block;
  margin-bottom: 0.15rem;
  font-family: var(--font-display);
  font-size: var(--step-2);
  font-style: italic;
  font-weight: 400;
  line-height: 1.1;
  color: var(--hematite);
}

.body > p,
.body > .intro { margin-top: var(--space-2); max-width: var(--measure); }

.body > figure { margin-top: var(--space-3); }

/* Home hero */

.hero .wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
  padding-block: var(--space-5) var(--space-4);
}

@media (min-width: 60rem) {
  .hero .wrap {
    grid-template-columns: minmax(0, 7fr) minmax(0, 4fr);
    align-items: start;
    gap: var(--space-5);
  }
}

.hero h1 {
  margin-top: var(--space-2);
  font-size: var(--step-4);
}

.hero .lead { margin-top: var(--space-3); }
.hero .actions { margin-top: var(--space-4); }

/* Library date slip */

.slip {
  width: 100%;
  max-width: 26rem;
  padding: var(--space-3);
  border: 1px solid var(--rule);
  border-top: 4px solid var(--baltic);
  background: var(--card);
}

.slip__head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--cover);
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.slip__book {
  margin-top: var(--space-2);
  font-size: var(--step-2);
}

.slip__author {
  margin-top: 0.25rem;
  color: var(--ink-muted);
}

.slip__rows { margin-top: var(--space-3); }

.slip__rows div {
  display: grid;
  grid-template-columns: 6.5rem minmax(0, 1fr);
  gap: 1rem;
  padding-block: 0.6rem;
  border-top: 1px dashed var(--cover);
}

.slip__rows dt {
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.slip__rows dd {
  min-width: 0;
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.slip__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-top: var(--space-2);
  padding-top: var(--space-2);
  border-top: 2px solid var(--cover);
}

.slip__foot p {
  max-width: 12rem;
  font-family: var(--font-display);
  font-style: italic;
  line-height: 1.35;
}

.stamp {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 6.25rem;
  height: 6.25rem;
  border: 2px solid var(--baltic);
  border-radius: 50%;
  transform: rotate(-10deg);
}

.stamp img { width: 78%; }

/* Photo slots: replace each with a real photo before launch */

.photo-slot__frame {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 3 / 2;
  max-width: 100%;
  padding: var(--space-3);
  border: 1px solid var(--rule);
  background: var(--paper-deep);
  color: var(--ink-muted);
  font-size: var(--step--1);
  text-align: center;
}

@media (min-width: 48rem) {
  .photo-slot--wide .photo-slot__frame { aspect-ratio: 16 / 7; }
}

.photo-slot figcaption {
  margin-top: 0.5rem;
  font-size: var(--step--1);
  color: var(--ink-muted);
}

/* Session steps: a real sequence, so they are numbered */

.steps {
  margin-top: var(--space-4);
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps > li {
  display: grid;
  gap: var(--space-1) var(--space-3);
  padding-block: var(--space-3);
  border-top: 1px solid var(--rule);
  counter-increment: step;
}

.steps > li:last-child { border-bottom: 1px solid var(--rule); }

@media (min-width: 40rem) {
  .steps > li { grid-template-columns: 9rem minmax(0, 1fr); }
}

.steps__label {
  font-size: var(--step--1);
  color: var(--ink-muted);
}

.steps__label::before {
  content: counter(step) ".";
  margin-right: 0.4rem;
  font-weight: 600;
  color: var(--ink);
}

.steps__label .ms {
  font-family: var(--font-display);
  font-size: var(--step-1);
  font-style: italic;
  color: var(--ink-muted);
}

.steps h3 { font-size: var(--step-1); }

.steps h3 + p {
  max-width: var(--measure);
  margin-top: 0.4rem;
}

.steps a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: var(--step--1);
  font-weight: 600;
}

/* Plain numbered list for short sequences */

.sequence {
  margin-top: var(--space-3);
  padding-left: 1.5rem;
}

.sequence li { padding-left: 0.25rem; }
.sequence li + li { margin-top: 0.6rem; }
.sequence li::marker { font-weight: 600; }

/* Questions and answers */

.qa { margin-top: var(--space-3); }

.qa > div {
  display: grid;
  gap: 0.35rem var(--space-3);
  padding-block: var(--space-2);
  border-top: 1px solid var(--rule);
}

.qa > div:last-child { border-bottom: 1px solid var(--rule); }

@media (min-width: 48rem) {
  .qa > div { grid-template-columns: minmax(0, 15rem) minmax(0, 1fr); }
}

.qa dt { font-weight: 600; }
.qa dd { margin: 0; }

/* Ruled lines: house rules, journaling prompts */

.ruled {
  margin-top: var(--space-3);
  padding: 0;
  list-style: none;
}

.ruled li {
  padding-block: 0.85rem;
  border-bottom: 1px solid var(--rule);
  font-family: var(--font-display);
  font-size: var(--step-1);
  font-weight: 400;
  line-height: 1.4;
}

.ruled li:first-child { border-top: 1px solid var(--rule); }

/* Support panel */

.support {
  padding: var(--space-4) var(--space-3);
  background: var(--tint);
}

@media (min-width: 48rem) {
  .support { padding: var(--space-4); }
}

.support h2 { font-size: var(--step-2); }

.support > p {
  max-width: var(--measure);
  margin-top: var(--space-2);
}

.lines { margin-top: var(--space-3); }

.lines > div {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0 var(--space-3);
  padding-block: 0.5rem;
  border-top: 1px solid var(--ink-muted);
}

.lines dt { font-weight: 600; }

.lines dt small {
  display: block;
  font-size: var(--step--1);
  font-weight: 400;
}

.lines dd {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--step-2);
  font-variant-numeric: tabular-nums;
}

.lines dd a {
  display: inline-block;
  padding-block: 0.25rem;
  text-decoration-thickness: 1px;
}

.support .small {
  margin-top: var(--space-2);
  font-size: var(--step--1);
}

/* Join block */

.join .actions { margin-top: var(--space-3); }

.join .small {
  margin-top: var(--space-2);
  font-size: var(--step--1);
  color: var(--ink-muted);
}

/* Inner page header */

.page-head { border-bottom: 1px solid var(--rule); }

.page-head .wrap { padding-block: var(--space-3) var(--space-5); }

.crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.4rem;
  margin-bottom: var(--space-3);
  padding: 0;
  list-style: none;
  font-size: var(--step--1);
  color: var(--ink-muted);
}

.crumbs li + li::before {
  content: "/";
  margin-right: 0.4rem;
}

.crumbs a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--ink-muted);
}

.crumbs [aria-current="page"] {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.page-head h1 {
  max-width: 22ch;
  font-size: var(--step-4);
}

.page-head .lead { margin-top: var(--space-3); }
.page-head .byline { margin-top: var(--space-3); }
.page-head .actions { margin-top: var(--space-4); }

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
}

@media (min-width: 60rem) {
  .split {
    grid-template-columns: minmax(0, 7fr) minmax(0, 4fr);
    align-items: start;
    gap: var(--space-5);
  }
}

/* Schedule table */

.table-scroll {
  margin-top: var(--space-3);
  overflow-x: auto;
  border: 1px solid var(--rule);
  background: var(--card);
}

table {
  width: 100%;
  min-width: 34rem;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

th, td {
  padding: 0.75rem 1rem;
  border-bottom: 1px dashed var(--rule);
  text-align: left;
  vertical-align: top;
}

thead th {
  border-bottom: 2px solid var(--cover);
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

tbody tr:last-child td { border-bottom: 0; }

.table-note {
  margin-top: var(--space-1);
  font-size: var(--step--1);
  color: var(--ink-muted);
}

/* Topics list */

.list-head {
  margin-top: var(--space-3);
  font-size: var(--step-1);
}

.list-head + .topics { margin-top: var(--space-1); }

.topics {
  margin-top: var(--space-3);
  padding: 0;
  list-style: none;
  columns: 2 14rem;
  column-gap: var(--space-4);
}

.topics li {
  padding-block: 0.55rem;
  border-top: 1px solid var(--rule);
  break-inside: avoid;
}

/* Long-form text */

.prose { max-width: var(--measure); }
.prose > * + * { margin-top: 1rem; }
.prose h2 { font-size: var(--step-2); }
.prose > h2:not(:first-child) { margin-top: var(--space-4); }
.prose h3 { margin-top: var(--space-3); font-size: var(--step-1); }
.prose ul, .prose ol { padding-left: 1.25rem; }
.prose li + li { margin-top: 0.4rem; }

.refs {
  padding-left: 1.25rem;
  font-size: var(--step--1);
}

.refs li + li { margin-top: 0.6rem; }
.refs a { overflow-wrap: anywhere; }

/* Footer */

.site-footer {
  padding-block: var(--space-5) var(--space-4);
  border-top: 1px solid var(--rule);
  font-size: var(--step--1);
}

.site-footer .wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
}

@media (min-width: 52rem) {
  .site-footer .wrap { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr); }
}

.site-footer .logo img { width: 12rem; }

.site-footer p + p { margin-top: var(--space-2); }

.footer-brand p:first-of-type { margin-top: var(--space-2); }

.site-footer h2 {
  font-family: var(--font-body);
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.site-footer ul {
  margin-top: 0.5rem;
  padding: 0;
  list-style: none;
}

.site-footer li a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.site-footer .footer-support { margin-top: var(--space-2); }

.footer-base {
  padding-top: var(--space-3);
  border-top: 1px solid var(--rule);
  color: var(--ink-muted);
}

@media (min-width: 52rem) {
  .footer-base { grid-column: 1 / -1; }
}

/* 404 */

.not-found .wrap { padding-block: var(--space-6); }
.not-found h1 { font-size: var(--step-4); max-width: 18ch; }
.not-found .lead { margin-top: var(--space-3); }
.not-found .actions { margin-top: var(--space-3); }
.not-found ul { margin-top: var(--space-3); padding-left: 1.25rem; }
.not-found li + li { margin-top: 0.25rem; }

.rsvp textarea { min-height: 9rem; resize: vertical; line-height: 1.55; }

/* Pantun */

.pantun {
  margin-top: var(--space-1);
  font-family: var(--font-display);
  font-size: var(--step-2);
  font-style: italic;
  line-height: 1.5;
  color: var(--hematite);
}

.gloss {
  max-width: var(--measure);
  margin-top: var(--space-2);
  font-size: var(--step--1);
  color: var(--ink-muted);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}
/* RSVP form */

.rsvp {
  display: grid;
  gap: var(--space-3);
  max-width: 32rem;
  margin-top: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--rule);
  border-top: 4px solid var(--baltic);
  background: var(--card);
}

.field {
  display: grid;
  gap: 0.35rem;
}

.field label { font-weight: 600; }

.optional {
  font-weight: 400;
  color: var(--ink-muted);
}

.hint {
  font-size: var(--step--1);
  color: var(--ink-muted);
}

.rsvp input[type="text"],
.rsvp input[type="tel"],
.rsvp input[type="email"],
.rsvp select,
.rsvp textarea {
  width: 100%;
  min-height: 48px;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--ink-muted);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
}

.rsvp input:focus-visible,
.rsvp select:focus-visible,
.rsvp textarea:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.rsvp input:user-invalid,
.rsvp select:user-invalid,
.rsvp textarea:user-invalid {
  border: 2px solid var(--error);
}

.field--check {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 0.75rem;
}

.field--check input {
  width: 1.375rem;
  height: 1.375rem;
  margin: 0.2rem 0 0;
  accent-color: var(--button);
}

.field--check label { font-weight: 400; }

.rsvp .button {
  justify-self: start;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.after-form {
  margin-top: var(--space-4);
  font-size: var(--step-1);
}

.preview-note {
  padding: 0.75rem 1rem;
  background: var(--tint);
  font-size: var(--step--1);
}