/* ==========================================================================
   MINIMAL EDITORIAL DESIGN SYSTEM - Base Variables & Typography
   Inspired by printed editorial design: serif headings, clean sans body, paper textures.
   ========================================================================== */

:root {
  /* --- PALETTE --- */

  /* Ink & Paper (High Contrast Base) */
  --ink:          #1a1a1a;  /* Near black, softer than #000 */
  --ink-2:        #333333;  /* Dark grey for subheads */
  --paper:        #f9f9f7;  /* Warm, off-white paper tone */
  --paper-bright: #ffffff;  /* Pure white for cards/inputs */

  /* Structural Lines */
  --line:         #e0e0e0;  /* Standard border */
  --line-strong:  #bfbfbf;  /* Darker border for emphasis */
  --line-faint:   #f0f0f0;  /* Very subtle divider */

  /* Semantic Colors (Restrained) */
  --sage-green:   #556b2f;  /* Primary brand/action color - Earthy, natural */
  --terra-cotta:  #a64d4d;  /* Destructive/Error - Muted red */
  --mustard:      #d4a017;  /* Warning/Attention - Muted yellow */
  --slate:        #4a5568;  /* Info/Secondary - Cool grey */
  --charcoal:     #36454F;
  --dark-green:   #1a4a1a;

  /* Neutrals */
  --gray-1:       #f5f5f5;  /* Lightest background wash */
  --gray-2:       #eeeeee;
  --gray-3:       #dddddd;
  --gray-4:       #999999;  /* Muted text */
  --gray-5:       #666666;

  /* Paints (Subtle background accents) */
  --paint-1:      #e8f5e9;  /* Pale sage wash */
  --paint-2:      #fbe9e7;  /* Pale terra cotta wash */
  --paint-3:      #fff8e1;  /* Pale mustard wash */
  --paint-4:      #e3f2fd;  /* Pale slate wash */
  --paint-5:      #f3e5f5;  /* Pale purple wash */

  /* --- TYPOGRAPHY --- */
  
  /* Font Stacks */
  --font-serif:   "EB Garamond", "Garamond", "Georgia", serif;
  --font-sans:    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono:    "JetBrains Mono", "SFMono-Regular", Consolas, monospace;

  /* Scale (Major Third - 1.25) */
  --fs-1: 3.052rem;  /* Display */
  --fs-2: 2.441rem;  /* H1 */
  --fs-3: 1.953rem;  /* H2 */
  --fs-4: 1.563rem;  /* H3 */
  --fs-5: 1.25rem;   /* H4/Large Body */
  --fs-6: 1rem;      /* Base Body */
  --fs-7: 0.8rem;    /* Small/Caption */

  /* --- SPACING & LAYOUT --- */
  
  --spacing-unit: 8px;
  
  /* Space Steps */
  --s-1: calc(var(--spacing-unit) * 0.5); /* 4px */
  --s-2: var(--spacing-unit);             /* 8px */
  --s-3: calc(var(--spacing-unit) * 1.5); /* 12px */
  --s-4: calc(var(--spacing-unit) * 2);   /* 16px */
  --s-5: calc(var(--spacing-unit) * 3);   /* 24px */
  --s-6: calc(var(--spacing-unit) * 4);   /* 32px */
  --s-8: calc(var(--spacing-unit) * 6);   /* 48px */
  
  /* Radii */
  --r-1: 4px;
  --r-2: 8px;
  --r-3: 16px;
  --r-pill: 9999px;

  /* Shadows (Soft, diffused) */
  --shadow-1: 0 1px 2px rgba(0,0,0,0.06);
  --shadow-2: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-3: 0 12px 24px rgba(0,0,0,0.12);

  /* Transitions */
  --ease: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --t-fast: 150ms;
  --t-med:  300ms;
}

/* --- RESET & BASE --- */

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

body {
  font-family: var(--font-sans);
  font-size: var(--fs-6);
  line-height: 1.6;
  color: var(--ink);
  background-color: var(--paper);
  -webkit-font-smoothing: antialiased;
}

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

/* --- ACCESSIBILITY --- */

.skip-to-main {
  position: absolute;
  top: -999px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper-bright);
  padding: var(--s-2) var(--s-4);
  z-index: 2000;
  border-radius: 0 0 var(--r-2) var(--r-2);
  font-weight: 600;
  text-decoration: none;
}

