/* ============================================================================
   Alpha Branding Studio — Base Styles
   assets/css/base.css
   ----------------------------------------------------------------------------
   Element-level foundations only: reset, defaults, and bare HTML elements.
   Depends on tokens.css (enqueue tokens.css FIRST).

   Contract:
   - Uses ONLY variables from tokens.css. No literal design values.
   - No components, no utilities, no layout classes.
   - Logical properties throughout for future i18n / writing-mode safety.
   - Styles bare elements so unclassed WordPress/Gutenberg content is on-brand.
   ============================================================================ */

/* ==========================================================================
   1. MODERN CSS RESET
   ========================================================================== */

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

* {
  margin: 0;
  padding: 0;
}

/* Remove default list styling only where the author opts in via role.
   Bare lists keep semantics + markers (see §5). */

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

/* Prevent orphaned text nodes from breaking flex/grid children */
:where(p, h1, h2, h3, h4, h5, h6) {
  overflow-wrap: break-word;
}


/* ==========================================================================
   2. HTML & BODY DEFAULTS
   ========================================================================== */

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -moz-tab-size: 4;
  tab-size: 4;
  scroll-behavior: smooth;
  /* Offset in-page anchors for the sticky header */
  scroll-padding-block-start: var(--header-height);
  hanging-punctuation: first last;
}

body {
  min-block-size: 100vh;
  min-block-size: 100svh;
  background-color: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  font-weight: var(--fw-regular);
  line-height: var(--lh-body);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-synthesis: none;
}


/* ==========================================================================
   3. TYPOGRAPHY
   ========================================================================== */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
  text-wrap: balance;
}

h1 {
  font-size: var(--fs-h1);
  line-height: var(--lh-display);
}

h2 {
  font-size: var(--fs-h2);
}

h3 {
  font-size: var(--fs-h3);
  font-weight: var(--fw-medium);
  line-height: var(--lh-snug);
  letter-spacing: var(--tracking-snug);
}

h4 {
  font-size: var(--fs-h4);
  font-weight: var(--fw-medium);
  line-height: var(--lh-heading);
  letter-spacing: var(--tracking-snug);
}

h5 {
  font-size: var(--fs-body-lg);
  font-weight: var(--fw-medium);
  line-height: var(--lh-heading);
}

h6 {
  font-size: var(--fs-body);
  font-weight: var(--fw-medium);
  line-height: var(--lh-heading);
}

/* Vertical rhythm for flowing prose. Reset the top margin of the first child
   and only add space between siblings (owl selector avoids edge margins). */
:where(h1, h2, h3, h4, h5, h6, p, ul, ol, blockquote, pre, table, figure)
  + :where(h1, h2, h3, h4, h5, h6, p, ul, ol, blockquote, pre, table, figure) {
  margin-block-start: var(--space-4);
}

p {
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  max-inline-size: var(--measure);
  text-wrap: pretty;
}

/* Lead paragraph immediately following a top-level heading reads larger */
:where(h1, h2) + p {
  font-size: var(--fs-body-lg);
  max-inline-size: var(--measure-narrow);
}

small {
  font-size: var(--fs-caption);
  line-height: var(--lh-snug);
  color: var(--text-muted);
}

strong,
b {
  font-weight: var(--fw-medium);
  color: var(--text-primary);
}

em,
i {
  font-style: italic;
}

mark {
  background-color: var(--accent-wash);
  color: var(--text-accent);
  padding-inline: 0.15em;
  border-radius: var(--radius-sm);
}

sub,
sup {
  font-size: 0.75em;
  line-height: 0;
  position: relative;
  vertical-align: baseline;
}

sup { inset-block-start: -0.5em; }
sub { inset-block-end: -0.25em; }

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


/* ==========================================================================
   4. LINKS
   ========================================================================== */

a {
  color: var(--text-accent);
  text-decoration-line: underline;
  text-decoration-thickness: from-font;
  text-underline-offset: 0.15em;
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
  transition: color var(--dur-fast) var(--ease-standard),
              text-decoration-color var(--dur-fast) var(--ease-standard);
}

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

a:active {
  color: var(--accent-strong);
}

/* Links that wrap non-text content shouldn't force an underline */
a:has(> img, > svg, > picture) {
  text-decoration: none;
}


/* ==========================================================================
   5. LISTS
   ========================================================================== */

ul,
ol {
  padding-inline-start: var(--space-5);
  max-inline-size: var(--measure);
}

li {
  margin-block-start: var(--space-2);
  line-height: var(--lh-body);
}

li::marker {
  color: var(--text-muted);
}

