/* ==========================================================================
   InihaoStudio — base.css
   Element defaults and layout primitives only. No component styles here.
   Depends on tokens.css.
   Fonts are loaded from Google Fonts via <link> in each page head with
   &display=swap and preconnect; this file only declares the stacks.
   ========================================================================== */

/* ---- Reset ---------------------------------------------------------- */

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

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Section 3 / 11: no horizontal scroll at any width. */
  overflow-x: clip;
  scrollbar-gutter: stable;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100svh;
  overflow-x: clip;
  background-color: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 400;
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---- Media ---------------------------------------------------------- */

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

img,
video {
  height: auto;
}

svg {
  flex-shrink: 0;
}

/* ---- Type ----------------------------------------------------------- */

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-display);
  font-weight: 600;
  /* Hard rule: no italic display headers, ever. */
  font-style: normal;
  line-height: var(--leading-tight);
  letter-spacing: -0.015em;
  text-wrap: balance;
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }
h5 { font-size: var(--text-base); }
h6 { font-size: var(--text-sm); }

p,
li {
  text-wrap: pretty;
}

p {
  max-width: var(--measure);
}

small {
  font-size: var(--text-sm);
  color: var(--ink-2);
}

strong,
b {
  font-weight: 600;
}

em,
i {
  font-style: italic;
}

/* Accent emphasis that avoids italic display text (Section 3). */
mark {
  background-color: var(--marigold);
  color: var(--ink);
  padding-inline: 0.15em;
  border-radius: var(--radius-sm);
}

abbr[title] {
  text-decoration: underline dotted;
  cursor: help;
}

code,
kbd,
samp,
pre {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.9em;
}

/* Mono is reserved for file sizes, page numbers and format labels. */
.u-mono {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: var(--text-sm);
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
}

u {
  text-decoration: none;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 0.08em;
}

/* ---- Links ---------------------------------------------------------- */

a {
  /* --teal is the only token that clears 4.5:1 for link text on paper. */
  color: var(--teal);
  text-decoration: underline;
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
  transition: color var(--dur-fast) var(--ease-out),
              text-decoration-color var(--dur-fast) var(--ease-out);
}

a:hover {
  color: var(--ink);
  text-decoration-color: var(--accent);
}

a:active {
  color: var(--ink-2);
}

/* ---- Lists ---------------------------------------------------------- */

ul[role="list"],
ol[role="list"] {
  list-style: none;
  padding: 0;
}

ul,
ol {
  padding-left: var(--space-5);
}

li + li {
  margin-top: var(--space-2);
}

li::marker {
  color: var(--ink-3);
}

/* ---- Rules ---------------------------------------------------------- */

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin-block: var(--space-6);
}

/* ---- Forms ---------------------------------------------------------- */

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

button,
[role="button"],
summary,
label[for],
select {
  cursor: pointer;
}

button {
  background: none;
  border: 0;
  padding: 0;
  text-align: inherit;
}

textarea {
  resize: vertical;
}

::placeholder {
  color: var(--ink-3);
  opacity: 1;
}

/* Touch targets: 44x44 minimum (Section 11). */
button,
[role="button"],
summary,
input[type="checkbox"],
input[type="radio"] {
  min-height: 44px;
}

input,
select,
textarea {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background-color: var(--paper);
  padding: var(--space-2) var(--space-3);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--ink-2);
  outline: none;
}

fieldset {
  border: 0;
  padding: 0;
}

legend {
  padding: 0;
  font-weight: 600;
}

/* ---- Focus ---------------------------------------------------------- */

/* Visible ring at >= 3:1. Never animated — it must appear instantly. */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
  transition: none;
}

/* Kill the ring only where the browser would draw its own, never globally. */
:focus:not(:focus-visible) {
  outline: none;
}

/* ---- Selection ------------------------------------------------------ */

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

/* ---- Layout primitives ---------------------------------------------- */

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

@media (min-width: 768px) {
  :root {
    --gutter: 2rem;
  }
}

@media (min-width: 1200px) {
  :root {
    --gutter: 2.5rem;
  }
}

/* ---- Accessibility utilities ---------------------------------------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  z-index: var(--z-toast);
  padding: var(--space-2) var(--space-4);
  background-color: var(--ink);
  color: var(--paper);
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-200%);
  transition: transform var(--dur-fast) var(--ease-out);
}

.skip-link:focus-visible {
  transform: translateY(0);
}

[hidden] {
  display: none !important;
}

/* ---- Reduced motion ------------------------------------------------- */

/* Section 3 / 7: spatial motion collapses to a short opacity change. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 150ms !important;
    transition-property: opacity !important;
    scroll-behavior: auto !important;
  }

  html {
    scroll-behavior: auto;
  }
}
