/* ─────────────────────────────────────────────────
   Highku – Shared Styles
   ───────────────────────────────────────────────── */

/* ── Tokens ── */

:root {
  --sage: #8B9D77;
  --sage-dark: #6D7F59;
  --sage-light: #B3C59F;
  --cream: #FCF8F0;
  --cream-dark: #262E21;
  --brown: #8B7765;
  --stone: #A8A39C;
  --text: #333;
  --text-secondary: #666;
  --bg: #B3C59F;
  --bg-card: var(--cream);
  --bg-card-border: rgba(139, 157, 119, 0.15);
  --bg-card-green-light: #E6EEDE;
  --bg-card-green-dark: #4A5A3C;

  --font-serif: -apple-system-ui-serif, ui-serif, 'Georgia', serif;
  --font-sans: -apple-system, BlinkMacSystemFont, 'SF Pro', Helvetica, sans-serif;

  --pad: 24px;
  --card-radius: 24px;
  --card-shadow: 0 8px 30px rgba(0, 0, 0, 0.15), 0 2px 8px rgba(0, 0, 0, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121A0F;
    --text: #e8e4dc;
    --text-secondary: #a8a39c;
    --bg-card: var(--cream-dark);
    --bg-card-border: rgba(139, 157, 119, 0.2);
    --bg-card-green-light: #2A3524;
    --bg-card-green-dark: #1A2116;
  }
}

/* ── Reset ── */

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-serif);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ── Grid layout ── */

.grid {
  display: grid;
  row-gap: var(--pad);
  grid-template-columns:
    [full-width-start] minmax(var(--pad), 1fr)
    [popout-start] 0
    [content-start] min(100% - var(--pad) * 2, 480px)
    [content-end] 0
    [popout-end] minmax(var(--pad), 1fr)
    [full-width-end];
  grid-template-rows: auto;
  padding-block: var(--pad);
}

@media (min-width: 640px) {
  .grid {
    --pad: 32px;
    grid-template-columns:
      [full-width-start] minmax(var(--pad), 1fr)
      [popout-start] minmax(var(--pad), 160px)
      [content-start] minmax(0, 600px)
      [content-end] minmax(var(--pad), 160px)
      [popout-end] minmax(var(--pad), 1fr)
      [full-width-end];
  }
}

/* Default: children sit in the content lane */
.grid > * {
  grid-column: content;
}

.grid > .popout {
  grid-column: popout;
}

.grid > .full-width {
  grid-column: full-width;
}

/* ── Stacking cards ── */

.stack-card {
  grid-column: full-width;
  position: sticky;
  top: var(--pad);
  width: calc(100% - var(--pad) - var(--pad));
  min-height: calc(100svh - var(--pad) * 2);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  justify-self: center;
  background: var(--bg-card);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  padding: var(--pad);
  margin-inline: var(--pad);
}

@media (min-width: 640px) {
  .stack-card {
    padding: calc(var(--pad) * 2);
    max-width: 900px;
  }

  /* Stagger the sticky top offset so each card peeks above the next */
  .stack-card:nth-child(1)  { top: var(--pad); }
  .stack-card:nth-child(2)  { top: calc(var(--pad) + 6px); }
  .stack-card:nth-child(3)  { top: calc(var(--pad) + 12px); }
  .stack-card:nth-child(4)  { top: calc(var(--pad) + 18px); }
  .stack-card:nth-child(5)  { top: calc(var(--pad) + 24px); }
  .stack-card:nth-child(6)  { top: calc(var(--pad) + 30px); }
  .stack-card:nth-child(7)  { top: calc(var(--pad) + 36px); }
  .stack-card:nth-child(8)  { top: calc(var(--pad) + 42px); }
  .stack-card:nth-child(9)  { top: calc(var(--pad) + 48px); }
  .stack-card:nth-child(10) { top: calc(var(--pad) + 54px); }
}

@media (max-width: 640px) {
  .stack-card {
    position: relative;
    top: 0;
    min-height: auto;
  }
}

/* z-index: each card covers the one before it */
.stack-card:nth-child(1)  { z-index: 1; }
.stack-card:nth-child(2)  { z-index: 2; }
.stack-card:nth-child(3)  { z-index: 3; }
.stack-card:nth-child(4)  { z-index: 4; }
.stack-card:nth-child(5)  { z-index: 5; }
.stack-card:nth-child(6)  { z-index: 6; }
.stack-card:nth-child(7)  { z-index: 7; }
.stack-card:nth-child(8)  { z-index: 8; }
.stack-card:nth-child(9)  { z-index: 9; }
.stack-card:nth-child(10) { z-index: 10; }

/* ── Card colour variants ── */

.stack-card--green-light {
  background: var(--bg-card-green-light);
  align-items: center;
  text-align: center;
}

.stack-card--green-dark {
  background: var(--bg-card-green-dark);
  color: #e8e4dc;
  align-items: center;
  text-align: center;
}

