/* ==========================================================================
   KiM — landing page
   Static: HTML + CSS + JS only.
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  /* Palette */
  --c-primary: #1b264f;
  --c-primary-deep: #111a38;     /* hover / pressed shade of primary */
  --c-on-primary: #f4f3ee;       /* text on primary surfaces */
  --c-secondary: #de9e36;
  --c-bg: #f4f3ee;
  --c-surface: #fbfaf6;          /* card fill, a touch lighter than paper */
  --c-surface-deep: #e2dfd4;     /* pressed card / ghost button */
  --c-panel: #ece9e0;            /* large section card, between paper and pressed card */
  --c-ink: #000000;              /* headings + body */
  --c-red: #90323d;              /* second halftone ink + layered shapes */
  --c-ink-soft: rgb(0 0 0 / 0.72);
  /* soft paper-coloured glow behind small text that sits over the halftone */
  --paper-halo: 0 0 2px var(--c-bg), 0 0 6px var(--c-bg), 0 0 12px var(--c-bg), 0 0 18px var(--c-bg);
  --c-grid: rgb(27 38 79 / 0.07);       /* grid-paper minor lines */
  --c-grid-major: rgb(27 38 79 / 0.13); /* grid-paper major lines */
  --grid: 24px;
  --grid-major: 120px;
  --c-link: #387780;
  --c-success: #23ce6b;
  --c-failure: #ff5400;
  --c-rule: rgb(25 29 50 / 0.12);

  /* Type */
  --f-display: "Indie Flower", "Comic Sans MS", cursive;
  --f-sub: "Solitreo", "Figtree", system-ui, sans-serif;   /* subtext */
  --f-body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-ko: "Gaegu", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --f-ko-text: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;   /* Korean meant to be read closely */

  --lh-body: 1.6;
  --lh-ko: 1.8;                  /* Hangul gets extra air */
  --lh-tight: 1.08;

  /* Spacing — 4px scale */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;
  --s-12: 48px;
  --s-16: 64px;
  --s-20: 80px;
  --s-24: 96px;
  --s-32: 128px;

  --container: 1200px;
  --gutter: var(--s-6);
  --nav-h: 72px;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + var(--s-4));
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background-color: var(--c-bg);
  color: var(--c-ink);
  font-family: var(--f-body);
  font-size: 1.0625rem;          /* 17px */
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  font-synthesis: none;          /* Indie Flower has no bold/italic; don't fake them */
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

h1, h2, h3 {
  font-family: var(--f-display);
  font-weight: 400;
  line-height: var(--lh-tight);
  letter-spacing: -0.01em;
  margin: 0;
  text-wrap: balance;
}

p { margin: 0; text-wrap: pretty; }

:lang(ko) {
  font-family: var(--f-ko);
  line-height: var(--lh-ko);
  letter-spacing: 0;
}

a { color: var(--c-link); }

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

:focus-visible {
  outline: 3px solid var(--c-secondary);
  outline-offset: 3px;
  border-radius: 4px;
}

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.skip-link {
  position: absolute;
  left: var(--s-4);
  top: -100px;
  z-index: 100;
  padding: var(--s-2) var(--s-4);
  background: var(--c-ink);
  color: var(--c-bg);
  border-radius: 8px;
  text-decoration: none;
}
.skip-link:focus { top: var(--s-4); }

/* ---------- Fixed paper texture ---------- */
.paper {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-color: var(--c-bg);
  background-image:
    /* grid paper: a major line every 5 squares, faint minor lines between */
    linear-gradient(to right, var(--c-grid-major) 1px, transparent 1px),
    linear-gradient(to bottom, var(--c-grid-major) 1px, transparent 1px),
    linear-gradient(to right, var(--c-grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--c-grid) 1px, transparent 1px),
    /* faint warm vignette so the sheet feels lit, not flat */
    radial-gradient(120% 90% at 50% 40%, transparent 55%, rgb(120 96 60 / 0.05) 100%),
    /* fibre grain */
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.35  0 0 0 0 0.30  0 0 0 0 0.22  0 0 0 0.38 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    /* larger, softer mottling */
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='600' height='600'%3E%3Cfilter id='m'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.012' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.45  0 0 0 0 0.38  0 0 0 0 0.25  0 0 0 0.14 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23m)'/%3E%3C/svg%3E");
  background-size:
    var(--grid-major) var(--grid-major), var(--grid-major) var(--grid-major),
    var(--grid) var(--grid), var(--grid) var(--grid),
    auto, 240px 240px, 600px 600px;
  background-position: center top;
}

