/* GDxUX v4 preview — shared tokens, type scale and accessibility.
   Colour and layout live in 3da.css / 3dc.css. */

:root {
  --gutter: clamp(1.25rem, 4vw, 3.5rem);
  --max: 88rem;
  --chrome: 6.75rem; /* preview bar 44px + header 64px (desktop, one line each) */
  --dock-space: 0px;
  --step-1: 1.25rem;
  --step-2: clamp(1.5rem, 1.2rem + 1.2vw, 2rem);
  --step-3: clamp(2rem, 1.4rem + 2.4vw, 3.25rem);
  --step-4: clamp(2.5rem, 1.6rem + 3.6vw, 4.5rem);
  --step-5: clamp(3.25rem, 1.5rem + 7vw, 8rem);
}
@media (max-width: 760px) {
  :root { --dock-space: calc(4.5rem + env(safe-area-inset-bottom)); }
}

*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 1rem;
  scroll-padding-bottom: var(--dock-space);
}
html, body { overflow-x: clip; }
html.menu-open { overflow: hidden; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--fg);
  padding-bottom: var(--dock-space);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, figure, blockquote, dl, dd, ul, ol { margin: 0; }
ul, ol { padding: 0; }
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-underline-offset: 0.18em; }
button { font: inherit; color: inherit; }
[lang="ko"] { word-break: keep-all; }

.wrap { max-width: var(--max); margin-inline: auto; padding-inline: var(--gutter); }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.nowrap { white-space: nowrap; }

/* Focus */
:focus-visible { outline: 3px solid var(--ring); outline-offset: 3px; }
:focus:not(:focus-visible) { outline: none; }

.skip {
  position: absolute; left: 1rem; top: -10rem; z-index: 100;
  padding: 0.75rem 1rem; min-height: 44px;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; text-decoration: none;
}
.skip:focus { top: 1rem; }

/* Preview bar (13px is the one allowed exception to the 16px body) */
.preview-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 0 0.75rem; min-height: 44px; padding: 0 var(--gutter);
  font-size: 13px; line-height: 1.4; text-align: center;
  background: var(--bar-bg); color: var(--bar-fg);
}
.preview-bar p { padding-block: 0.375rem; }
.preview-bar a { display: inline-flex; align-items: center; min-height: 44px; padding-inline: 0.25rem; font-weight: 600; }

/* Header */
.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  min-height: 4rem; padding: 0.5rem var(--gutter);
}
.mark {
  display: inline-flex; align-items: center; min-height: 44px;
  font-family: var(--font-display); font-weight: 700; font-size: 1.375rem;
  letter-spacing: -0.01em; text-decoration: none;
}
.header-actions { display: flex; align-items: center; gap: 0.75rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 44px; min-width: 44px; padding: 0.625rem 1.25rem;
  font: 600 1rem/1.2 var(--font-body); text-decoration: none;
  border: 2px solid transparent; border-radius: var(--btn-radius, 0); cursor: pointer;
  background: transparent;
}
.btn-cta { background: var(--accent); color: var(--accent-ink); }
.btn-ghost { color: var(--fg); border-color: currentColor; }
@media (max-width: 760px) { .header-cta { display: none; } }

/* Fullscreen typographic menu (all widths) */
.menu {
  position: fixed; inset: 0; z-index: 50; overflow-y: auto;
  display: flex; flex-direction: column;
  padding: 0.5rem var(--gutter) calc(2rem + env(safe-area-inset-bottom));
  background: var(--menu-bg); color: var(--menu-fg);
}
.menu[hidden] { display: none; }
.menu-top { display: flex; align-items: center; justify-content: space-between; min-height: 4rem; }
.menu-list { list-style: none; margin-block: auto; padding-block: 2rem; }
.menu-list a {
  display: block; min-width: 44px; min-height: 44px; padding-block: 0.1em; text-decoration: none;
  font-family: var(--font-display); font-size: clamp(2.75rem, 1.5rem + 6vw, 7rem);
  line-height: 1.05; letter-spacing: -0.02em;
}
.menu-list a[aria-current="page"] { color: var(--menu-accent, var(--accent-text)); }
@media (hover: hover) and (pointer: fine) { .menu-list a:hover { color: var(--menu-accent, var(--accent-text)); } }
.menu .btn-ghost { color: var(--menu-fg); }
.menu { --ring: var(--menu-fg); }
.preview-bar { --ring: var(--bar-fg); }
.menu-foot a { display: inline-flex; align-items: center; min-height: 44px; }

/* Sticky mobile dock */
.dock { display: none; }
@media (max-width: 760px) {
  .dock {
    display: flex; position: fixed; z-index: 20;
    left: 0.75rem; right: 0.75rem; bottom: calc(0.75rem + env(safe-area-inset-bottom));
    min-height: 52px; box-shadow: 0 8px 24px rgb(0 0 0 / 0.25);
    transition: transform 0.3s ease, opacity 0.3s ease;
  }
  .dock.is-hidden { transform: translateY(150%); opacity: 0; pointer-events: none; }
}
/* Room for the dock after text blocks it must not cover (0 on desktop) */
.section[data-dock-clear]::after { content: ""; display: block; height: var(--dock-space); }

/* Works list (shared hooks; look in direction CSS) */
.works { list-style: none; }
.work-title a { display: inline-flex; align-items: center; min-width: 44px; min-height: 44px; text-decoration: none; }
@media (hover: hover) and (pointer: fine) { .work-title a:hover { text-decoration: underline; } }
.footer-nav a { display: inline-flex; align-items: center; min-width: 44px; min-height: 44px; }

/* Preview form */
.form { display: grid; gap: 1rem; max-width: 36rem; }
.field { display: grid; gap: 0.375rem; }
.field label { font-weight: 600; }
.field input, .field textarea {
  width: 100%; min-height: 48px; padding: 0.75rem 0.875rem;
  font: inherit; font-size: 16px; color: var(--fg);
  background: var(--field-bg); border: 2px solid var(--field-border); border-radius: var(--field-radius, 0);
}
.field textarea { min-height: 8rem; resize: vertical; }
.form .btn { justify-self: start; }
.form-status { min-height: 1.6em; font-weight: 600; }

/* Lightbox (native <dialog>: modal, Esc, focus kept inside) */
.lightbox {
  width: min(64rem, calc(100vw - 2rem)); max-width: none; max-height: calc(100dvh - 2rem);
  padding: 0; border: 0; background: var(--lb-bg); color: var(--lb-fg); border-radius: var(--lb-radius, 0);
}
.lightbox::backdrop { background: rgb(10 8 6 / 0.82); }
.lightbox-inner { display: grid; gap: 1rem; padding: 1rem; }
.lightbox-close { justify-self: end; }
.lightbox img { width: 100%; max-height: 68dvh; object-fit: contain; background: var(--lb-img-bg, #0d0a08); }
.lightbox h2 { font-family: var(--font-display); font-size: var(--step-2); line-height: 1.15; }
.lightbox h2 a { text-underline-offset: 0.15em; }

/* WebGL canvas sits over the static image and fades in only once a frame is ready */
.stage-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; opacity: 0; transition: opacity 0.6s ease; }
.is-live > .stage-canvas { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  *:not(.xfade), *:not(.xfade)::before, *:not(.xfade)::after {
    animation-duration: 0.01ms !important; animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important; scroll-behavior: auto !important;
  }
}
