/**
 * w3domicile V3 — reset, typography, layout primitives
 *
 * Depends on: tokens.css (loaded first via functions.php)
 */

/* -------------------------------------------------------------------------
   Reset
   ------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  hanging-punctuation: first last;
}

body {
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  line-height: var(--leading-normal);
  color: var(--color-text-primary);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

main {
  display: block;
}

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

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

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

ul,
ol {
  list-style: none;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

hr {
  border: 0;
  border-top: 1px solid var(--color-border);
  margin: var(--space-5) 0;
}

/* -------------------------------------------------------------------------
   Links
   ------------------------------------------------------------------------- */
a {
  color: var(--color-secondary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

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

/* -------------------------------------------------------------------------
   Typography — fluid scale (tokens define clamp() values)
   ------------------------------------------------------------------------- */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: var(--leading-tight);
  color: var(--color-text-primary);
  letter-spacing: -0.025em;
  text-wrap: balance;
}

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

p {
  margin-bottom: var(--space-4);
}

p:last-child {
  margin-bottom: 0;
}

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

strong,
b {
  font-weight: var(--weight-semibold);
}

em,
i {
  font-style: italic;
}

code,
kbd,
samp {
  font-family: ui-monospace, 'Cascadia Code', 'Segoe UI Mono', monospace;
  font-size: 0.9em;
}

pre {
  overflow-x: auto;
  font-family: ui-monospace, 'Cascadia Code', 'Segoe UI Mono', monospace;
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-4);
}

pre code {
  font-size: inherit;
  background: none;
  border: 0;
  padding: 0;
}

/* -------------------------------------------------------------------------
   Prose — blog posts, pages, product descriptions
   ------------------------------------------------------------------------- */
.post-content {
  line-height: var(--leading-relaxed);
  color: var(--color-text-primary);
}

.post-content > * + * {
  margin-top: var(--space-4);
}

.post-content h2,
.post-content h3,
.post-content h4 {
  margin-top: var(--space-6);
  margin-bottom: var(--space-3);
}

.post-content h2:first-child,
.post-content h3:first-child,
.post-content h4:first-child {
  margin-top: 0;
}

.post-content ul,
.post-content ol {
  padding-left: var(--space-5);
  margin-bottom: var(--space-4);
  list-style: disc;
}

.post-content ol {
  list-style: decimal;
}

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

.post-content a {
  color: var(--color-secondary);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.post-content a:hover {
  color: var(--color-accent);
}

.post-content blockquote {
  border-left: 4px solid var(--color-accent);
  padding: var(--space-4) var(--space-5);
  background: var(--color-surface-raised);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: var(--space-5) 0;
  font-style: normal;
  font-size: var(--text-lg);
  font-weight: 500;
  color: var(--color-text-primary);
}

.post-content img,
.post-content figure {
  border-radius: var(--radius-md);
  margin: var(--space-4) 0;
}

.post-content figcaption {
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-align: center;
}

.post-content code {
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.1em 0.35em;
  font-size: 0.9em;
}

.post-title {
  font-size: var(--text-3xl);
  margin-bottom: var(--space-3);
}

.post-meta {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-5);
}

/* -------------------------------------------------------------------------
   Layout primitives
   ------------------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: clamp(var(--space-4), 4vw, var(--space-5));
}

.container--narrow {
  max-width: var(--container-narrow);
}

.section {
  padding-block: clamp(var(--space-7), 6vw, var(--space-8));
}

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

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

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.section-header h2 {
  font-size: var(--text-xl);
  margin: 0;
}

.content-layout {
  display: grid;
  grid-template-columns: 1fr 270px;
  gap: var(--space-6);
  align-items: start;
}

/* -------------------------------------------------------------------------
   Accessibility
   ------------------------------------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

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

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

.screen-reader-text {
  border: 0;
  clip: rect(1px, 1px, 1px, 1px);
  clip-path: inset(50%);
  height: 1px;
  width: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  word-wrap: normal !important;
}

.screen-reader-text:focus {
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  clip: auto !important;
  clip-path: none;
  color: var(--color-secondary);
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  height: auto;
  inset-inline-start: var(--space-2);
  inset-block-start: var(--space-2);
  line-height: var(--leading-normal);
  padding: var(--space-4) var(--space-5);
  text-decoration: none;
  width: auto;
  z-index: 100000;
}

/* -------------------------------------------------------------------------
   Responsive layout
   ------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .content-layout {
    grid-template-columns: 1fr;
  }
}