/* ---------- Squircle (progressive) ----------
   Fallback is a plain radius; main.js swaps in a true superellipse
   clip-path once it runs. Browsers with native corner-shape use that. */
.squircle {
  border-radius: 28px;
}
@supports (corner-shape: squircle) {
  .squircle {
    border-radius: 48px;
    corner-shape: squircle;
  }
  .card.squircle { border-radius: 40px; }
}

/* ---------- Navbar ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--nav-h);
  background: #000;
  color: var(--c-on-primary);
  transition: box-shadow 200ms ease;
  /* on arrival the bar drops in from the top, then its contents follow */
  animation: nav-in 700ms var(--ease-out) both;
}
.nav.is-scrolled { box-shadow: 0 6px 16px -8px rgb(0 0 0 / 0.5); }
.nav__brand,
.nav__links li {
  animation: nav-item-in 600ms var(--ease-out) both;
  animation-delay: calc(250ms + var(--i, 0) * 80ms);
}
.nav__links li:nth-child(1) { --i: 1; }
.nav__links li:nth-child(2) { --i: 2; }
.nav__links li:nth-child(3) { --i: 3; }
@keyframes nav-in {
  from { opacity: 0; translate: 0 -100%; }
}
@keyframes nav-item-in {
  from { opacity: 0; translate: 0 -12px; }
}
@keyframes nav-fade-in {
  from { opacity: 0; }
}

.nav__inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-6);
}

.nav__brand {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  line-height: 1;
}
.nav__brand img {
  width: 48px;
  height: 48px;
}
.nav__brand:hover,
.nav__brand:focus,
.nav__brand:visited { text-decoration: none; }

.nav__links {
  position: relative;
  isolation: isolate;            /* keeps the CTA's red layer behind it but in the nav */
  display: flex;
  align-items: center;
  gap: var(--s-2);
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav__links a {
  display: inline-block;
  padding: var(--s-2) var(--s-3);
  color: var(--c-on-primary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9375rem;
  border-radius: 999px;
  position: relative;
}
/* One underline for the whole bar: main.js moves it (via --ind-x / --ind-w)
   to the section in view, or to whichever link is hovered, and it slides
   between them */
.nav__links::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 6px;
  width: var(--ind-w, 0px);
  height: 2px;
  background: var(--c-secondary);
  translate: var(--ind-x, 0px) 0;
  pointer-events: none;
  /* fades in with the links (opacity only: translate is the position) */
  animation: nav-fade-in 600ms var(--ease-out) 330ms both;
}
.nav__links.is-sliding::after {
  transition: translate 380ms var(--ease-out), width 380ms var(--ease-out);
}

.nav__links .nav__cta {
  margin-left: var(--s-2);
  padding: var(--s-2) var(--s-5);
  background: var(--c-primary);
  color: var(--c-on-primary);
  --layer: 3px;
  top: 0;
  left: 0;
  transition: background-color 140ms ease, top 140ms var(--ease-out), left 140ms var(--ease-out);
}
.nav__links .nav__cta::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: var(--c-red);
  translate: var(--layer) var(--layer);
  transition: translate 140ms var(--ease-out);
}
/* Pressed: the button drops onto its red layer, hiding it */
.nav__links .nav__cta:hover,
.nav__links .nav__cta:active {
  top: var(--layer);
  left: var(--layer);
  background: var(--c-primary-deep);
}
.nav__links .nav__cta:hover::before,
.nav__links .nav__cta:active::before { translate: 0 0; }

