/*
 * base.css — CSS reset, custom properties, typography
 * Part of the Compare WordPress Theme
 * No hardcoded hex values — all color via CSS custom properties
 */

/* ─── CSS Custom Properties (default: trust-blue) ───────────────────────────── */
/* These are overridden by /inc/color-palettes.php via wp_head                   */

:root {
  /* Palette colors — overridden per site */
  --color-primary:       #1D4ED8;
  --color-primary-dark:  #1E3A8A;
  --color-primary-light: #EFF6FF;
  --color-accent:        #F59E0B;
  --color-accent-dark:   #D97706;
  --color-text:          #111827;
  --color-text-muted:    #6B7280;
  --color-bg:            #FFFFFF;
  --color-bg-soft:       #F9FAFB;
  --color-border:        #E5E7EB;
  --color-nav-bg:        #1E3A8A;

  /* Semantic mappings — same across all palettes */
  --color-link:          var(--color-primary);
  --color-link-hover:    var(--color-primary-dark);
  --color-btn-bg:        var(--color-accent);
  --color-btn-hover:     var(--color-accent-dark);
  --color-btn-text:      #FFFFFF;
  --color-highlight:     var(--color-primary-light);
  --color-badge-bg:      var(--color-primary);
  --color-badge-text:    #FFFFFF;
  --color-score-bar:     var(--color-primary);
  --color-nav-text:      #FFFFFF;
  --color-nav-hover:     var(--color-accent);
  --color-footer-bg:     var(--color-nav-bg);
  --color-footer-text:   rgba(255, 255, 255, 0.75);
  --color-table-header:  var(--color-primary);
  --color-table-text:    #FFFFFF;
  --color-table-alt:     var(--color-bg-soft);

  /* Semantic fixed colors — never change with palette */
  --color-pros:    #16A34A;
  --color-cons:    #DC2626;
  --color-warning: #D97706;
  --color-info:    #0EA5E9;
  --color-success: #16A34A;
  --color-danger:  #DC2626;

  /* Typography */
  --font-display: 'Georgia', 'Times New Roman', serif;
  --font-body:    system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono:    'Courier New', Courier, monospace;
  --font-ui:      system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

  /* Fluid type scale */
  --text-xs:   clamp(0.6875rem, 1.2vw, 0.75rem);
  --text-sm:   clamp(0.8125rem, 1.4vw, 0.875rem);
  --text-base: clamp(0.9375rem, 1.6vw, 1.0625rem);
  --text-lg:   clamp(1.0625rem, 1.8vw, 1.1875rem);
  --text-xl:   clamp(1.25rem,   2.2vw, 1.5rem);
  --text-2xl:  clamp(1.5rem,    2.8vw, 1.875rem);
  --text-3xl:  clamp(1.75rem,   3.5vw, 2.375rem);
  --text-4xl:  clamp(2rem,      4vw,   3rem);

  /* Line heights */
  --line-height-body:    1.75;
  --line-height-heading: 1.2;
  --line-height-tight:   1.1;

  /* Font weights */
  --font-weight-normal:   400;
  --font-weight-medium:   500;
  --font-weight-semibold: 600;
  --font-weight-bold:     700;

  /* Spacing scale */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;

  /* Border radius */
  --radius-sm:   0.25rem;
  --radius-md:   0.5rem;
  --radius-lg:   0.75rem;
  --radius-xl:   1rem;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.10);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
  --shadow-xl: 0 16px 40px rgba(0, 0, 0, 0.14);

  /* Transitions */
  --transition-fast:   150ms ease;
  --transition-base:   250ms ease;
  --transition-slow:   400ms ease;

  /* Z-index layers */
  --z-base:     1;
  --z-dropdown: 100;
  --z-sticky:   200;
  --z-fixed:    300;
  --z-modal:    400;
  --z-toast:    500;
}

/* ─── CSS Reset ─────────────────────────────────────────────────────────────── */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  font-size: 100%;
}

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

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

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

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

a {
  color: var(--color-link);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color var(--transition-fast);
}

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

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

p {
  max-width: 75ch;
}

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

li {
  margin-bottom: var(--space-1);
}

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

table {
  border-collapse: collapse;
  width: 100%;
}

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background-color: var(--color-bg-soft);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.1em 0.35em;
}

pre {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  background-color: var(--color-bg-soft);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  overflow-x: auto;
  line-height: 1.6;
}

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

blockquote {
  border-left: 4px solid var(--color-primary);
  padding: var(--space-4) var(--space-6);
  margin: var(--space-8) 0;
  background-color: var(--color-primary-light);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-style: italic;
  color: var(--color-text);
}

blockquote p {
  margin: 0;
}

/* ─── Headings ──────────────────────────────────────────────────────────────── */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-heading);
  color: var(--color-text);
  margin-bottom: var(--space-4);
  scroll-margin-top: 80px; /* For sticky header offset */
}

h1 { font-size: var(--text-3xl); margin-bottom: var(--space-6); }
h2 { font-size: var(--text-2xl); margin-top: var(--space-10); margin-bottom: var(--space-4); }
h3 { font-size: var(--text-xl);  margin-top: var(--space-8);  margin-bottom: var(--space-3); }
h4 { font-size: var(--text-lg);  margin-top: var(--space-6);  margin-bottom: var(--space-2); }
h5 { font-size: var(--text-base); font-weight: var(--font-weight-semibold); margin-top: var(--space-4); }
h6 { font-size: var(--text-sm);   font-weight: var(--font-weight-semibold); margin-top: var(--space-4); }

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