.skip-to-main:focus {
  top: 0;
  outline: 3px solid var(--mustard);
}

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

/* --- TYPOGRAPHY --- */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-serif);
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink);
  margin-bottom: var(--s-3);
}

h1 { font-size: var(--fs-2); letter-spacing: -0.02em; }
h2 { font-size: var(--fs-3); letter-spacing: -0.01em; margin-top: var(--s-6); }
h3 { font-size: var(--fs-4); margin-top: var(--s-5); }
h4 { font-size: var(--fs-5); }

p {
  margin-bottom: var(--s-4);
  max-width: 70ch; /* Reading length */
}

a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: color var(--t-fast) var(--ease);
}

a:hover {
  color: var(--sage-green);
  text-decoration-thickness: 2px;
}

small, .text-small {
  font-size: var(--fs-7);
  color: var(--ink-2);
}

.text-muted {
  color: var(--gray-4);
}

/* --- BUTTONS --- */

button,
input[type="button"],
input[type="submit"],
input[type="reset"],
[role="button"] {
  cursor: pointer;
}

button:disabled,
input[type="button"]:disabled,
input[type="submit"]:disabled,
input[type="reset"]:disabled,
[role="button"][aria-disabled="true"] {
  cursor: not-allowed;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-4);
  font-family: var(--font-sans);
  font-size: var(--fs-6);
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: var(--r-2);
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
  line-height: 1;
}

.btn:disabled, .btn.disabled {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

/* Primary: Sage Green Solid */
.btn-primary {
  background-color: var(--ink);
  color: var(--paper-bright);
  border-color: var(--ink);
}

.btn-primary:hover {
  background-color: var(--ink-2);
  transform: translateY(-1px);
  box-shadow: var(--shadow-1);
}

.btn-primary:active {
  transform: translateY(0);
}

/* Secondary: Outline */
.btn-secondary {
  background-color: transparent;
  color: var(--ink);
  border-color: var(--line-strong);
}

.btn-secondary:hover {
  border-color: var(--ink);
  background-color: var(--gray-1);
}

/* Ghost: Text only (with subtle hover) */
.btn-ghost {
  background-color: transparent;
  color: var(--ink-2);
}

.btn-ghost:hover {
  background-color: var(--gray-1);
  color: var(--ink);
}

/* Destructive */
.btn-danger {
  background-color: var(--terra-cotta);
  color: white;
}
.btn-danger:hover {
  background-color: #8a3b3b;
}

/* Sizes */
.btn-sm {
  font-size: var(--fs-7);
  padding: var(--s-1) var(--s-3);
}

.btn-lg {
  font-size: var(--fs-5);
  padding: var(--s-3) var(--s-5);
}

/* --- FORMS --- */

label {
  display: block;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: var(--fs-7);
  color: var(--ink-2);
  margin-bottom: var(--s-1);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
textarea,
select {
  display: block;
  width: 100%;
  padding: var(--s-2) var(--s-3);
  font-family: var(--font-sans);
  font-size: var(--fs-6);
  color: var(--ink);
  background-color: var(--paper-bright);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-2);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--sage-green);
  box-shadow: 0 0 0 3px var(--paint-1);
}

input::placeholder, textarea::placeholder {
  color: var(--gray-4);
}

/* Checkbox/Radio Wrapper */
.form-check {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin-bottom: var(--s-2);
}

.form-check input {
  width: auto;
  margin: 0;
}

.form-check label {
  margin: 0;
  text-transform: none;
  font-size: var(--fs-6);
  font-weight: 400;
  letter-spacing: normal;
}

/* --- CARDS & SURFACES --- */

.card {
  background-color: var(--paper-bright);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  padding: var(--s-5);
  box-shadow: var(--shadow-1);
}

.card-header {
  border-bottom: 1px solid var(--line);
  padding-bottom: var(--s-3);
  margin-bottom: var(--s-3);
}

.card-header h2, .card-header h3 {
  margin: 0;
}

/* Corner Accent (Editorial Touch) */
.corner-accent-tr {
  position: relative;
  overflow: hidden;
}

.corner-accent-tr::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, transparent 50%, var(--paint-2) 50%);
  opacity: 0.8;
}

/* --- UTILITIES --- */

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--s-4);
}

.flex-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--s-3);
}