/* ---------- Buttons & links ---------- */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 48px;
  padding: var(--s-3) var(--s-6);
  border-radius: 999px;
  font: 600 1rem/1.2 var(--f-body);
  text-decoration: none;
  --layer: 4px;
  top: 0;
  left: 0;
  transition: background-color 140ms ease, color 140ms ease, box-shadow 140ms ease,
    top 140ms var(--ease-out), left 140ms var(--ease-out);
}

/* Layered: a red copy of the shape sits offset behind each button */
.btn::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: var(--c-red);
  translate: var(--layer) var(--layer);
  transition: translate 140ms var(--ease-out);
}
/* Pressed: the button drops onto its red layer, hiding it. Moved with
   top/left rather than a transform, so the button doesn't become a
   stacking context and lift its red layer in front of itself. The layer
   moves back by the same amount, so it stays put on the page. */
.btn:hover,
.btn:active {
  top: var(--layer);
  left: var(--layer);
}
.btn:hover::before,
.btn:active::before { translate: 0 0; }

.btn--primary {
  background: var(--c-primary);
  color: var(--c-on-primary);
  box-shadow: 0 1px 0 rgb(255 255 255 / 0.2) inset, 0 6px 16px -8px rgb(27 38 79 / 0.6);
}
.btn--primary:hover,
.btn--primary:active {
  background: var(--c-primary-deep);
  box-shadow: 0 1px 0 rgb(255 255 255 / 0.12) inset;
}

.btn--ghost {
  background: var(--c-surface);  /* solid, so the red layer doesn't show through */
  color: var(--c-ink);
  box-shadow: inset 0 0 0 1.5px var(--c-rule);
}
.btn--ghost:hover,
.btn--ghost:active {
  background: var(--c-surface-deep);
  box-shadow: inset 0 0 0 1.5px var(--c-ink);
}

.link {
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: rgb(56 119 128 / 0.35);
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
  transition: text-decoration-color 160ms ease;
}
.link:hover { text-decoration-color: currentColor; }

/* ---------- Hero ---------- */
/* The hero is full-bleed: the halftone fills the whole section behind the
   copy, with the building on the right and the dots thinning out toward
   the text (left) and the bottom edge. */
.hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  align-items: center;
  min-height: calc(100svh - var(--nav-h));
  padding-block: var(--s-12) var(--s-24);
}

.hero__inner {
  position: relative;
  z-index: 1;
}

.hero__copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 36rem;
}

.hero__greeting {
  font-size: 2rem;
  font-weight: 700;
  color: var(--c-ink);
  margin-bottom: var(--s-3);
  transform: rotate(-2deg);
  transform-origin: left center;
}

.hero__title {
  font-size: clamp(2.75rem, 1.6rem + 4.2vw, 5.25rem);
  font-weight: 400;
  line-height: 1.04;
  letter-spacing: -0.02em;
  margin-bottom: var(--s-8);
}
.hero__title em {
  font-style: italic;
  font-weight: 400;
  color: var(--c-ink);
  padding-inline: 0.04em;
}

.hero__lede {
  font-family: var(--f-sub);
  /* kept narrow so it ends before the halftone gets dense */
  max-width: 22em;
  font-size: 1.1875rem;
  line-height: 1.65;
  color: rgb(0 0 0 / 0.86);
  margin-bottom: var(--s-10);
  text-shadow: var(--paper-halo);
}

.hero__actions {
  isolation: isolate;            /* keeps the buttons' red layers above the hero art */
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
  margin-bottom: var(--s-6);
}

.hero__note {
  font-family: var(--f-sub);
  max-width: 26em;
  font-size: 0.875rem;
  color: var(--c-ink-soft);
  text-shadow: var(--paper-halo);
}

/* Fade-up entrance for hero copy */
.reveal {
  opacity: 0;
  translate: 0 24px;
  animation: rise 900ms var(--ease-out) forwards;
  animation-delay: var(--d, 0ms);
}
@keyframes rise {
  to { opacity: 1; translate: 0 0; }
}

