/* ==========================================================================
   Components: one section per component. Values come from tokens.css.
   Every component here is shown in design-system.html; add new ones there too.
   Rule order matters in a few places (noted), and the responsive rules stay last.
   ========================================================================== */

/* ===== Section label ===== */
.section-label {
  font-size: var(--text-secondary);
  font-weight: var(--weight-medium);
  color: var(--color-text);
  margin-bottom: var(--space-40);
}

/* ===== Frame =====
   A fixed frame around the browser window; the page scrolls beneath it.
   Square outer corners, rounded inner corners, filled with a gradient whose
   glow follows the cursor (frame.js sets --pointer-x / --pointer-y).

   Fallback (no mask-composite support): a solid frame drawn as a rounded box
   inset by the frame width, with a shadow spread past the window edges. */
body::after {
  content: '';
  position: fixed;
  inset: var(--frame);
  border-radius: var(--frame-radius);
  box-shadow: 0 0 0 calc(var(--frame) * 2 + var(--frame-radius)) var(--color-accent);
  pointer-events: none;
  z-index: var(--z-frame);
}

/* Cursor position, registered so it can ease smoothly. Defaults to the centre. */
@property --pointer-x { syntax: '<length-percentage>'; inherits: true; initial-value: 50%; }
@property --pointer-y { syntax: '<length-percentage>'; inherits: true; initial-value: 50%; }

/* Gradient frame: a full-window gradient with the inner rounded rectangle cut
   out by the mask. Top layer = whole window; the layers below it add up to
   the rounded rectangle (two crossing bands + four corner circles), which is
   subtracted. */
@supports (mask-composite: subtract) {
  html { transition: --pointer-x var(--frame-follow) ease-out, --pointer-y var(--frame-follow) ease-out; }

  body::after {
    --k: calc(var(--frame) + var(--frame-radius));  /* corner circle centre offset */
    --corner: var(--mask-solid) calc(var(--frame-radius) - var(--mask-feather)), transparent var(--frame-radius);
    inset: 0;
    border-radius: 0;
    box-shadow: none;
    background: radial-gradient(circle at var(--pointer-x) var(--pointer-y), var(--color-frame-glow), var(--color-accent) var(--frame-glow));
    mask-image:
      linear-gradient(var(--mask-solid) 0 0),
      linear-gradient(var(--mask-solid) 0 0),
      linear-gradient(var(--mask-solid) 0 0),
      radial-gradient(circle at var(--k) var(--k), var(--corner)),
      radial-gradient(circle at calc(100% - var(--k)) var(--k), var(--corner)),
      radial-gradient(circle at var(--k) calc(100% - var(--k)), var(--corner)),
      radial-gradient(circle at calc(100% - var(--k)) calc(100% - var(--k)), var(--corner));
    mask-size:
      100% 100%,
      calc(100% - 2 * var(--k)) calc(100% - 2 * var(--frame)),
      calc(100% - 2 * var(--frame)) calc(100% - 2 * var(--k)),
      100% 100%, 100% 100%, 100% 100%, 100% 100%;
    mask-position: center;
    mask-repeat: no-repeat;
    mask-composite: subtract, add, add, add, add, add, add;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { transition: none; }
}

/* ===== Navigation =====
   .nav > .nav-inner > [.nav-logo (wordmark), .nav-links > (links, .theme-toggle)] */
.nav {
  position: sticky;
  top: var(--frame);
  padding-top: var(--space-24);
  background: var(--color-bg);
  z-index: var(--z-nav);
}

.nav-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: var(--nav-height);
}

/* Wordmark: an Orange circle and "nanz" in Orange. Large text (24px Heavy), so Orange passes
   contrast here (3.9:1 light, 4.2:1 dark); not for smaller text. */
.nav-logo {
  font-family: var(--font-display);
  font-size: var(--text-heading);
  font-weight: var(--weight-heavy);
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
  color: var(--color-brand);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-12);
}

/* The circle beside the name (decorative, so drawn in CSS) */
.nav-logo::before {
  content: '';
  width: var(--avatar);
  height: var(--avatar);
  border-radius: var(--radius-round);
  background: var(--color-brand);
  flex-shrink: 0;
}