.flex-col {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.items-start { align-items: flex-start; }
.items-center { align-items: center; }

.grid {
  display: grid;
  gap: var(--s-4);
}

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

.mt-2 { margin-top: var(--s-2); }
.mt-4 { margin-top: var(--s-4); }
.mb-2 { margin-bottom: var(--s-2); }
.mb-4 { margin-bottom: var(--s-4); }

.w-full { width: 100%; }

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: var(--fs-7);
  font-weight: 600;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background-color: var(--gray-2);
  color: var(--ink-2);
}

.badge-success { background-color: var(--paint-1); color: var(--dark-green); }
.badge-warning { background-color: var(--paint-3); color: #8a6d0b; }
.badge-danger  { background-color: var(--paint-2); color: var(--terra-cotta); }
.badge-info    { background-color: var(--paint-4); color: #2c5282; }

/* Alert Banner */
.alert {
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-2);
  margin-bottom: var(--s-4);
  border: 1px solid transparent;
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
}

.alert-info {
  background-color: var(--paint-4);
  border-color: #bee3f8;
  color: #2c5282;
}

.alert-success {
  background-color: var(--paint-1);
  border-color: #c6f6d5;
  color: var(--dark-green);
}

.alert-warning {
  background-color: var(--paint-3);
  border-color: #fefcbf;
  color: #744210;
}

.alert-danger {
  background-color: var(--paint-2);
  border-color: #fed7d7;
  color: #742a2a;
}

/* --- NAVIGATION --- */
.navbar {
  background-color: var(--paper-bright);
  border-bottom: 1px solid var(--line);
  padding: var(--s-3) 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-brand {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: var(--fs-4);
  text-decoration: none;
  color: var(--ink);
}

.nav-links {
  display: flex;
  gap: var(--s-4);
  list-style: none;
}

.nav-links a {
  text-decoration: none;
  font-weight: 600;
  color: var(--ink-2);
  padding-bottom: 2px;
  border-bottom: 2px solid transparent;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--ink);
  border-color: var(--sage-green);
}

/* User Menu Dropdown */
.user-menu {
  position: relative;
}

.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  cursor: pointer;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--gray-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--ink-2);
  border: 1px solid var(--line-strong);
}

/* --- TABLES --- */
.table-container {
  overflow-x: auto;
  border-radius: var(--r-2);
  border: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th, td {
  padding: var(--s-3);
  border-bottom: 1px solid var(--line);
}

th {
  background-color: var(--gray-1);
  font-weight: 600;
  color: var(--ink);
  font-size: var(--fs-7);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

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

tr:hover td {
  background-color: var(--paper);
}

/* --- LOADING STATES --- */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--gray-2);
  border-top-color: var(--sage-green);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* HTMX Loading Indicator support */
.htmx-indicator {
  opacity: 0;
  transition: opacity 200ms ease-in;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
}

/* Global Footer Utilities */
.floating-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: #fff;
  border-top: 2px solid var(--line);
  box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
}

.footer-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.75rem 2rem;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
}

/* Responsive Breakpoint Utilities */
@media (max-width: 900px) {
  .hide-on-tablet {
    display: none;
  }

  .grid-cols-2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .hide-on-mobile {
    display: none;
  }

  /* Reduce padding on cards for mobile */
  .card {
    padding: var(--s-4);
  }

  /* Stack buttons vertically on mobile */
  .btn-group {
    flex-direction: column;
    width: 100%;
  }

  .btn-group .btn {
    width: 100%;
  }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  .btn {
    border-width: 2px;
  }

  nav a.active {
    border-bottom-width: 3px;
  }

  .card {
    border-width: 2px;
  }
}

/* Recipe Detail Utilities */
.recipe-card-transparent {
  border: none !important;
  box-shadow: none !important;
  background: transparent !important;
  padding: 0 !important;
}

.hero-image-container {
  width: 100%;
  max-height: 200px;
  overflow: hidden;
  border-radius: 12px;
  border: 1.5px solid var(--line);
}

.hero-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  font-size: 0.9rem;
}

.json-block-dark {
  background: #111827;
  color: #e5e7eb;
  padding: 1rem;
  border-radius: 8px;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  margin-top: 1rem;
}

.kg-modal-body { padding: 0.5rem 0; }

.kg-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.kg-legend {
  margin-top: 0.75rem;
  font-size: 0.9rem;
  color: var(--gray-5);
}

