@charset "UTF-8";
/**
 * Erewhon Base Styles
 * Foundation layer: HTML element defaults + resets
 * 
 * Philosophy:
 * - Semantic token usage throughout
 * - Accessible by default
 * - Consistent rhythm and spacing
 * - Beautiful typography baseline
 * 
 * @package Erewhon
 * @version 2.0
 */

/* ============================================
   BOX MODEL RESET
   Modern CSS reset approach
   ============================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ============================================
   ROOT & HTML
   Foundation settings
   ============================================ */
html {
  font-size: 100%; /* 16px base */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  hanging-punctuation: first last;
}

@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;
  }
}

/* ============================================
   BODY
   Base typography and background
   ============================================ */
body {
  min-height: 100vh;
  min-height: 100dvh; /* Dynamic viewport height */
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--fw-normal);
  line-height: var(--lh-body);
  letter-spacing: var(--ls-normal);
  color: var(--text-primary);
  background: var(--bg-canvas);
  overflow-x: hidden;
  text-wrap: var(--text-wrap-pretty);
}

/* ============================================
   TEXT SELECTION
   Brand-aligned selection styling
   ============================================ */
::selection {
  background: var(--primary-alpha-20);
  color: var(--text-primary);
}

::-moz-selection {
  background: var(--primary-alpha-20);
  color: var(--text-primary);
}

/* ============================================
   FOCUS VISIBLE
   Consistent, accessible focus states
   ============================================ */
:focus-visible {
  outline: var(--focus-width) var(--focus-style) var(--focus-color);
  outline-offset: var(--focus-offset);
  border-radius: var(--radius-xs);
}

:focus:not(:focus-visible) {
  outline: none;
}

/* ============================================
   HEADINGS
   Hierarchical typography with semantic spacing
   ============================================ */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: var(--heading-font-weight);
  line-height: var(--heading-line-height);
  letter-spacing: var(--heading-letter-spacing);
  color: var(--text-primary);
  text-wrap: var(--text-wrap-balance);
  margin: 0;
}

h1 { 
  font-size: var(--h1);
  line-height: var(--lh-tight);
  margin-bottom: var(--gap-heading-body);
}

h2 { 
  font-size: var(--h2);
  margin-bottom: var(--gap-heading-body);
}

h3 { 
  font-size: var(--h3);
  margin-bottom: var(--gap-heading-body);
}

h4 { 
  font-size: var(--h4);
  margin-bottom: var(--gap-heading-subheading);
}

h5 { 
  font-size: var(--h5);
  margin-bottom: var(--gap-heading-subheading);
}

h6 { 
  font-size: var(--h6);
  font-weight: var(--fw-semibold);
  margin-bottom: var(--gap-heading-subheading);
}

/* Heading spacing context */
h1 + *, h2 + *, h3 + * {
  margin-top: 0;
}

/* ============================================
   PARAGRAPHS & TEXT
   Comfortable reading experience
   ============================================ */
p {
  margin: 0 0 var(--gap-paragraph-paragraph) 0;
  max-width: var(--content-width-prose);
  text-wrap: var(--text-wrap-pretty);
}

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

/* Text emphasis */
strong, b {
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
}

em, i {
  font-style: italic;
}

mark {
  background: var(--warning-ultra-light);
  color: var(--text-primary);
  padding: 0.125em 0.25em;
  border-radius: var(--radius-xs);
}

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

/* Subscript and superscript */
sub, sup {
  font-size: var(--text-xs);
  line-height: 0;
  position: relative;
  vertical-align: baseline;
}

sup { top: -0.5em; }
sub { bottom: -0.25em; }

/* Abbreviations */
abbr[title] {
  text-decoration: underline dotted;
  cursor: help;
  text-decoration-color: var(--text-tertiary);
}

/* Code and preformatted text */
code, kbd, samp {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--bg-sunken);
  padding: 0.125em 0.375em;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-light);
}

pre {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: var(--lh-relaxed);
  background: var(--bg-sunken);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  overflow-x: auto;
  margin: 0 0 var(--content-gap) 0;
}

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

/* Keyboard input */
kbd {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-bottom-width: 2px;
  box-shadow: var(--shadow-xs);
  font-size: var(--text-xs);
  padding: 0.125em 0.5em;
}