.nav-links { display: flex; align-items: center; gap: var(--space-32); }

/* Theme toggle: round icon button; shows a moon in light mode, a sun in dark */
.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: var(--toggle);
  height: var(--toggle);
  border-radius: var(--radius-round);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color 0.15s;
}

.theme-toggle:hover,
.theme-toggle:focus-visible { border-color: var(--color-text); }
.theme-toggle svg { width: var(--icon); height: var(--icon); }
.theme-toggle .icon-sun,
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

.nav-links a {
  font-size: var(--text-secondary);
  font-weight: var(--weight-medium);
}

.nav-links a[aria-current="page"] { font-weight: var(--weight-heavy); }

/* ===== Hero ===== */
.hero { padding: var(--space-100) 0 var(--space-80); }

.hero-headline {
  font-family: var(--font-display);
  font-size: var(--text-heading);
  font-weight: var(--weight-heavy);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  margin-bottom: var(--space-24);
}

.hero-design { transition: all 0.3s; }

.hero-design:hover {
  background: var(--fill-highlight);
  background-size: var(--fill-highlight-size);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: gradient-shift 2s linear infinite;
}

@keyframes gradient-shift {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

.hero-subtitle {
  font-size: var(--text-body);
  color: var(--color-text);
  margin-bottom: var(--space-32);
  line-height: var(--leading-relaxed);
  max-width: var(--measure);
}

.hero-meta { display: flex; align-items: center; gap: var(--space-24); font-size: var(--text-secondary); font-weight: var(--weight-medium); }

.hero-link { white-space: nowrap; }
.hero-role { color: var(--color-text); }
.hero-role strong { color: var(--color-text); font-weight: var(--weight-heavy); }

/* ===== Project card =====
   .project-card--large (text beside image) or .project-card--small (text above image).
   Image fill variants: --carepatron, --kami, --laurel, --cogo, --lifekit, --kumu */
.project-card__image { width: 100%; min-height: var(--card-image-min); }
.project-card__image--carepatron { background: var(--fill-carepatron); }
.project-card__image--kami { background: var(--fill-kami); }
.project-card__image--laurel { background: var(--fill-laurel); }
.project-card__image--cogo { background: var(--fill-cogo); }
.project-card__image--lifekit { background: var(--fill-lifekit); }
.project-card__image--kumu { background: var(--fill-kumu); }

.project-card__brand {
  font-size: var(--text-secondary);
  font-weight: var(--weight-heavy);
  color: var(--color-text);
  margin: var(--space-16) 0 var(--space-8);
}

.project-card__title {
  font-family: var(--font-display);
  font-size: var(--text-title);
  font-weight: var(--weight-heavy);
  margin-bottom: var(--space-12);
  line-height: var(--leading-snug);
}

.project-card__desc {
  color: var(--color-text);
  font-size: var(--text-body);
  line-height: var(--leading-normal);
  margin-bottom: var(--space-20);
  max-width: var(--measure);
}

.project-card__tags { display: flex; flex-wrap: wrap; gap: var(--space-8); }

.project-card__link {
  font-size: var(--text-secondary);
  font-weight: var(--weight-medium);
}

/* ===== Project list =====
   Projects by date, newest first: a rule, then date, title and description.
   <ol class="project-list"> > <li class="project-list__item"> */
.project-list { list-style: none; border-bottom: 1px solid var(--color-border); }
.project-list__item { padding: var(--space-32) 0; border-top: 1px solid var(--color-border); }
.project-list__date { font-size: var(--text-secondary); font-weight: var(--weight-medium); margin-bottom: var(--space-12); }

.project-list__title {
  font-family: var(--font-display);
  font-size: var(--text-title);
  font-weight: var(--weight-heavy);
  line-height: var(--leading-snug);
  margin-bottom: var(--space-8);
}

.project-list__desc { font-size: var(--text-body); line-height: var(--leading-normal); max-width: var(--measure); }

/* ===== Tag ===== */
.tag {
  display: inline-block;
  padding: var(--space-6) var(--space-14);
  font-size: var(--text-small);
  font-weight: var(--weight-medium);
  border-radius: var(--radius-pill);
  background: var(--color-tag);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

/* ===== Project card: large ===== */
.project-card--large {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: var(--space-32);
  border: 1px solid var(--color-border);
  display: flex;
  align-items: stretch;
  transition: transform 0.2s, box-shadow 0.2s;
}

.project-card--large:hover {
  transform: translateY(calc(-1 * var(--lift)));
  box-shadow: var(--shadow-md);
}

.project-card--large .project-card__info {
  flex: 0 0 var(--card-info);
  padding: var(--space-40);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.project-card--large .project-card__image { flex: 1; min-height: var(--card-image-min-lg); }

/* ===== Project card: small, in a three-column grid ===== */
.project-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-24); }

.project-card--small {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s, box-shadow 0.2s;
}

.project-card--small:hover {
  transform: translateY(calc(-1 * var(--lift)));
  box-shadow: var(--shadow-md);
}

.project-card--small .project-card__info {
  padding: var(--space-24);
  order: -1;
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
}

.project-card--small .project-card__image { flex: 1; min-height: var(--card-image-min-sm); order: 1; }
.project-card--small .project-card__desc { margin-bottom: 0; }
.project-card--small .tag { align-self: flex-start; }

/* ===== About =====
   Order: must come after .section (layout.css) so its padding wins. */
.about { background: var(--color-surface); padding: var(--space-80) 0; }
.about > .container { display: flex; align-items: flex-start; gap: var(--space-60); }
.about-inner { flex: 1; max-width: var(--measure-wide); }
.about-image { flex-shrink: 0; width: var(--about-image); }
.about-image img { width: 100%; border-radius: var(--radius-lg); object-fit: cover; }
.about-label { font-size: var(--text-secondary); font-weight: var(--weight-medium); color: var(--color-text); margin-bottom: var(--space-32); }
.about-bio { font-size: var(--text-body); line-height: var(--leading-loose); color: var(--color-text); margin-bottom: var(--space-20); }
.about-bio:last-of-type { margin-bottom: var(--space-32); }

/* ===== Button =====
   Variants: .btn--outline (fills with the text colour on hover) */
.btn {
  display: inline-block;
  padding: var(--space-14) var(--space-32);
  font-size: var(--text-secondary);
  font-weight: var(--weight-heavy);
  font-family: var(--font-body);
  border-radius: var(--radius-pill);
  text-decoration: none;
  transition: all 0.2s;
}

.btn--outline { color: var(--color-text); background: transparent; border: var(--border-strong) solid var(--color-text); }
.btn--outline:hover { background: var(--color-text); color: var(--color-bg); }

/* ===== Footer ===== */
.footer {
  position: relative;
  margin-top: auto;  /* sits at the bottom of the window on short pages */
  background: var(--color-accent);
  color: var(--color-on-accent);
  padding: var(--space-48) 0;
  text-align: center;
}

/* Round the page's bottom corners where it meets the footer, so the footer
   reads as part of the frame. Same shadow trick as the frame, clipped to
   this strip so only the two corner pieces show. */
.footer::before {
  content: '';
  position: absolute;
  left: var(--frame);
  right: var(--frame);
  bottom: 100%;
  height: var(--frame-radius);
  border-radius: 0 0 var(--frame-radius) var(--frame-radius);
  box-shadow: 0 0 0 var(--frame-radius) var(--color-accent);
  clip-path: inset(0 0 -1px 0);
  pointer-events: none;
}
.footer-tagline { font-family: var(--font-display); font-size: var(--text-title); font-weight: var(--weight-heavy); }

.footer-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-32);
  margin-top: var(--space-20);
}