.ml-auto { margin-left: auto !important; }
.ml-1 { margin-left: 1rem !important; }
.mr-05 { margin-right: 0.5rem !important; }
.gap-2 { gap: 0.5rem !important; }
.gap-3 { gap: 3rem !important; }
.align-start { align-items: flex-start !important; }
.flex-wrap { flex-wrap: wrap !important; }
.bg-cream { background: var(--paper) !important; } /* cream -> paper */
.border-none { border: none !important; }
.fs-1-1 { font-size: 1.1rem !important; }
.fs-1 { font-size: 1rem !important; }
.relative { position: relative !important; }

#knowledge-graph-container {
  width: 100%;
  height: 600px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

/* ==========================================================================
   CSP-SAFE UTILITY CLASSES
   Replaces inline styles for Content Security Policy compliance
   ========================================================================== */

/* --- Display --- */
.d-none { display: none !important; }
.d-block { display: block !important; }
.d-inline { display: inline !important; }
.d-inline-block { display: inline-block !important; }
.d-flex { display: flex !important; }
.d-inline-flex { display: inline-flex !important; }
.d-grid { display: grid !important; }

/* --- Flex Direction --- */
.flex-row { flex-direction: row !important; }
.flex-column { flex-direction: column !important; }

/* --- Flex Wrap --- */
.flex-wrap { flex-wrap: wrap !important; }
.flex-nowrap { flex-wrap: nowrap !important; }

/* --- Justify Content --- */
.justify-start { justify-content: flex-start !important; }
.justify-center { justify-content: center !important; }
.justify-end { justify-content: flex-end !important; }
.justify-between { justify-content: space-between !important; }

/* --- Align Items --- */
.align-start { align-items: flex-start !important; }
.align-center { align-items: center !important; }
.align-end { align-items: flex-end !important; }

/* --- Gap --- */
.gap-0 { gap: 0 !important; }
.gap-1 { gap: 0.25rem !important; }
.gap-2 { gap: 0.5rem !important; }
.gap-3 { gap: 0.75rem !important; }
.gap-4 { gap: 1rem !important; }
.gap-5 { gap: 1.25rem !important; }
.gap-6 { gap: 1.5rem !important; }

/* --- Margins --- */
.m-0 { margin: 0 !important; }
.m-1 { margin: 0.25rem !important; }
.m-2 { margin: 0.5rem !important; }
.m-3 { margin: 0.75rem !important; }
.m-4 { margin: 1rem !important; }
.m-5 { margin: 1.25rem !important; }
.m-6 { margin: 1.5rem !important; }

.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 0.25rem !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mt-3 { margin-top: 0.75rem !important; }
.mt-4 { margin-top: 1rem !important; }
.mt-5 { margin-top: 1.25rem !important; }
.mt-6 { margin-top: 1.5rem !important; }
.mt-8 { margin-top: 2rem !important; }

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.25rem !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 0.75rem !important; }
.mb-4 { margin-bottom: 1rem !important; }
.mb-5 { margin-bottom: 1.25rem !important; }
.mb-6 { margin-bottom: 1.5rem !important; }

.ml-0 { margin-left: 0 !important; }
.ml-1 { margin-left: 0.25rem !important; }
.ml-2 { margin-left: 0.5rem !important; }
.ml-3 { margin-left: 0.75rem !important; }
.ml-4 { margin-left: 1rem !important; }
.ml-auto { margin-left: auto !important; }

.mr-0 { margin-right: 0 !important; }
.mr-1 { margin-right: 0.25rem !important; }
.mr-2 { margin-right: 0.5rem !important; }
.mr-3 { margin-right: 0.75rem !important; }
.mr-4 { margin-right: 1rem !important; }

.mx-auto { margin-left: auto !important; margin-right: auto !important; }

/* --- Padding --- */
.p-0 { padding: 0 !important; }
.p-1 { padding: 0.25rem !important; }
.p-2 { padding: 0.5rem !important; }
.p-3 { padding: 0.75rem !important; }
.p-4 { padding: 1rem !important; }
.p-5 { padding: 1.25rem !important; }
.p-6 { padding: 1.5rem !important; }

.pt-0 { padding-top: 0 !important; }
.pt-2 { padding-top: 0.5rem !important; }
.pt-3 { padding-top: 0.75rem !important; }
.pt-4 { padding-top: 1rem !important; }