/* Blockquotes */
blockquote {
  margin: 0 0 var(--content-gap) 0;
  padding-left: var(--space-lg);
  border-left: 3px solid var(--primary);
  color: var(--text-secondary);
  font-style: italic;
}

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

blockquote cite {
  display: block;
  font-style: normal;
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  margin-top: var(--space-xs);
}

blockquote cite::before {
  content: "— ";
}

/* ============================================
   LINKS
   Accessible, consistent interactions
   ============================================ */
a {
  color: var(--color-link);
  text-decoration: none;
  text-underline-offset: 0.2em;
  transition: var(--transition-color);
}

a:hover {
  color: var(--color-link-hover);
  text-decoration: underline;
}

a:active {
  color: var(--color-link-active);
}

a:focus-visible {
  outline: var(--focus-width) var(--focus-style) var(--focus-color);
  outline-offset: var(--focus-offset);
  border-radius: var(--radius-xs);
}

/* External links indicator (optional) */
a[href^="http"]::after,
a[target="_blank"]::after {
  content: "";
  display: inline-block;
  width: 0.75em;
  height: 0.75em;
  margin-left: 0.25em;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6'%3E%3C/path%3E%3Cpolyline points='15 3 21 3 21 9'%3E%3C/polyline%3E%3Cline x1='10' y1='14' x2='21' y2='3'%3E%3C/line%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  opacity: 0.5;
  vertical-align: middle;
}

/* Remove external link icon from specific contexts */
nav a[href^="http"]::after,
footer a[href^="http"]::after,
.no-external-icon a[href^="http"]::after {
  content: none;
  display: none;
}

/* ============================================
   LISTS
   Semantic spacing and styling
   ============================================ */
ul, ol {
  margin: 0 0 var(--content-gap) 0;
  padding-left: var(--space-lg);
}

ul ul, ul ol,
ol ul, ol ol {
  margin-top: var(--space-xs);
  margin-bottom: var(--space-xs);
}

li {
  margin-bottom: var(--space-xs);
  padding-left: var(--space-2xs);
}

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

li > p {
  margin-bottom: var(--space-xs);
}

/* Definition lists */
dl {
  margin: 0 0 var(--content-gap) 0;
}

dt {
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-2xs);
}

dd {
  margin: 0 0 var(--space-sm) var(--space-lg);
  color: var(--text-secondary);
}

/* Remove list styling */
.list-none {
  list-style: none;
  padding-left: 0;
}

.list-none li {
  padding-left: 0;
}

/* ============================================
   HORIZONTAL RULE
   Section divider
   ============================================ */
hr {
  border: none;
  height: 1px;
  background: var(--border-light);
  margin: var(--section-space-sm) 0;
}

hr.hr-thick {
  height: 2px;
  background: var(--border-default);
}

hr.hr-gradient {
  background: linear-gradient(
    to right,
    transparent,
    var(--border-medium),
    transparent
  );
}

/* ============================================
   MEDIA ELEMENTS
   Responsive by default
   ============================================ */
img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

img {
  font-style: italic; /* Alt text styling if image fails */
  background-repeat: no-repeat;
  background-size: cover;
  shape-margin: 1rem;
}

/* Figure elements */
figure {
  margin: 0 0 var(--content-gap) 0;
}

figcaption {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: var(--space-sm);
  text-align: center;
  font-style: italic;
}

/* SVG */
svg {
  fill: currentColor;
  vertical-align: middle;
}

/* ============================================
   FORM ELEMENTS
   Consistent, accessible inputs
   ============================================ */
button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
  margin: 0;
}

/* Buttons */
button {
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

/* Labels */
label {
  display: inline-block;
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
  cursor: pointer;
}

label.required::after {
  content: " *";
  color: var(--error);
}

/* Text inputs */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="tel"],
input[type="url"],
input[type="date"],
input[type="datetime-local"],
input[type="month"],
input[type="week"],
input[type="time"],
select,
textarea {
  width: 100%;
  padding: var(--input-padding-block) var(--input-padding-inline);
  font-size: var(--text-base);
  line-height: var(--lh-normal);
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-input);
  transition: var(--transition-interactive);
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

/* Input states */
input:hover,
select:hover,
textarea:hover {
  background: var(--bg-input-hover);
  border-color: var(--border-input-hover);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  background: var(--bg-input-focus);
  border-color: var(--border-input-focus);
  box-shadow: var(--shadow-focus);
}