.footer-links a {
  font-size: var(--text-secondary);
  font-weight: var(--weight-medium);
  color: var(--color-on-accent);
}

/* An accent highlight would vanish on the accent footer, so invert it */
.footer a:not(.nav-logo, .btn):hover,
.footer a:not(.nav-logo, .btn):focus-visible { background-color: var(--color-inverse); color: var(--color-on-inverse); }

.footer-links a[aria-current="page"] { font-weight: var(--weight-heavy); }

/* ===== Page title (sub-pages) ===== */
.page-title {
  font-family: var(--font-display);
  font-size: var(--text-display);
  font-weight: var(--weight-heavy);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  margin-bottom: var(--space-24);
}

/* ===== Style guide (design-system.html only) =====
   Order: .ds-note must stay before .type-specimen (the note uses both). */
.ds-intro { padding: var(--space-100) 0 var(--space-32); }
.ds-section { padding: var(--space-48) 0; }
.ds code { font-family: var(--font-mono); font-size: var(--text-small); color: var(--color-text); }

/* Palette swatches show raw palette tokens on purpose */
.swatch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--swatch-min), 1fr)); gap: var(--space-24); }
.swatch__chip { height: var(--swatch); border-radius: var(--radius-lg); border: 1px solid var(--color-border); margin-bottom: var(--space-12); }
.swatch__chip--orange { background: var(--orange); }
.swatch__chip--mahogany { background: var(--mahogany); }
.swatch__chip--forest { background: var(--forest); }
.swatch__chip--olive { background: var(--olive); }
.swatch__chip--black { background: var(--black); }
.swatch__chip--neutral { background: var(--neutral); }
.swatch__role { font-size: var(--text-small); font-weight: var(--weight-medium); color: var(--color-text); margin: var(--space-2) 0 var(--space-4); }
.ds-note { margin-top: var(--space-40); margin-bottom: 0; }
.ds-lede { max-width: var(--measure-lede); margin-bottom: var(--space-32); }
.theme-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-24); }