.pb-0 { padding-bottom: 0 !important; }
.pb-2 { padding-bottom: 0.5rem !important; }
.pb-3 { padding-bottom: 0.75rem !important; }
.pb-4 { padding-bottom: 1rem !important; }

.pl-2 { padding-left: 0.5rem !important; }
.pr-2 { padding-right: 0.5rem !important; }

.px-3 { padding-left: 0.75rem !important; padding-right: 0.75rem !important; }
.px-4 { padding-left: 1rem !important; padding-right: 1rem !important; }
.px-6 { padding-left: 1.5rem !important; padding-right: 1.5rem !important; }

.py-2 { padding-top: 0.5rem !important; padding-bottom: 0.5rem !important; }
.py-3 { padding-top: 0.75rem !important; padding-bottom: 0.75rem !important; }
.py-4 { padding-top: 1rem !important; padding-bottom: 1rem !important; }
.py-12 { padding-top: 3rem !important; padding-bottom: 3rem !important; }

/* --- Width --- */
.w-full { width: 100% !important; }
.w-auto { width: auto !important; }
.max-w-xs { max-width: 320px !important; }
.max-w-sm { max-width: 520px !important; }
.max-w-md { max-width: 700px !important; }
.max-w-lg { max-width: 900px !important; }
.max-w-xl { max-width: 1100px !important; }
.max-w-70ch { max-width: 70ch !important; }

/* --- Height --- */
.h-full { height: 100% !important; }
.h-auto { height: auto !important; }
.min-h-80 { min-height: 80px !important; }
.min-h-150 { min-width: 150px !important; }
.max-h-200 { max-height: 200px !important; }
.max-h-300 { max-height: 300px !important; }
.max-h-60vh { max-height: 60vh !important; }

/* --- Typography --- */
.text-xs { font-size: 0.75rem !important; }
.text-sm { font-size: 0.85rem !important; }
.text-base { font-size: 1rem !important; }
.text-lg { font-size: 1.1rem !important; }
.text-xl { font-size: 1.25rem !important; }

.font-normal { font-weight: 400 !important; }
.font-medium { font-weight: 500 !important; }
.font-semibold { font-weight: 600 !important; }
.font-bold { font-weight: 700 !important; }

.text-left { text-align: left !important; }
.text-center { text-align: center !important; }
.text-right { text-align: right !important; }

