/* ==========================================================================
   LEWB - Theme Polish (Premium Layer)
   Dependencies: Needs variables from global.css
   ========================================================================== */

/* -----------------------------
   1. Typography & Content
------------------------------ */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading, var(--font-sans));
  color: var(--text);
  font-weight: 700;
  margin-top: 2em; /* Better spacing for long content */
  margin-bottom: 0.75em;
  line-height: 1.15;
  letter-spacing: -0.015em;
  transition: color 0.2s ease;
}

h1 { font-weight: 800; letter-spacing: -0.03em; }
h2 { font-weight: 800; letter-spacing: -0.02em; }
h3 { font-weight: 700; }
h4,h5,h6 { font-weight: 600; }

h1:first-child,
h2:first-child {
  margin-top: 0;
}

p.lead {
  font-size: var(--text-3);
  line-height: 1.6;
  color: var(--text-muted);
  font-weight: 500;
  max-width: 65ch;
  margin-bottom: 2rem;
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 3rem 0;
}

mark {
  background: rgba(255, 215, 0, 0.25);
  padding: 0.1em 0.2em;
  border-radius: 4px;
  color: inherit;
}

blockquote {
  margin: 2rem 0;
  padding: 2rem;
  border-left: 4px solid var(--primary, #a81c3d);
  background: var(--surface-2);
  border-radius: 0 var(--radius-2) var(--radius-2) 0;
  font-size: var(--text-2);
  font-style: italic;
}

blockquote p:last-child {
  margin-bottom: 0;
}

blockquote cite {
  display: block;
  margin-top: 1rem;
  font-size: var(--text-1);
  font-style: normal;
  font-weight: 600;
  color: var(--text-muted);
}
blockquote cite::before {
  content: "— ";
}

/* -----------------------------
   2. Lists
------------------------------ */
ul, ol {
  padding-left: 1.5rem;
  margin-bottom: var(--space-4);
}

ul li, ol li {
  margin-bottom: 0.5rem;
  padding-left: 0.5rem;
}

ul li::marker {
  color: var(--primary, #a81c3d);
}

ol li::marker {
  font-weight: 600;
  color: var(--text-muted);
}

/* -----------------------------
   3. Tables (Premium)
------------------------------ */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-bottom: 2rem;
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--border);
  border-radius: var(--radius-2);
  overflow: hidden; /* For rounded corners */
}

thead th {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 700;
  text-align: left;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover td {
  background: var(--surface-3);
  color: var(--text);
}

tfoot td {
  background: var(--surface-2);
  padding: 1rem;
  font-weight: 600;
  border-top: 2px solid var(--border);
}

/* -----------------------------
   4. Forms (Refined)
------------------------------ */
/* Overrides global generic styles for better polish */

label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text);
  font-size: 0.95em;
}

input, select, textarea {
  transition: all 0.2s ease;
}

input:hover, select:hover, textarea:hover {
  border-color: var(--border-strong);
}

fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius-2);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  background: var(--surface);
}

legend {
  font-weight: 700;
  padding: 0 0.5rem;
  color: var(--text);
}

/* Checkbox & Radio customization could go here but requires changing HTML structure usually.
   Keeping default for now but robust. */

/* -----------------------------
   5. Buttons (Variants)
------------------------------ */
/* Primary is default in global, let's refine */
.button, button, input[type="submit"] {
  letter-spacing: 0.02em;
  text-transform: none; /* Avoid shouting */
}

/* Secondary / Outline variant */
.button--secondary,
.button.button--outline {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text);
  box-shadow: none;
}

.button--secondary:hover,
.button.button--outline:hover {
  border-color: var(--text);
  background: var(--surface-2);
  box-shadow: var(--shadow-1);
}

/* Disabled state */
button:disabled,
.button.is-disabled {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
  filter: grayscale(1);
}

/* -----------------------------
   6. Components
------------------------------ */

/* Details / Summary */
details {
  border: 1px solid var(--border);
  border-radius: var(--radius-2);
  margin-bottom: 1rem;
  background: var(--surface);
  overflow: hidden;
}

summary {
  padding: 1rem;
  cursor: pointer;
  font-weight: 600;
  background: var(--surface-2);
  list-style: none; /* Hide default triangle in some browsers */
  position: relative;
  padding-right: 3rem;
  transition: background 0.2s;
}

summary:hover {
  background: var(--surface-3);
}

summary::-webkit-details-marker {
  display: none;
}

/* Custom indicator */
summary::after {
  content: '+';
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-weight: 400;
  font-size: 1.5em;
  line-height: 1;
}

details[open] summary::after {
  content: '−'; /* Minus sign */
}

details[open] summary {
  border-bottom: 1px solid var(--border);
}

details > p,
details > div {
  padding: 1.5rem;
  margin: 0;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Figures */
figure {
  margin: 2rem 0;
}

figure img {
  border-radius: var(--radius-2);
  box-shadow: var(--shadow-2);
  width: 100%;
}

figcaption {
  margin-top: 0.75rem;
  font-size: 0.9em;
  color: var(--text-muted);
  text-align: center;
  font-style: italic;
}

/* Code */
pre {
  background: #1e293b; /* Slate 800 */
  color: #e2e8f0; /* Slate 200 */
  padding: 1.5rem;
  border-radius: var(--radius-2);
  overflow-x: auto;
  font-family: monospace;
  font-size: 0.9em;
  line-height: 1.5;
}

code {
  background: var(--surface-2);
  padding: 0.2em 0.4em;
  border-radius: 4px;
  font-size: 0.9em;
  color: var(--primary, #d63384);
}

pre code {
  background: transparent;
  padding: 0;
  color: inherit;
  font-size: inherit;
}