/* Nested lists tighten up */
li > :where(ul, ol) {
  margin-block-start: var(--space-2);
}

dl {
  max-inline-size: var(--measure);
}

dt {
  font-weight: var(--fw-medium);
  color: var(--text-primary);
}

dd {
  margin-block-end: var(--space-3);
  margin-inline-start: 0;
  color: var(--text-secondary);
}


/* ==========================================================================
   6. IMAGES & MEDIA
   ========================================================================== */

img,
picture,
video,
canvas {
  display: block;
  max-inline-size: 100%;
  block-size: auto;
}

img {
  font-style: italic;           /* styles the alt text if the image fails */
  color: var(--text-muted);
  background-repeat: no-repeat;
  background-size: cover;
  vertical-align: middle;
  border-radius: 0;             /* radius is a component concern, not base */
}

figure {
  margin-block: var(--space-5);
}

figcaption {
  margin-block-start: var(--space-3);
  font-size: var(--fs-caption);
  line-height: var(--lh-snug);
  color: var(--text-muted);
}


/* ==========================================================================
   7. SVG
   ========================================================================== */

svg {
  display: inline-block;
  vertical-align: middle;
  fill: currentColor;
  flex-shrink: 0;
}

/* Icon-role SVGs inherit sizing from the current font unless sized explicitly */
svg:not([width]):not([height]) {
  inline-size: 1em;
  block-size: 1em;
}

/* Line-icon defaults (Lucide) — respect the single stroke width token */
svg[stroke] {
  stroke-width: var(--icon-stroke);
}


/* ==========================================================================
   8. BUTTONS — browser reset only (no visual component styling)
   ========================================================================== */