/* ---------- Halftone background ---------- */
.hero__bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* Fade in once the first frame is drawn (only when JS is running) */
.js .halftone {
  opacity: 0;
  transition: opacity 1100ms ease 150ms;
}
.js .halftone.is-ready { opacity: 1; }

.halftone__canvas,
.halftone__fallback {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Used when the canvas can't read pixels (e.g. the page was opened from
   file://, or JS is off): the photo itself, inked toward the primary
   colour and faded the same way the dots are. */
.halftone__fallback {
  object-fit: cover;
  object-position: 100% 40%;
  filter: grayscale(1) sepia(1) hue-rotate(190deg) saturate(1.6) brightness(0.8) contrast(1.05);
  mix-blend-mode: multiply;
  opacity: 0.55;
  -webkit-mask-image: linear-gradient(to right, transparent 12%, #000 57%);
  mask-image: linear-gradient(to right, transparent 12%, #000 57%);
}
.halftone.is-fallback .halftone__canvas { display: none; }

/* ---------- Info / cards ---------- */
.info {
  padding-block: var(--s-16) var(--s-24);
}

/* One large card holding the whole section. The shell carries the shadow
   so the squircle clip on the panel doesn't cut it off. */
.info__shell {
  filter: drop-shadow(0 1px 1px rgb(25 29 50 / 0.05)) drop-shadow(0 18px 40px rgb(25 29 50 / 0.08));
}
.info__panel {
  padding: var(--s-16) var(--s-12) var(--s-20);
  background: var(--c-panel);
}
@supports (corner-shape: squircle) {
  .info__panel.squircle { border-radius: 64px; }
}

/* Scroll-linked: main.js sets --p (0..1) from the scroll position, so the
   panel rises in as you scroll down and sinks back as you scroll up */
.js .info__shell {
  opacity: var(--p, 0);
  translate: 0 calc((1 - var(--p, 0)) * 48px);
  scale: calc(0.98 + 0.02 * var(--p, 0));
}

.info__head {
  max-width: 40rem;
  margin-bottom: var(--s-12);
}

.eyebrow {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--c-ink);
  margin-bottom: var(--s-2);
}

.info__title {
  font-size: clamp(2rem, 1.4rem + 2.2vw, 3.25rem);
}

.cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s-6);
  align-items: stretch;
}

/* The shell carries the shadow so the squircle clip on .card doesn't cut it off */
.card-shell {
  position: relative;
  display: flex;
  filter: drop-shadow(0 1px 1px rgb(25 29 50 / 0.06)) drop-shadow(0 12px 24px rgb(25 29 50 / 0.06));
}

/* Layered: a red copy of the card's shape sits offset behind it. main.js
   passes the squircle clip up as --squircle-clip when it computes one. */
.card-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--c-red);
  border-radius: 28px;
  clip-path: var(--squircle-clip, none);
  translate: 10px 10px;
}
@supports (corner-shape: squircle) {
  .card-shell::before { border-radius: 40px; corner-shape: squircle; }
}

.card {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  padding: var(--s-10) var(--s-8) var(--s-8);
  background: var(--c-surface);
  color: var(--c-ink);
  transition: translate 160ms var(--ease-out), background-color 160ms ease;
}
/* Pressed: the card drops onto its red layer, hiding it */
.card-shell:hover .card {
  translate: 10px 10px;
  background: var(--c-surface-deep);
}
.card-shell:hover .card--feature { background: var(--c-primary-deep); }
.card p {
  font-family: var(--f-sub);
  color: var(--c-ink-soft);
  line-height: 1.7;
}
.card .link { margin-top: auto; padding-top: var(--s-2); }

.card__index {
  font-family: var(--f-display);
  font-style: italic;
  font-size: 1rem;
  color: var(--c-secondary);
  letter-spacing: 0.04em;
}

.card__title {
  font-size: 1.75rem;
  margin-bottom: var(--s-1);
}