.stack-card--green-dark .hero-haiku,
.stack-card--green-dark .footer-haiku,
.stack-card--green-dark .cta-secondary {
  color: rgba(232, 228, 220, 0.7);
}

.stack-card--green-dark .footer-links {
  color: rgba(232, 228, 220, 0.5);
}

.stack-card--green-dark .footer-links a,
.stack-card--green-dark .cta-secondary a {
  color: var(--sage-light);
}

.stack-card--green-dark .footer-logo {
  filter: invert(1);
  opacity: 0.4;
}

/* ── Card (deep-link card) ── */

.card {
  background: var(--bg-card);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  padding: 40px 32px;
  margin-bottom: 32px;
}

.card-label {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  text-align: left;
  letter-spacing: 0.05em;
  color: var(--sage);
  margin-bottom: 24px;
}

.card-haiku {
  font-style: italic;
  font-size: 19px;
  line-height: 1.75;
  text-align: left;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.card-explanation h2,
.card-explanation h3 {
  font-family: var(--font-sans);
  font-weight: 600;
}

.card-explanation h2 {
  font-size: 19px;
  margin: 38px 0 8px;
}

.card-explanation h3 {
  font-size: 15px;
  margin: 24px 0 8px;  
}

.card-explanation h2:first-child,
.card-explanation h3:first-child {
  margin-top: 0;
}

.card-explanation ul,
.card-explanation ol {
  padding-left: 20px;
  margin: 8px 0;
}

.card-explanation li {
  margin-bottom: 4px;
}

.card-explanation {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-secondary);
  text-align: left;
}

.card-explanation a {
  color: var(--sage);
  text-decoration: underline;
}

.card-explanation a:hover {
  color: var(--sage-dark);
}

/* ── Buttons ── */

.cta-button {
  display: inline-block;
  background: var(--sage);
  color: white;
  text-decoration: none;
  padding: 16px 40px;
  border-radius: 16px;
  font-size: 17px;
  font-family: var(--font-sans);
  font-weight: 600;
  transition: background 0.2s, transform 0.2s;
  letter-spacing: -0.01em;
}

.cta-button:hover {
  background: var(--sage-dark);
  transform: scale(1.03);
}

.cta-secondary {
  display: block;
  margin-top: 16px;
  font-size: 14px;
  color: var(--text-secondary);
  font-family: var(--font-sans);
}

.cta-secondary a {
  color: var(--sage);
  text-decoration: none;
}

.cta-secondary a:hover {
  text-decoration: underline;
}

/* ── Logo ── */

.logo {
  width: 48px;
  margin-bottom: 32px;
}

/* ── Centered page layout (deep-link & 404 pages) ── */

.page-centered {
  min-height: 100svh;
  align-items: center;
  align-content: center;
  text-align: center;
}

/* ── Haiku (standalone, e.g. 404) ── */

.haiku {
  font-style: italic;
  font-size: 19px;
  line-height: 2.2;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.haiku a {
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--sage);
  text-decoration: none;
}

.haiku a:hover {
  text-decoration: underline;
}

/* ── Hero (inside a stack-card) ── */

.hero-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
}

.hero-logo {
  width: 240px;
  max-width: 60vw;
  margin-bottom: 48px;
}

.hero-haiku {
  font-style: italic;
  font-size: clamp(18px, 4vw, 22px);
  line-height: 2.2;
  color: var(--text-secondary);
  margin-bottom: 48px;
}

/* ── Feature card content ── */

.card-inner {
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 1;
  text-align: left;
  width: 100%;
  max-width: 480px;
  padding: 16px 0;
}

@media (min-width: 640px) {
  .card-inner {
    max-width: none;
    flex-direction: row;
    align-items: center;
    gap: 24px;
  }
}

.card-text {
  flex: 1;
  min-width: 0;
}

.card-title {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sage);
  margin-bottom: 24px;
}

.card-poem {
  font-style: italic;
  font-size: clamp(18px, 4vw, 28px);
  line-height: 2;
  color: var(--text-secondary);
}

.card-screenshot {
  display: block;
  width: 220px;
  max-width: 50vw;
  height: auto;
  border-radius: 16px;
  margin-top: 32px;
  align-self: center;
}

@media (min-width: 640px) {
  .card-screenshot {
    width: 260px;
    max-width: none;
    margin-top: 0;
    flex-shrink: 0;
  }
}

/* ── Section heading ── */

.section-heading {
  text-align: center;
  padding-block: 24px;
}

.section-heading h2 {
  font-size: clamp(24px, 5vw, 32px);
  font-weight: 400;
  color: var(--sage);
}

/* ── Footer (inside a stack-card) ── */

.footer-inner {
  text-align: center;
  padding-block: 48px;
}

.footer-logo {
  width: 40px;
  margin-bottom: 20px;
  opacity: 0.5;
}

.footer-haiku {
  font-style: italic;
  font-size: 15px;
  line-height: 2;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.footer-links {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--stone);
}

.footer-links a {
  color: var(--sage);
  text-decoration: none;
}

.footer-links a:hover {
  text-decoration: underline;
}
