/* ============================================================
   Chung Wah School — chungwahschool.com
   Palette: ink green + aged paper + antique gold
   ============================================================ */

:root {
  --ink: #12352c;
  --ink-soft: #3d564d;
  --ink-faint: #6d8078;
  --gold: #a8791f;
  --paper: #f4f1e8;
  --paper-raised: #fdfcf8;
  --line: rgba(18, 53, 44, 0.13);
  --line-soft: rgba(18, 53, 44, 0.07);
  --shadow-rest: 0 1px 2px rgba(18, 53, 44, 0.05), 0 12px 28px -14px rgba(18, 53, 44, 0.22);
  --shadow-hover: 0 2px 4px rgba(18, 53, 44, 0.06), 0 26px 48px -18px rgba(18, 53, 44, 0.34);

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia,
    "Times New Roman", serif;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, "Helvetica Neue", Arial, sans-serif;
  --cjk-serif: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", STSong, SimSun,
    "PingFang SC", "Microsoft YaHei", serif;

  color-scheme: light;
  font-family: var(--sans);
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(ellipse 60rem 28rem at 50% -6rem, rgba(168, 121, 31, 0.13), transparent 70%),
    radial-gradient(ellipse 50rem 34rem at 92% 110%, rgba(18, 53, 44, 0.07), transparent 70%);
  background-attachment: fixed;
}

.page {
  display: flex;
  flex-direction: column;
  align-items: center;
  /* "safe" so a short screen falls back to top-aligned instead of clipping */
  justify-content: safe center;
  gap: clamp(1.6rem, 4.5vw, 2.25rem);
  min-height: 100svh;
  padding: clamp(2rem, 6vw, 3.25rem) clamp(1rem, 5vw, 3rem) clamp(2.25rem, 5vw, 3.25rem);
}

/* ---------------- Masthead ---------------- */

.masthead {
  width: min(100%, 40rem);
  text-align: center;
}

.eyebrow {
  margin: 0 0 0.9rem;
  color: var(--gold);
  font-size: clamp(0.66rem, 1.6vw, 0.74rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.34em;
  text-indent: 0.34em;
  text-transform: uppercase;
}

.wordmark {
  margin: 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(2rem, 6.6vw, 3.4rem);
  font-weight: 400;
  line-height: 1.04;
  letter-spacing: 0.005em;
}

.wordmark-cn {
  margin: clamp(0.75rem, 2vw, 1.05rem) 0 0;
  color: var(--ink-faint);
  font-family: var(--cjk-serif);
  font-size: clamp(0.9rem, 2.4vw, 1.06rem);
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.42em;
  text-indent: 0.42em;
}

main {
  width: min(100%, 40rem);
}

/* ---------------- Course cards ---------------- */

/* two up at every width, so both courses fit one phone screen */
.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 19.5rem), 19.5rem));
  justify-content: center;
  gap: clamp(0.75rem, 2.6vw, 1.6rem);
  margin: 0;
  padding: 0;
  list-style: none;
}

.course-grid > li {
  display: flex;
  width: 100%;
  max-width: 19.5rem;
  justify-self: center;
}

/* Keep courses here so they can be restored without rebuilding the card. */
.course-grid > .course-hidden {
  display: none;
}

.course-card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: var(--paper-raised);
  box-shadow: var(--shadow-rest);
  transition:
    transform 260ms cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 260ms cubic-bezier(0.22, 1, 0.36, 1),
    border-color 260ms ease;
}

.course-card:hover,
.course-card:focus-within {
  transform: translateY(-5px);
  border-color: rgba(168, 121, 31, 0.3);
  box-shadow: var(--shadow-hover);
}

/* Cover plate — square, drawn artwork rather than a photograph */
.cover {
  position: relative;
  border-bottom: 1px solid var(--line-soft);
}

.cover > svg,
.cover > img {
  display: block;
  width: 100%;
  height: auto;
}