button {
  appearance: none;
  background: none;
  border: 0;
  color: inherit;
  font-family: inherit;
  line-height: var(--lh-snug);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:disabled {
  cursor: not-allowed;
}


/* ==========================================================================
   9. INPUTS & FORM ELEMENT DEFAULTS
   ========================================================================== */

input,
textarea,
select {
  font-family: inherit;
  font-size: max(var(--fs-body), 16px); /* 16px min prevents iOS zoom */
  color: var(--text-primary);
  background-color: var(--bg-surface);
  border: var(--border-hairline) solid var(--border-default);
  border-radius: var(--radius-md);
  line-height: var(--lh-snug);
}

textarea {
  resize: vertical;
  min-block-size: 140px;
}

select {
  appearance: none;
  cursor: pointer;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
  opacity: 1; /* Firefox lowers placeholder opacity by default */
}

/* Reduce native spin/clear chrome that fights the minimal aesthetic */
input[type="number"] {
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

/* Accent for native checkbox/radio/range/progress */
input[type="checkbox"],
input[type="radio"],
input[type="range"],
progress {
  accent-color: var(--accent);
}

input:disabled,
textarea:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

label {
  display: inline-block;
  font-size: var(--fs-caption);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
}

fieldset {
  border: var(--border-hairline) solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-5);
}

legend {
  padding-inline: var(--space-2);
  font-weight: var(--fw-medium);
  color: var(--text-primary);
}


/* ==========================================================================
   10. TABLES
   ========================================================================== */

table {
  inline-size: 100%;
  border-collapse: collapse;
  font-size: var(--fs-body-sm);
  text-align: start;
}

caption {
  margin-block-end: var(--space-3);
  font-size: var(--fs-caption);
  color: var(--text-muted);
  text-align: start;
}

th,
td {
  padding-block: var(--space-3);
  padding-inline: var(--space-4);
  text-align: start;
  vertical-align: top;
  border-block-end: var(--border-hairline) solid var(--border-default);
}

thead th {
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
  border-block-end-color: var(--border-strong);
}


/* ==========================================================================
   11. BLOCKQUOTES
   ========================================================================== */

blockquote {
  margin-block: var(--space-5);
  padding-inline-start: var(--space-5);
  border-inline-start: var(--border-thick) solid var(--accent);
  border-radius: 0; /* single-sided borders stay square */
  font-family: var(--font-voice, var(--font-body));
  font-size: var(--fs-body-lg);
  line-height: var(--lh-body);
  color: var(--text-secondary);
  max-inline-size: var(--measure);
}

blockquote cite {
  display: block;
  margin-block-start: var(--space-3);
  font-family: var(--font-body);
  font-size: var(--fs-caption);
  font-style: normal;
  color: var(--text-muted);
}


/* ==========================================================================
   12. CODE & PRE
   ========================================================================== */

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

code {
  padding-block: 0.1em;
  padding-inline: 0.35em;
  background-color: var(--accent-wash);
  color: var(--text-accent);
  border-radius: var(--radius-sm);
  overflow-wrap: break-word;
}

pre {
  margin-block: var(--space-5);
  padding: var(--space-5);
  background-color: var(--bg-inverse);
  color: var(--text-on-dark);
  border-radius: var(--radius-lg);
  font-size: var(--fs-body-sm);
  line-height: var(--lh-body);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  tab-size: 2;
}

/* Code inside pre resets its inline chrome */
pre code {
  padding: 0;
  background: none;
  color: inherit;
  border-radius: 0;
  font-size: inherit;
}

kbd {
  padding-block: 0.1em;
  padding-inline: 0.4em;
  background-color: var(--bg-surface);
  border: var(--border-hairline) solid var(--border-default);
  border-radius: var(--radius-sm);
  font-size: 0.85em;
  color: var(--text-primary);
}


/* ==========================================================================
   13. HORIZONTAL RULES
   ========================================================================== */

hr {
  border: 0;
  block-size: var(--border-hairline);
  background-color: var(--border-default);
  margin-block: var(--space-7);
}


/* ==========================================================================
   14. SELECTION
   ========================================================================== */

::selection {
  background-color: var(--color-ink);
  color: var(--color-paper);
  text-shadow: none;
}


/* ==========================================================================
   15. FOCUS-VISIBLE
   Keyboard focus is always visible; pointer focus stays quiet.
   ========================================================================== */

:focus-visible {
  outline: var(--border-thick) solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Elements that carry their own ring-based focus (form fields) drop the
   outline in favor of the token shadow for a softer, on-brand treatment. */
:where(input, textarea, select):focus-visible {
  outline: none;
  border-color: var(--text-primary);
  box-shadow: var(--shadow-focus);
}

/* Remove the legacy outline for mouse users that support :focus-visible */
:focus:not(:focus-visible) {
  outline: none;
}


/* ==========================================================================
   16. ACCESSIBILITY HELPERS
   ========================================================================== */

/* Skip link — visually hidden until focused, then anchored top-start */
.skip-link {
  position: absolute;
  inset-block-start: var(--space-2);
  inset-inline-start: var(--space-2);
  z-index: var(--z-spinner);
  padding-block: var(--space-2);
  padding-inline: var(--space-4);
  background-color: var(--bg-inverse);
  color: var(--text-on-dark);
  border-radius: var(--radius-md);
  text-decoration: none;
  transform: translateY(-150%);
  transition: transform var(--dur-base) var(--ease-out);
}

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

/* Honor the OS "increase contrast" setting for hairlines */
@media (prefers-contrast: more) {
  :root {
    --border-default: var(--color-graphite);
  }
}

/* Target highlight when navigating to an in-page anchor */
:target {
  scroll-margin-block-start: var(--header-height);
}


/* ==========================================================================
   17. SCREEN-READER UTILITY
   Visually hidden but available to assistive tech. `.sr-only-focusable`
   reveals itself on focus (e.g. inline skip targets).
   ========================================================================== */

.sr-only,
.screen-reader-text {
  position: absolute !important;
  inline-size: 1px;
  block-size: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.sr-only-focusable:focus,
.sr-only-focusable:focus-within {
  position: static !important;
  inline-size: auto;
  block-size: auto;
  margin: 0;
  overflow: visible;
  clip: auto;
  clip-path: none;
  white-space: normal;
}


/* ==========================================================================
   18. REDUCED MOTION
   ========================================================================== */

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

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}


/* ==========================================================================
   19. PRINT
   ========================================================================== */

@media print {
  *,
  *::before,
  *::after {
    background: transparent !important;
    color: #000 !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }

  html {
    font-size: 12pt;
  }

  body {
    background: #fff;
    color: #000;
  }

  a {
    color: #000;
    text-decoration: underline;
  }

  /* Expose destination URLs for external links */
  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.85em;
    word-break: break-all;
  }

  /* Don't print URLs for in-page or JS anchors */
  a[href^="#"]::after,
  a[href^="javascript:"]::after {
    content: "";
  }

  img,
  svg,
  table,
  pre,
  blockquote,
  figure {
    break-inside: avoid;
  }

  h1, h2, h3, h4, h5, h6 {
    break-after: avoid;
  }

  p, h2, h3, h4 {
    orphans: 3;
    widows: 3;
  }

  thead {
    display: table-header-group;
  }

  /* Hide non-content chrome from print output */
  .skip-link,
  nav,
  footer {
    display: none !important;
  }
}