.theme-preview {
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-28);
}

.theme-preview__demo { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-12); margin: var(--space-16) 0 var(--space-24); }
.token-list { display: grid; gap: var(--space-10); list-style: none; padding-top: var(--space-20); border-top: 1px solid var(--color-border); }
.token { display: flex; align-items: center; gap: var(--space-12); font-size: var(--text-small); }
.token code { margin-left: auto; color: var(--color-text); }
.token__chip { width: var(--chip); height: var(--chip); border-radius: var(--radius-sm); border: 1px solid var(--color-border); flex-shrink: 0; }
.token__chip--bg { background: var(--color-bg); }
.token__chip--card { background: var(--color-surface); }
.token__chip--text { background: var(--color-text); }
.token__chip--tag { background: var(--color-tag); }
.token__chip--border { background: var(--color-border); }
.swatch__name { font-weight: var(--weight-heavy); font-size: var(--text-secondary); }

.type-specimen {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-32);
  margin-bottom: var(--space-24);
}

.type-specimen__meta { margin-bottom: var(--space-12); font-size: var(--text-small); font-weight: var(--weight-medium); color: var(--color-text); }
.type-specimen--scale { padding: var(--space-8) var(--space-32); }
.type-row { display: grid; grid-template-columns: var(--type-label) 1fr; gap: var(--space-24); align-items: baseline; padding: var(--space-24) 0; border-bottom: 1px solid var(--color-border); }
.type-row:last-child { border-bottom: 0; }
.type-row__meta { display: flex; flex-direction: column; gap: var(--space-2); font-size: var(--text-small); font-weight: var(--weight-medium); color: var(--color-text); }
.type-row__meta strong { color: var(--color-text); font-weight: var(--weight-heavy); font-size: var(--text-secondary); }
.type-row__sample { line-height: var(--leading-snug); min-width: 0; overflow-wrap: anywhere; }
.type-display { font-family: var(--font-display); font-size: var(--text-display); font-weight: var(--weight-heavy); line-height: var(--leading-tight); letter-spacing: var(--tracking-tight); }
.type-heading { font-family: var(--font-display); font-size: var(--text-heading); font-weight: var(--weight-heavy); }
.type-title { font-family: var(--font-display); font-size: var(--text-title); font-weight: var(--weight-heavy); }
.type-body { font-size: var(--text-body); font-weight: var(--weight-medium); }
.type-secondary { font-size: var(--text-secondary); font-weight: var(--weight-medium); }
.type-small { font-size: var(--text-small); font-weight: var(--weight-medium); }

.component-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-24); margin-bottom: var(--space-24); }

.component {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-28);
}

