/* ============================================================================
   HARUKASU — base layer: reset, typography, layout primitives, motion
   ========================================================================= */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Deliberate overflow (bleeds, overhanging rules) is clipped, never scrolled.
  `clip` rather than `hidden` so position: sticky keeps working. */
  overflow-x: clip;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  margin: 0;
  overflow-x: clip;
  background: var(--color-paper);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.9;
  letter-spacing: 0.015em;
  font-feature-settings: "palt" 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-break: strict;
  word-break: normal;
  overflow-wrap: anywhere;
}

h1,
h2,
h3,
h4,
p,
figure,
blockquote,
dl,
dd {
  margin: 0;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

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

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: 0;
  cursor: pointer;
}

table {
  border-collapse: collapse;
  width: 100%;
}

:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 3px;
  border-radius: 1px;
}

::selection {
  background: var(--color-accent-soft);
  color: var(--color-ink);
}

/* --- Typography ---------------------------------------------------------- */

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.005em;
  line-height: 1.32;
  /* CJK: break at phrase boundaries rather than mid-word where supported. */
  word-break: auto-phrase;
  line-break: strict;
  text-wrap: balance;
}

h1 {
  font-size: var(--text-display);
  line-height: 1.18;
}

h2 {
  font-size: var(--text-display-s);
  line-height: 1.28;
}

h3 {
  font-size: var(--text-lg);
  line-height: 1.5;
}

h4 {
  font-size: var(--text-md);
  font-weight: 700;
  line-height: 1.6;
}

p {
  text-wrap: pretty;
}

strong {
  font-weight: 700;
}

.mono {
  font-family: var(--font-mono);
  font-weight: 400;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
}

.label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-ink-3);
  font-variant-numeric: tabular-nums;
}

.label--accent {
  color: var(--color-accent);
}

.lede {
  font-size: var(--text-md);
  line-height: 1.95;
  color: var(--color-ink-2);
  max-width: var(--measure-jp);
}

.prose {
  max-width: var(--measure);
}

.prose > * + * {
  margin-top: 1.1em;
}

.prose h2 {
  margin-top: var(--space-xl);
  font-size: var(--text-xl);
}

.prose h3 {
  margin-top: var(--space-lg);
}

.prose ul {
  padding-left: 0;
}

.prose ul > li {
  position: relative;
  padding-left: 1.4em;
  margin-top: 0.4em;
}

.prose ul > li::before {
  content: "";
  position: absolute;
  left: 0.15em;
  top: 0.85em;
  width: 0.5em;
  height: 1px;
  background: var(--color-accent);
}

.fineprint {
  font-size: var(--text-sm);
  line-height: 1.8;
  color: var(--color-ink-3);
}

/* --- Frame & sections ---------------------------------------------------- */

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

.section {
  padding-block: var(--space-2xl);
}

.section--loose {
  padding-block: var(--space-3xl);
}

.section--surface {
  background: var(--color-surface);
}

/* negative-space divider: the section break is the rhythm, never a sub-rule */

.break {
  height: 1px;
  background: var(--color-rule);
  border: 0;
  margin: 0;
}

/* --- Split (Split Studio diptych) ---------------------------------------- */

.split {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: var(--space-xl) var(--space-2xl);
  align-items: start;
}

.split--reverse > :first-child {
  grid-column: 2;
}

.split--reverse > :last-child {
  grid-column: 1;
  grid-row: 1;
}

.split__head {
  position: relative;
}

.split__head .label {
  display: block;
  margin-bottom: var(--space-sm);
}

.head-note {
  margin-top: var(--space-md);
  max-width: 30em;
  color: var(--color-ink-2);
}

/* --- Section head (S1 left margin numbered) ------------------------------ */

.sec-head {
  max-width: 46rem;
  padding-bottom: var(--space-lg);
}

.sec-head .label {
  display: block;
  margin-bottom: var(--space-xs);
}

.sec-head .head-note {
  margin-top: var(--space-md);
}

/* --- Inline breaks ------------------------------------------------------- */

.nobr {
  display: inline-block;
}

/* --- Grids --------------------------------------------------------------- */

.grid {
  display: grid;
  gap: var(--space-lg);
}

.grid--2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid--3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* --- Motion (one composed entrance, never scroll-jacked) ------------------ */

@media (prefers-reduced-motion: no-preference) {
  .rise {
    animation: rise var(--dur-slow) var(--ease-out) both;
    animation-delay: var(--rise-delay, 0ms);
  }

  .reveal {
    opacity: 0;
    transform: translateY(10px);
    transition:
    opacity var(--dur-slow) var(--ease-out),
    transform var(--dur-slow) var(--ease-out);
    transition-delay: var(--reveal-delay, 0ms);
  }

  .reveal.is-in {
    opacity: 1;
    transform: none;
  }

  @keyframes rise {
    from {
      opacity: 0;
      transform: translateY(14px);
    }

    to {
      opacity: 1;
      transform: none;
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  .rise,
  .reveal {
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
    transition: none !important;
  }
}

.skip-link {
  position: absolute;
  left: var(--space-sm);
  top: -3rem;
  z-index: var(--z-toast);
  background: var(--color-ink);
  color: var(--color-paper);
  padding: 0.6rem 1rem;
  font-size: var(--text-sm);
  transition: top var(--dur-fast) var(--ease-out);
}

.skip-link:focus {
  top: var(--space-sm);
}

.stack > * + * {
  margin-top: var(--space-md);
}

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

@media (max-width: 60rem) {
  .split {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-lg);
  }

  .split--reverse > :first-child,
  .split--reverse > :last-child {
    grid-column: 1;
    grid-row: auto;
  }

  .grid--3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 40rem) {
  body {
    line-height: 1.85;
  }

  .grid--2,
  .grid--3 {
    grid-template-columns: minmax(0, 1fr);
  }

  .section {
    padding-block: var(--space-xl);
  }

  .section--loose {
    padding-block: var(--space-2xl);
  }
}