input:disabled,
select:disabled,
textarea:disabled {
  background: var(--bg-input-disabled);
  border-color: var(--border-interactive-disabled);
  cursor: not-allowed;
  opacity: 0.6;
}

/* Placeholder styling */
::placeholder {
  color: var(--text-placeholder);
  opacity: 1;
}

/* Textarea specific */
textarea {
  min-height: 8rem;
  resize: vertical;
  font-family: inherit;
}

/* Select specific */
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23444' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-sm) center;
  background-size: 12px;
  padding-right: var(--space-xl);
}

/* Checkbox and radio */
input[type="checkbox"],
input[type="radio"] {
  width: 1.125rem;
  height: 1.125rem;
  margin-right: var(--space-xs);
  cursor: pointer;
  accent-color: var(--color-action);
}

/* Search input */
input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

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

/* Fieldset */
fieldset {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  margin: 0 0 var(--content-gap) 0;
}

legend {
  font-weight: var(--fw-semibold);
  padding: 0 var(--space-sm);
  color: var(--text-primary);
}

/* Form validation states */
input:invalid:not(:placeholder-shown),
textarea:invalid:not(:placeholder-shown) {
  border-color: var(--error);
}

input:valid:not(:placeholder-shown),
textarea:valid:not(:placeholder-shown) {
  border-color: var(--success);
}

/* Helper text */
.form-helper {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  margin-top: var(--space-2xs);
}

.form-error {
  font-size: var(--text-sm);
  color: var(--error);
  margin-top: var(--space-2xs);
}

/* ============================================
   TABLES
   Professional data presentation
   ============================================ */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 var(--content-gap) 0;
  font-size: var(--text-sm);
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

/* Table header */
thead {
  background: var(--bg-muted);
  border-bottom: 2px solid var(--border-default);
}

th {
  padding: var(--space-md) var(--space-md);
  text-align: left;
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
  white-space: nowrap;
}

/* Table body */
tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: var(--transition-bg);
}

tbody tr:hover {
  background: var(--bg-hover);
}

tbody tr:last-child {
  border-bottom: none;
}

td {
  padding: var(--space-md) var(--space-md);
  color: var(--text-secondary);
  vertical-align: top;
}

/* Table caption */
caption {
  caption-side: top;
  text-align: left;
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-sm);
}

/* Striped table variant */
.table-striped tbody tr:nth-child(even) {
  background: var(--bg-subtle);
}

/* Compact table variant */
.table-compact th,
.table-compact td {
  padding: var(--space-sm) var(--space-md);
}

/* Scrollable table wrapper */
.table-wrapper {
  overflow-x: auto;
  margin: 0 0 var(--content-gap) 0;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
}

.table-wrapper table {
  margin: 0;
  box-shadow: none;
}

/* ============================================
   DETAILS & SUMMARY
   Accessible disclosure widgets
   ============================================ */
details {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin: 0 0 var(--content-gap) 0;
}

summary {
  cursor: pointer;
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
  user-select: none;
  list-style: none;
}

summary::-webkit-details-marker {
  display: none;
}

summary::before {
  content: "▶";
  display: inline-block;
  margin-right: var(--space-xs);
  transition: var(--transition-transform);
}

details[open] summary::before {
  transform: rotate(90deg);
}

details[open] {
  padding-bottom: var(--space-lg);
}

details > *:not(summary) {
  margin-top: var(--space-md);
}

/* ============================================
   UTILITY CLASSES
   Common helpers
   ============================================ */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  background: var(--bg-inverse);
  color: var(--text-inverse);
  padding: var(--space-md) var(--space-lg);
  text-decoration: none;
  z-index: var(--z-maximum);
}

.skip-link:focus {
  top: 0;
}

/* ============================================
   PRINT STYLES
   Optimized for printing
   ============================================ */
@media print {
  *,
  *::before,
  *::after {
    background: transparent !important;
    color: #000 !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }

  a,
  a:visited {
    text-decoration: underline;
  }

  a[href]::after {
    content: " (" attr(href) ")";
  }

  abbr[title]::after {
    content: " (" attr(title) ")";
  }

  pre,
  blockquote {
    border: 1px solid #999;
    page-break-inside: avoid;
  }

  thead {
    display: table-header-group;
  }

  tr,
  img {
    page-break-inside: avoid;
  }

  img {
    max-width: 100% !important;
  }

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

  h2,
  h3 {
    page-break-after: avoid;
  }
}