.entry-content ul,
.entry-content ol {
  margin: var(--space-4) 0 var(--space-6);
}

.entry-content ul li,
.entry-content ol li {
  margin-bottom: var(--space-2);
  line-height: var(--line-height-body);
}

.entry-content ul ul,
.entry-content ol ol,
.entry-content ul ol,
.entry-content ol ul {
  margin: var(--space-2) 0;
}

/* ─── Article Content Typography ─────────────────────────────────────────────── */

.entry-content {
  font-size: var(--text-base);
  line-height: var(--line-height-body);
  color: var(--color-text);
}

.entry-content p {
  margin-bottom: var(--space-6);
}

.entry-content a {
  color: var(--color-link);
  text-decoration: underline;
}

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

.entry-content img {
  border-radius: var(--radius-md);
  margin: var(--space-6) 0;
}

.entry-content figure {
  margin: var(--space-6) 0;
}

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

.entry-content h2 {
  border-bottom: 2px solid var(--color-border);
  padding-bottom: var(--space-3);
}

.entry-content table {
  margin: var(--space-6) 0;
  font-size: var(--text-sm);
}

/* ─── Accessibility ──────────────────────────────────────────────────────────── */

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

.screen-reader-text:focus {
  background-color: var(--color-bg);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  clip: auto !important;
  clip-path: none;
  color: var(--color-text);
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--font-weight-bold);
  height: auto;
  left: var(--space-6);
  line-height: normal;
  padding: var(--space-4) var(--space-6);
  text-decoration: none;
  top: var(--space-6);
  width: auto;
  z-index: var(--z-toast);
}

.compare-skip-link {
  position: absolute;
  top: -9999px;
  left: -9999px;
}

.compare-skip-link:focus {
  position: fixed;
  top: var(--space-4);
  left: var(--space-4);
  z-index: var(--z-toast);
  background: var(--color-primary);
  color: #FFFFFF;
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-md);
  font-weight: var(--font-weight-semibold);
  text-decoration: none;
  outline: none;
}

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

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

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

::selection {
  background-color: var(--color-primary-light);
  color: var(--color-text);
}

/* ─── Scrollbar ──────────────────────────────────────────────────────────────── */

@supports (scrollbar-width: thin) {
  * {
    scrollbar-width: thin;
    scrollbar-color: var(--color-border) transparent;
  }
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background-color: var(--color-border); border-radius: var(--radius-full); }

/* ─── Utility Classes ────────────────────────────────────────────────────────── */

.compare-visually-hidden { @extend .screen-reader-text; }

.compare-text-center  { text-align: center; }
.compare-text-left    { text-align: left; }
.compare-text-right   { text-align: right; }

.compare-text-xs      { font-size: var(--text-xs); }
.compare-text-sm      { font-size: var(--text-sm); }
.compare-text-base    { font-size: var(--text-base); }
.compare-text-lg      { font-size: var(--text-lg); }
.compare-text-xl      { font-size: var(--text-xl); }
.compare-text-2xl     { font-size: var(--text-2xl); }
.compare-text-3xl     { font-size: var(--text-3xl); }

.compare-font-bold    { font-weight: var(--font-weight-bold); }
.compare-font-medium  { font-weight: var(--font-weight-medium); }
.compare-font-normal  { font-weight: var(--font-weight-normal); }

.compare-text-muted   { color: var(--color-text-muted); }
.compare-text-primary { color: var(--color-primary); }
.compare-text-accent  { color: var(--color-accent); }

.compare-mt-0 { margin-top: 0; }
.compare-mb-0 { margin-bottom: 0; }
.compare-mt-4 { margin-top: var(--space-4); }
.compare-mb-4 { margin-bottom: var(--space-4); }
.compare-mt-8 { margin-top: var(--space-8); }
.compare-mb-8 { margin-bottom: var(--space-8); }

/* ─── WordPress Core Alignment Classes ───────────────────────────────────────── */

.alignleft {
  float: left;
  margin: 0 var(--space-6) var(--space-4) 0;
}

.alignright {
  float: right;
  margin: 0 0 var(--space-4) var(--space-6);
}

.aligncenter {
  display: block;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

.alignwide {
  margin-left: calc(-1 * var(--space-8));
  margin-right: calc(-1 * var(--space-8));
}

.alignfull {
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  width: 100vw;
}

/* ─── Gallery ────────────────────────────────────────────────────────────────── */

.gallery {
  display: grid;
  gap: var(--space-4);
  margin: var(--space-6) 0;
}

.gallery-columns-2 { grid-template-columns: repeat(2, 1fr); }
.gallery-columns-3 { grid-template-columns: repeat(3, 1fr); }
.gallery-columns-4 { grid-template-columns: repeat(4, 1fr); }

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin: 0;
}

/* ─── WordPress Admin Bar Offset ─────────────────────────────────────────────── */

.admin-bar .compare-header--sticky {
  top: 32px;
}

@media screen and (max-width: 782px) {
  .admin-bar .compare-header--sticky {
    top: 46px;
  }
}