.cover::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(18, 53, 44, 0.05);
}

.glyph {
  font-family: var(--cjk-serif);
}

.card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: clamp(0.85rem, 2.6vw, 1.5rem);
}

.card-body h3 {
  margin: 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(0.98rem, 2.4vw, 1.3rem);
  font-weight: 400;
  line-height: 1.24;
  text-wrap: balance;
}

.card-body h3 span {
  display: block;
  margin-top: 0.4rem;
  color: var(--gold);
  font-family: var(--cjk-serif);
  font-size: clamp(0.72rem, 1.5vw, 0.82rem);
  line-height: 1;
  letter-spacing: 0.22em;
  text-indent: 0.22em;
}

.blurb {
  margin: 0.8rem 0 0;
  color: var(--ink-soft);
  font-size: clamp(0.8rem, 1.6vw, 0.88rem);
  line-height: 1.6;
  text-wrap: pretty;
}

.course-status {
  margin: auto 0 0;
  padding-top: 1.15rem;
  color: var(--gold);
  font-size: clamp(0.78rem, 1.5vw, 0.83rem);
  font-weight: 600;
  letter-spacing: 0.03em;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.4rem;
  margin: 0.9rem 0 0;
  padding: 0;
  list-style: none;
}

.meta li {
  padding: 0.24rem 0.58rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-faint);
  font-size: 0.685rem;
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.cta {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 0.45rem;
  margin-top: auto;
  padding-top: 1.15rem;
  color: var(--ink);
  font-size: clamp(0.78rem, 1.5vw, 0.83rem);
  font-weight: 600;
  letter-spacing: 0.03em;
  text-decoration: none;
}

/* stretched hit area — the whole card is the link */
.cta::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.cta svg {
  width: 1.05rem;
  height: 1.05rem;
  fill: none;
  stroke: var(--gold);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 260ms cubic-bezier(0.22, 1, 0.36, 1);
}

.course-card:hover .cta,
.course-card:focus-within .cta {
  color: var(--gold);
}

.course-card:hover .cta svg,
.course-card:focus-within .cta svg {
  transform: translateX(4px);
}

.cta:focus-visible {
  outline: none;
}

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

/* ---------------- Responsive ---------------- */

@media (max-width: 34rem) {
  .course-card {
    border-radius: 11px;
  }

  .card-body {
    padding: 0.8rem 0.85rem 0.95rem;
  }

  .cta {
    padding-top: 0.9rem;
  }

  .cta svg {
    width: 0.9rem;
    height: 0.9rem;
  }
}

/* ---------------- Dark mode ---------------- */

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --ink: #eae5d8;
    --ink-soft: #b3bcb2;
    --ink-faint: #8b968d;
    --gold: #d5aa55;
    --paper: #101a17;
    --paper-raised: #16211d;
    --line: rgba(234, 229, 216, 0.16);
    --line-soft: rgba(234, 229, 216, 0.09);
    --shadow-rest: 0 12px 30px -16px rgba(0, 0, 0, 0.8);
    --shadow-hover: 0 28px 52px -20px rgba(0, 0, 0, 0.9);
  }

  body {
    background-image:
      radial-gradient(ellipse 60rem 28rem at 50% -6rem, rgba(213, 170, 85, 0.11), transparent 70%),
      radial-gradient(ellipse 50rem 34rem at 92% 110%, rgba(213, 170, 85, 0.05), transparent 70%);
  }

  /* the artwork stays a printed plate; just take the glare off it */
  .cover > svg {
    filter: brightness(0.86) saturate(0.94);
  }

  .cover::after {
    box-shadow: inset 0 0 0 1px rgba(234, 229, 216, 0.07);
  }

  .course-card:hover,
  .course-card:focus-within {
    border-color: rgba(213, 170, 85, 0.32);
  }
}

/* ---------------- Motion preferences ---------------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
  .course-card:hover,
  .course-card:focus-within {
    transform: none;
  }
}