.text-ink { color: var(--ink) !important; }
.text-ink-2 { color: var(--ink-2) !important; }
.text-muted { color: var(--gray-4) !important; }
.text-sage { color: var(--sage-green) !important; }
.text-error { color: #c00 !important; }
.text-white { color: white !important; }

.italic { font-style: italic !important; }
.uppercase { text-transform: uppercase !important; }
.capitalize { text-transform: capitalize !important; }
.no-underline { text-decoration: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.whitespace-nowrap { white-space: nowrap !important; }

.font-mono { font-family: var(--font-mono) !important; }
.font-sans { font-family: var(--font-sans) !important; }

.leading-tight { line-height: 1 !important; }
.leading-normal { line-height: 1.5 !important; }

/* --- Background --- */
.bg-white { background-color: white !important; }
.bg-paper { background-color: var(--paper) !important; }
.bg-paper-bright { background-color: var(--paper-bright) !important; }
.bg-gray-1 { background-color: var(--gray-1) !important; }
.bg-sage { background-color: var(--sage-green) !important; }
.bg-sage-light { background-color: rgba(139, 168, 136, 0.12) !important; }
.bg-paint-1 { background-color: var(--paint-1) !important; }
.bg-paint-2 { background-color: var(--paint-2) !important; }
.bg-progress { background-color: #e0e0e0 !important; }
.bg-transparent { background: transparent !important; }

/* --- Border --- */
.border { border: 1px solid var(--line) !important; }
.border-2 { border: 2px solid var(--line) !important; }
.border-sage { border-color: var(--sage-green) !important; }
.border-sage-light { border-color: var(--sage-green-light, rgba(139, 168, 136, 0.3)) !important; }
.border-light { border-color: var(--line) !important; }
.border-t { border-top: 1px solid var(--line) !important; }
.border-b { border-bottom: 1px solid var(--line) !important; }
.border-b-2 { border-bottom: 2px solid var(--line) !important; }
.border-none { border: none !important; }

.rounded { border-radius: var(--r-1) !important; }
.rounded-md { border-radius: var(--r-2) !important; }
.rounded-lg { border-radius: var(--r-3) !important; }
.rounded-full { border-radius: 9999px !important; }

/* --- Position --- */
.relative { position: relative !important; }
.absolute { position: absolute !important; }
.fixed { position: fixed !important; }
.inset-0 { top: 0; right: 0; bottom: 0; left: 0; }
.top-full { top: 100% !important; }
.left-0 { left: 0 !important; }
.right-0 { right: 0 !important; }

/* --- Overflow --- */
.overflow-hidden { overflow: hidden !important; }
.overflow-auto { overflow: auto !important; }
.overflow-y-auto { overflow-y: auto !important; }
.overflow-x-auto { overflow-x: auto !important; }

/* --- Cursor --- */
.cursor-pointer { cursor: pointer !important; }
.cursor-default { cursor: default !important; }

/* --- Z-Index --- */
.z-10 { z-index: 10 !important; }
.z-100 { z-index: 100 !important; }
.z-1000 { z-index: 1000 !important; }

/* --- Box Shadow --- */
.shadow-sm { box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important; }
.shadow { box-shadow: var(--shadow-2) !important; }
.shadow-lg { box-shadow: 0 4px 6px rgba(0,0,0,0.1) !important; }
.shadow-none { box-shadow: none !important; }

/* --- Opacity --- */
.opacity-80 { opacity: 0.8 !important; }
.opacity-90 { opacity: 0.9 !important; }

/* --- Flex/Grid sizing --- */
.flex-1 { flex: 1 !important; }
.flex-shrink-0 { flex-shrink: 0 !important; }

/* ==========================================================================
   COMPONENT UTILITIES - CSP Refactor Replacements
   ========================================================================== */

/* Form Group */
.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.form-hint {
  font-size: 0.9rem;
  color: var(--gray-4);
  margin-top: 0.25rem;
}

.required-mark {
  color: #c00;
}

/* Form input with border styling */
.form-input {
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
  border: 2px solid var(--line);
  border-radius: 8px;
  font-family: inherit;
}

.form-input:focus {
  outline: none;
  border-color: var(--sage-green);
}

/* Search Form */
.search-form-row {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
  max-width: 800px;
}

.search-input {
  flex: 1;
  padding: 0.875rem 1.25rem;
  font-size: 1rem;
  border: 2px solid var(--sage-green);
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.search-btn {
  padding: 0.875rem 1.5rem;
  font-size: 1rem;
}

/* Alert boxes */
.alert-error {
  background: #fee;
  border: 1px solid #fcc;
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  color: #c00;
}

.alert-success-box {
  background-color: #d1e7dd;
  color: #0f5132;
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid #badbcc;
}

/* Card Variants */
.card-centered {
  text-align: center;
  padding: 3rem;
}

.card-narrow {
  max-width: 520px;
  margin: 2rem auto;
}

.card-wide {
  max-width: 1100px;
  margin: 1.5rem auto;
  padding: 1.5rem;
}

.card-highlight {
  background: var(--paint-1);
  border: 2px solid var(--sage-green);
}

.card-muted {
  background: var(--gray-1);
  border: 1px solid var(--line);
  margin-top: 1.5rem;
}

/* Header with actions */
.header-with-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.header-with-actions h2 {
  margin: 0;
}

/* Progress Bars */
.progress-bar-container {
  flex: 1;
  max-width: 400px;
  background: #e0e0e0;
  border-radius: 4px;
  overflow: hidden;
  height: 24px;
}

.progress-bar-container-sm {
  height: 20px;
}

.progress-bar-fill {
  background: var(--sage-green);
  height: 100%;
  display: flex;
  align-items: center;
  padding-left: 0.5rem;
  color: white;
  font-size: 0.85rem;
  font-weight: 600;
}

.progress-bar-fill-muted {
  background: #999;
}

/* Ingredient row */
.ingredient-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.ingredient-name {
  min-width: 150px;
  font-weight: 500;
}

.ingredient-count {
  min-width: 80px;
  text-align: right;
  color: var(--gray-4);
  font-size: 0.9rem;
}

/* Image containers */
.thumb-container {
  width: 100%;
  height: 160px;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.thumb-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Pagination */
.pagination {
  margin-top: 1.5rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
}

/* Chips/Tags */
.chip {
  display: inline-flex;
  align-items: center;
  background: rgba(139, 168, 136, 0.12);
  border: 1px solid var(--sage-green-light, rgba(139, 168, 136, 0.3));
  border-radius: 4px;
}

.chip-btn {
  border: none;
  padding: 0.2rem 0.4rem;
  font-size: 0.8rem;
  color: var(--charcoal);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
  background: transparent;
}

.chip-divider {
  width: 1px;
  height: 14px;
  background: var(--sage-green-light, rgba(139, 168, 136, 0.3));
}

.chip-close {
  border: none;
  padding: 0.2rem 0.4rem;
  color: var(--gray-4);
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  background: transparent;
}

/* Ingredient chips container */
.chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

/* Input with button row */
.input-button-row {
  display: flex;
  gap: 0.5rem;
}

/* Autocomplete dropdown */
.autocomplete-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 60px;
  margin-top: 0.25rem;
  background: white;
  border: 2px solid var(--line);
  border-radius: 8px;
  max-height: 300px;
  overflow-y: auto;
  z-index: 1000;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.autocomplete-dropdown.show {
  display: block;
}

/* Modal variants */
.modal-wide {
  max-width: 900px;
}

.modal-extra-wide {
  max-width: 90%;
}

.modal-medium {
  max-width: 700px;
}

.modal-body-padded {
  padding: 1.5rem;
}

/* Tabs */
.tabs {
  margin-bottom: 1.5rem;
  display: flex;
  gap: 0.75rem;
  border-bottom: 2px solid var(--line);
  padding-bottom: 0.5rem;
  flex-wrap: wrap;
}

/* Details/Summary */
.details-expandable {
  margin-top: 0.75rem;
  font-size: 0.9rem;
}

.details-expandable summary {
  cursor: pointer;
  margin-bottom: 0.5rem;
}

.details-content {
  max-height: 200px;
  overflow-y: auto;
  padding: 0.5rem 0;
}

.details-content-tall {
  max-height: 300px;
}

/* List items */
.list-item-flex {
  padding: 0.5rem 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Button variants for add actions */
.btn-add {
  padding: 0.75rem 1.5rem;
  background: var(--sage-green);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}

/* Table compact */
.table-compact {
  font-size: 0.85rem;
}

/* Subtle lead text */
.lead {
  font-size: 1.1rem;
  opacity: 0.9;
  margin-top: 0.75rem;
}

.lead-sm {
  font-size: 0.95rem;
  opacity: 0.8;
  margin-top: 0.5rem;
}

/* Menu action row */
.menu-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Library badge */
.library-badge {
  font-size: 0.75rem;
  color: var(--sage-green);
  font-weight: 600;
  margin-left: 0.5rem;
}

/* Superuser banner */
.superuser-banner {
  background: var(--paint-1);
  border: 2px solid var(--sage-green);
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
}

/* Layout controls for visualization */
.layout-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 1rem;
  background: white;
  border-radius: 4px;
}

.layout-btn {
  padding: 0.5rem 1rem;
  margin-right: 0.5rem;
  cursor: pointer;
  border: 1px solid #ddd;
  background: white;
  border-radius: 4px;
}

.layout-btn:last-child {
  margin-right: 0;
}

.layout-btn.active {
  background: var(--sage-green);
  color: white;
  border-color: var(--sage-green);
}

/* ==========================================================================
   LANDING PAGE STYLES
   ========================================================================== */

.landing-hero {
  padding: 4rem 2rem;
  background-color: var(--paper-bright);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  margin-bottom: 3rem;
  text-align: center;
}

.landing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
}

.landing-card {
  background-color: var(--paper-bright);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  padding: 2rem;
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.landing-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-2);
  border-color: var(--sage-green);
}

.landing-card h3 {
  margin-top: 0;
  color: var(--sage-green);
}

.landing-card p {
  flex-grow: 1;
  color: var(--ink-2);
  margin-bottom: 1.5rem;
}

.landing-card a {
  align-self: flex-start;
  font-weight: 600;
  text-decoration: none;
  color: var(--ink);
  border-bottom: 2px solid var(--line-strong);
  padding-bottom: 2px;
}

.landing-card a:hover {
  color: var(--sage-green);
  border-color: var(--sage-green);
}