.component__name { font-size: var(--text-small); font-weight: var(--weight-medium); color: var(--color-text); margin-bottom: var(--space-20); }
.component__demo { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-8); }
.component--wide .project-card { margin-bottom: 0; }

/* Style guide demos: spacing bars, radius and shadow samples, image fills */
.ds-flush { margin: 0; }
.ds-stack { margin-top: var(--space-24); }
.ds-accent-panel { background: var(--color-accent); border-color: var(--color-accent); color: var(--color-on-accent); }
.ds-accent-panel .component__name { color: var(--color-on-accent); }
.ds-accent-panel code { color: var(--color-on-accent); }
.space-list { display: grid; gap: var(--space-4); }
.space-row { display: grid; grid-template-columns: var(--type-label) 1fr; gap: var(--space-24); align-items: center; }
.space-bar { display: block; height: var(--space-12); background: var(--color-accent); border-radius: var(--radius-xs); }
.space-bar--2 { width: var(--space-2); }
.space-bar--4 { width: var(--space-4); }
.space-bar--6 { width: var(--space-6); }
.space-bar--8 { width: var(--space-8); }
.space-bar--10 { width: var(--space-10); }
.space-bar--12 { width: var(--space-12); }
.space-bar--14 { width: var(--space-14); }
.space-bar--16 { width: var(--space-16); }
.space-bar--20 { width: var(--space-20); }
.space-bar--24 { width: var(--space-24); }
.space-bar--28 { width: var(--space-28); }
.space-bar--32 { width: var(--space-32); }
.space-bar--40 { width: var(--space-40); }
.space-bar--48 { width: var(--space-48); }
.space-bar--60 { width: var(--space-60); }
.space-bar--64 { width: var(--space-64); }
.space-bar--80 { width: var(--space-80); }
.space-bar--100 { width: var(--space-100); }
.radius-demo { height: var(--swatch); background: var(--color-surface); border: 1px solid var(--color-text); margin-bottom: var(--space-12); }
.radius-demo--xs { border-radius: var(--radius-xs); }
.radius-demo--sm { border-radius: var(--radius-sm); }
.radius-demo--lg { border-radius: var(--radius-lg); }
.radius-demo--pill { border-radius: var(--radius-pill); }
.radius-demo--round { border-radius: var(--radius-round); width: var(--swatch); }
.radius-demo--frame { border-radius: var(--frame-radius); }
.shadow-demo { height: var(--swatch); background: var(--color-surface); border-radius: var(--radius-lg); margin-bottom: var(--space-12); }
.shadow-demo--sm { box-shadow: var(--shadow-sm); }
.shadow-demo--md { box-shadow: var(--shadow-md); }
.fill-chip { min-height: 0; height: var(--swatch); border-radius: var(--radius-lg); margin-bottom: var(--space-12); }

/* ===== Responsive =====
   Breakpoints are listed in tokens.css; keep these literals in sync. */
@media (max-width: 768px) {
  .container, .nav-inner { padding: 0 var(--gutter-sm); }
  .hero { padding: var(--space-64) 0 var(--space-48); }
  .page-title, .type-display { font-size: var(--text-display-sm); }
  .type-row { grid-template-columns: 1fr; gap: var(--space-8); }
  .project-card--large { flex-direction: column; }
  .project-card--large .project-card__info { flex: none; }
  .project-card--large .project-card__image { min-height: var(--card-image-min); }
  .project-grid { grid-template-columns: 1fr; }
  .about > .container { flex-direction: column; gap: var(--space-40); }
  .about-image { width: 100%; max-width: var(--about-image-max); }
  .ds-intro { padding: var(--space-64) 0 var(--space-24); }
  .component-grid { grid-template-columns: 1fr; }
  .theme-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .nav-inner { height: var(--nav-height-sm); }
  .nav { padding-top: var(--space-12); }
  .nav-links { gap: var(--space-16); }
  .hero-meta { flex-direction: column-reverse; align-items: flex-start; gap: var(--space-12); }
  .project-card__info { padding: var(--space-20); }
  .footer-links { gap: var(--space-20); }
  .component { padding: var(--space-20); }
}
