/**
 * TrendMix Base Styles
 * Reset + base element styling
 *
 * @package TrendMix
 */

/* ─── 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%;
}

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

  /* Prevent horizontal overflow */
  overflow-x: hidden;
}

/* ─── Global Layout ───────────────────────────────── */

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

/*
 * Comfortable page gutters.
 * This prevents content from touching the edges
 * on pages where a container is not used.
 */

.site-main {
  width: 100%;
}

.site-main > section {
  width: 100%;
}

/* ─── Typography ──────────────────────────────────── */

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--color-text-primary);
  margin-bottom: var(--space-4);
}

h1 {
  font-size: var(--text-5xl);
}

h2 {
  font-size: var(--text-4xl);
}

h3 {
  font-size: var(--text-3xl);
}

h4 {
  font-size: var(--text-2xl);
}

h5 {
  font-size: var(--text-xl);
  font-weight: var(--fw-semibold);
}

h6 {
  font-size: var(--text-lg);
  font-weight: var(--fw-semibold);
}

@media (max-width: 768px) {
  h1 {
    font-size: var(--text-4xl);
  }

  h2 {
    font-size: var(--text-3xl);
  }

  h3 {
    font-size: var(--text-2xl);
  }

  h4 {
    font-size: var(--text-xl);
  }
}

@media (max-width: 640px) {
  h1 {
    font-size: var(--text-3xl);
  }

  h2 {
    font-size: var(--text-2xl);
  }

  h3 {
    font-size: var(--text-xl);
  }
}

p {
  margin-bottom: var(--space-4);
  color: var(--color-text-secondary);
  line-height: var(--leading-relaxed);
}

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

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

em,
i {
  font-style: italic;
}

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

/* ─── Links ───────────────────────────────────────── */

a {
  color: var(--color-link);
  text-decoration: none;
  transition:
    color var(--transition-fast),
    opacity var(--transition-fast);
}

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

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

/* ─── Lists ───────────────────────────────────────── */

ul,
ol {
  padding-inline-start: var(--space-6);
  margin-bottom: var(--space-5);
}

ul {
  list-style: disc;
}

ol {
  list-style: decimal;
}

li {
  margin-bottom: var(--space-2);
  color: var(--color-text-secondary);
  line-height: var(--leading-relaxed);
}

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

/* ─── Images ──────────────────────────────────────── */

img {
  display: block;
  max-width: 100%;
  height: auto;
}

figure {
  margin: 0;
}

figcaption {
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* ─── Forms ───────────────────────────────────────── */

input,
textarea,
select,
button {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
}

input,
textarea,
select {
  max-width: 100%;
}

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

/*
 * Better default form spacing.
 * Individual components can override this.
 */

input:not([type="checkbox"]):not([type="radio"]),
textarea,
select {
  width: 100%;
}

textarea {
  min-height: 140px;
  resize: vertical;
}

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

/* ─── Focus Styles ────────────────────────────────── */

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

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

/* ─── Selection ───────────────────────────────────── */

::selection {
  background-color: rgba(var(--color-primary-rgb), 0.15);
  color: var(--color-primary);
}

/* ─── Horizontal Rule ─────────────────────────────── */

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

/* ─── Code ────────────────────────────────────────── */

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background-color: var(--color-neutral-100);
  padding: 0.15em 0.45em;
  border-radius: var(--radius-sm);
  color: var(--color-primary);
}

pre {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  background-color: var(--color-neutral-100);
  padding: var(--space-5) var(--space-6);
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin: var(--space-6) 0;
  border-inline-start: 3px solid var(--color-primary);
}

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

/* ─── Blockquote ──────────────────────────────────── */

blockquote {
  border-inline-start: 3px solid var(--color-accent);
  padding: var(--space-5) var(--space-6);
  margin: var(--space-8) 0;
  background-color: var(--color-neutral-50);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

blockquote p {
  font-size: var(--text-lg);
  font-style: italic;
  color: var(--color-text-primary);
  margin-bottom: 0;
}

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

/* ─── Tables ──────────────────────────────────────── */

table {
  width: 100%;
  margin: var(--space-6) 0;
  border-collapse: collapse;
}

th {
  padding: var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  border-bottom: 2px solid var(--color-border);
  text-align: start;
}

td {
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-border-light);
  color: var(--color-text-secondary);
  vertical-align: middle;
}

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

/* ─── Content Spacing ─────────────────────────────── */

/*
 * Gives WordPress content comfortable vertical rhythm.
 */

.entry-content > * + *,
.page-content > * + * {
  margin-top: var(--space-5);
}

.entry-content h2,
.entry-content h3,
.entry-content h4,
.page-content h2,
.page-content h3,
.page-content h4 {
  margin-top: var(--space-10);
}

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

.entry-content img,
.page-content img {
  margin-block: var(--space-6);
}

/* ─── Skip Link ───────────────────────────────────── */

.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  z-index: var(--z-toast);
  background-color: var(--color-primary);
  color: var(--color-white);
  padding: var(--space-3) var(--space-5);
  border-radius: 0 0 var(--radius-base) var(--radius-base);
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  transition: top var(--transition-fast);
}

.skip-link:focus {
  top: 0;
  color: var(--color-white);
}

/* ─── Screen Reader Only ──────────────────────────── */

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

/* ─── RTL Support ─────────────────────────────────── */

[dir="rtl"] {
  text-align: right;
}

[dir="rtl"] ul,
[dir="rtl"] ol {
  padding-inline-start: var(--space-6);
}

[dir="rtl"] blockquote {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

/* ─── Responsive Spacing ──────────────────────────── */

@media (max-width: 768px) {
  .container {
    padding-inline: 20px;
  }

  .entry-content h2,
  .page-content h2 {
    margin-top: var(--space-8);
  }

  .entry-content h3,
  .page-content h3 {
    margin-top: var(--space-7);
  }

  blockquote {
    padding: var(--space-4) var(--space-5);
    margin-block: var(--space-6);
  }

  th,
  td {
    padding: var(--space-3);
  }
}

@media (max-width: 480px) {
  .container {
    padding-inline: 16px;
  }

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

  pre {
    padding: var(--space-4);
    border-radius: var(--radius-sm);
  }

  blockquote {
    padding: var(--space-4);
  }

  th,
  td {
    padding: var(--space-3) var(--space-2);
  }
}

/* ─── Print ───────────────────────────────────────── */

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

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

  thead {
    display: table-header-group;
  }

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

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

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

  .site-header,
  .site-footer,
  .sidebar,
  .mobile-nav {
    display: none;
  }
}