.card--feature {
  background: var(--c-primary);
  color: var(--c-on-primary);
}
.card--feature p { color: rgb(244 243 238 / 0.86); }
.card--feature .card__index { color: var(--c-secondary); }
.card--feature .link {
  color: var(--c-on-primary);
  text-decoration-color: rgb(222 158 54 / 0.8);
}
.card--feature .link:hover { text-decoration-color: var(--c-secondary); }

/* Cards follow the panel, also scroll-linked through --p (see main.js) */
.js .card-shell {
  opacity: var(--p, 0);
  translate: 0 calc((1 - var(--p, 0)) * 32px);
}

/* ---------- Footer ---------- */
.footer {
  background: #000;
  color: var(--c-on-primary);
  padding-block: var(--s-16) var(--s-10);
}
.footer a { color: var(--c-on-primary); }

.footer__inner {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--s-10) var(--s-8);
}

.footer__wordmark {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 2.25rem;
  line-height: 1;
  margin-bottom: var(--s-3);
}
.footer__wordmark [lang="ko"] {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--c-secondary);
  margin-left: var(--s-2);
  vertical-align: middle;
}

.footer__tagline { color: rgb(244 243 238 / 0.8); }

.footer__links {
  display: flex;
  gap: var(--s-6);
  align-items: flex-start;
  flex-wrap: wrap;
}
.footer__links a {
  text-decoration: none;
  font-weight: 500;
}
.footer__links a:hover { text-decoration: underline; text-underline-offset: 4px; }

.footer__base {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-6);
  flex-wrap: wrap;
  padding-top: var(--s-8);
  border-top: 1px solid rgb(244 243 238 / 0.2);
}

.footer__vu {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}
.footer__vu img { height: 40px; width: auto; }
.footer__vu-text {
  display: none;
  font-family: var(--f-display);
  font-size: 1.125rem;
  letter-spacing: 0.02em;
}
.footer__vu.is-text img { display: none; }
.footer__vu.is-text .footer__vu-text { display: inline; }

.footer__legal {
  font-size: 0.8125rem;
  color: rgb(244 243 238 / 0.75);
}
.footer__legal a { text-underline-offset: 3px; }

/* :focus ring on dark footer */
.footer :focus-visible { outline-color: var(--c-secondary); }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  /* Stacked: copy on top, the building rises from the bottom of the hero */
  .hero {
    align-items: flex-start;
    min-height: auto;
    padding-block: var(--s-10) clamp(360px, 92vw, 620px);
  }
  .hero__bg {
    inset: auto 0 0 0;
    height: clamp(460px, 118vw, 820px);
  }
  .halftone__fallback {
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, #000 38%);
    mask-image: linear-gradient(to bottom, transparent 0%, #000 38%);
  }

  .cards { grid-template-columns: 1fr; max-width: 40rem; }
  .info { padding-block: var(--s-10) var(--s-16); }
  .info__panel { padding: var(--s-10) var(--s-6) var(--s-12); }
}

@media (max-width: 600px) {
  :root {
    --gutter: var(--s-4);
    --nav-h: 64px;
  }
  .nav__brand img { width: 40px; height: 40px; }
  .nav__links { gap: 0; }
  .nav__links a { padding: var(--s-2); font-size: 0.875rem; }
  .nav__links .nav__cta { padding: var(--s-2) var(--s-4); margin-left: var(--s-1); }

  .hero__greeting { font-size: 1.5rem; }
  .hero__lede { font-size: 1.0625rem; }
  .hero__actions { width: 100%; }
  .hero__actions .btn { flex: 1 1 100%; }

  .card { padding: var(--s-8) var(--s-6) var(--s-6); }

  .footer__inner { grid-template-columns: 1fr; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal,
  .js .info__shell,
  .js .card-shell {
    animation: none;
    opacity: 1;
    translate: none;
    scale: none;
    transition: none;
  }
  .js .halftone { transition: none; }
  .nav,
  .nav__brand,
  .nav__links li,
  .nav__links::after { animation: none; }
  .nav__links.is-sliding::after { transition: none; }
}
