/* =====================================================================
   Law Twist — main.css
   Shared design system for all pages.

   Aesthetic: Modern, technical, neutral. Inter throughout, weight + color
   for hierarchy. Warm cream-paper light theme, deep ink dark theme,
   electric blue accent.

   Sections:
     1. Design tokens (CSS custom properties)
     2. Dark theme overrides
     3. Reset / normalize
     4. Document defaults
     5. Typography
     6. Layout primitives (.container, .stack, .cluster, .grid, .split)
     7. Components (.btn, .card, .input, .alert, .nav, .footer, .badge)
     8. Utilities
     9. Print

   Stage A: this file is created but NOT linked from any live page yet.
   Stage B will migrate pages one at a time.
   ===================================================================== */


/* ----- 1. Design tokens ------------------------------------------------ */

:root {
  /* Brand */
  --brand:           #00ABFF;
  --brand-strong:    #0089CC;
  --brand-soft:      #E6F6FF;
  --brand-contrast:  #FFFFFF;

  /* Neutrals (light theme — warm cream) */
  --bg:              #FAFAF7;
  --surface:         #FFFFFF;
  --surface-2:       #F4F3EE;
  --surface-sunken:  #EDEBE3;
  --ink:             #0D0D0D;
  --ink-2:           #2A2A2A;
  --muted:           #6B6B6B;
  --faint:           #9A9A95;
  --border:          #E5E3DA;
  --border-strong:   #C9C6BA;

  /* Status */
  --success:         #1C8A4A;
  --success-soft:    #E4F4EA;
  --warning:         #B86A00;
  --warning-soft:    #FBEFD9;
  --danger:          #C7283A;
  --danger-soft:     #FBE6E8;
  --info:            var(--brand-strong);
  --info-soft:       var(--brand-soft);

  /* Typography
     Single-family system: Inter for everything. Headlines get hierarchy
     from weight (600) + size + tighter letter-spacing rather than a
     separate display face. --font-display is kept as an alias so any
     code referencing it still works after the switch. */
  --font-sans:       "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-display:    var(--font-sans);
  --font-mono:       ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  /* Fluid type scale (clamps to viewport) */
  --step--1:  clamp(0.83rem, 0.81rem + 0.10vw, 0.89rem);
  --step-0:   clamp(1.00rem, 0.97rem + 0.13vw, 1.06rem);
  --step-1:   clamp(1.20rem, 1.16rem + 0.20vw, 1.31rem);
  --step-2:   clamp(1.44rem, 1.38rem + 0.30vw, 1.62rem);
  --step-3:   clamp(1.73rem, 1.65rem + 0.42vw, 2.00rem);
  --step-4:   clamp(2.07rem, 1.96rem + 0.58vw, 2.47rem);
  --step-5:   clamp(2.49rem, 2.33rem + 0.80vw, 3.05rem);
  --step-6:   clamp(2.99rem, 2.76rem + 1.10vw, 3.77rem);

  /* Spacing scale */
  --space-1:  0.25rem;   /*  4px */
  --space-2:  0.5rem;    /*  8px */
  --space-3:  0.75rem;   /* 12px */
  --space-4:  1rem;      /* 16px */
  --space-5:  1.5rem;    /* 24px */
  --space-6:  2rem;      /* 32px */
  --space-7:  3rem;      /* 48px */
  --space-8:  4rem;      /* 64px */
  --space-9:  6rem;      /* 96px */
  --space-10: 8rem;      /* 128px */

  /* Radii — single 4px value across the system (brutal/Linear-style).
     All tokens collapse to 4px so any existing rule that references
     --radius-md, --radius-lg, etc. still works without edits. To go
     softer in the future, just change these values. */
  --radius-sm:    4px;
  --radius-md:    4px;
  --radius-lg:    4px;
  --radius-xl:    4px;
  --radius-pill:  4px;

  /* Shadows */
  --shadow-sm:   0 1px 2px rgba(13, 13, 13, 0.06);
  --shadow-md:   0 6px 18px -6px rgba(13, 13, 13, 0.12), 0 2px 4px rgba(13, 13, 13, 0.04);
  --shadow-lg:   0 18px 40px -14px rgba(13, 13, 13, 0.18), 0 4px 10px rgba(13, 13, 13, 0.06);
  --shadow-focus: 0 0 0 3px rgba(0, 171, 255, 0.30);

  /* Layout */
  --container-narrow: 42rem;   /* prose-width */
  --container-base:   64rem;   /* default */
  --container-wide:   64rem;   /* dashboards */

  /* Motion */
  --ease-out:  cubic-bezier(0.16, 1, 0.30, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --dur-fast:  140ms;
  --dur-base:  220ms;
  --dur-slow:  360ms;
}


/* ----- 2. Dark theme overrides ---------------------------------------- */

[data-theme="dark"] {
  --bg:              #0F1014;
  --surface:         #171821;
  --surface-2:       #1E2030;
  --surface-sunken:  #0A0A0E;
  --ink:             #F2F0E8;
  --ink-2:           #DBD9D1;
  --muted:           #9A9A95;
  --faint:           #6B6B6B;
  --border:          #2A2C3A;
  --border-strong:   #3E4053;

  --brand-soft:      rgba(0, 171, 255, 0.14);

  --success-soft:    rgba(28, 138, 74, 0.16);
  --warning-soft:    rgba(184, 106, 0, 0.16);
  --danger-soft:     rgba(199, 40, 58, 0.16);
  --info-soft:       rgba(0, 171, 255, 0.16);

  --shadow-sm:   0 1px 2px rgba(0, 0, 0, 0.40);
  --shadow-md:   0 6px 18px -6px rgba(0, 0, 0, 0.55), 0 2px 4px rgba(0, 0, 0, 0.30);
  --shadow-lg:   0 18px 40px -14px rgba(0, 0, 0, 0.65), 0 4px 10px rgba(0, 0, 0, 0.35);
}


/* ----- 3. Reset / normalize ------------------------------------------- */

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

html, body { height: 100%; }

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

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

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

table { border-collapse: collapse; }

[hidden] { display: none !important; }

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}


/* ----- 4. Document defaults ------------------------------------------- */

html {
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: var(--step-0);
  line-height: 1.55;
  color: var(--ink);
  background-color: var(--bg);
  font-feature-settings: "kern", "liga", "calt";
}

::selection {
  background: var(--brand);
  color: var(--brand-contrast);
}


/* ----- 5. Typography -------------------------------------------------- */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.015em;
  color: var(--ink);
}

h1 { font-size: clamp(2rem, 1.85rem + 0.7vw, 2.625rem); font-weight: 700; letter-spacing: -0.025em; line-height: 1.1; }
h2 { font-size: var(--step-5); letter-spacing: -0.02em; line-height: 1.1; }
h3 { font-size: var(--step-4); }
h4 { font-size: var(--step-3); }
h5 { font-size: var(--step-2); }
h6 { font-size: var(--step-1); }

/* Headline accent pattern: <h1>Headline <em>accent</em></h1>
   The <em> renders in brand color, upright (not italic), bolder than its surroundings.
   Used across all migrated pages for consistent emphasis on key words. */
h1 em, h2 em {
  font-style: normal;
  color: var(--brand);
  font-weight: 700;
}

.eyebrow {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: var(--step--1);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

p { max-width: 65ch; }
.lede { font-size: var(--step-1); color: var(--ink-2); max-width: 60ch; }

a {
  color: var(--brand-strong);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  transition: color var(--dur-fast) var(--ease-out);
}
a:hover { color: var(--brand); }

[data-theme="dark"] a { color: var(--brand); }
[data-theme="dark"] a:hover { color: #4DC4FF; }

code, kbd, samp, pre {
  font-family: var(--font-mono);
  font-size: 0.92em;
}
code {
  background: var(--surface-2);
  padding: 0.12em 0.35em;
  border-radius: var(--radius-sm);
}
pre {
  background: var(--surface-2);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  overflow-x: auto;
}
pre code { background: transparent; padding: 0; }

blockquote {
  border-left: 3px solid var(--brand);
  padding: var(--space-2) var(--space-5);
  font-size: var(--step-2);
  font-style: italic;
  color: var(--ink-2);
}

hr {
  border: 0;
  height: 1px;
  background: var(--border);
  margin: var(--space-7) 0;
}


/* ----- 6. Layout primitives ------------------------------------------- */

.container {
  width: 100%;
  max-width: var(--container-base);
  margin-inline: auto;
  padding-inline: var(--space-5);
}
.container--narrow { max-width: var(--container-narrow); }
.container--wide  { max-width: var(--container-wide); }

/* Stack: vertical rhythm */
.stack > * + * { margin-top: var(--space-4); }
.stack-sm > * + * { margin-top: var(--space-2); }
.stack-lg > * + * { margin-top: var(--space-6); }
.stack-xl > * + * { margin-top: var(--space-8); }

/* Cluster: horizontal flow with wrapping */
.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
}
.cluster-sm { gap: var(--space-2); }
.cluster-lg { gap: var(--space-6); }

/* Grid: equal columns, responsive */
.grid {
  display: grid;
  gap: var(--space-5);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
}
.grid-2 {
  display: grid;
  gap: var(--space-5);
  grid-template-columns: repeat(2, 1fr);
}
.grid-3 {
  display: grid;
  gap: var(--space-5);
  grid-template-columns: repeat(3, 1fr);
}
@media (max-width: 720px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* Split: 50/50 with a min-content option */
.split {
  display: grid;
  gap: var(--space-6);
  grid-template-columns: 1fr 1fr;
}
@media (max-width: 720px) {
  .split { grid-template-columns: 1fr; }
}

.section {
  padding-block: clamp(var(--space-7), 6vw, var(--space-10));
}
.section-tight { padding-block: var(--space-7); }


/* ----- 7. Components -------------------------------------------------- */

/* --- Button --- */
.btn {
  --btn-bg:      var(--surface);
  --btn-fg:      var(--ink);
  --btn-border:  var(--border-strong);
  --btn-hover:   var(--surface-2);

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.7em 1.3em;
  font-family: var(--font-sans);
  font-size: var(--step-0);
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  color: var(--btn-fg);
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition:
    background var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out);
  white-space: nowrap;
  user-select: none;
}
.btn:hover { background: var(--btn-hover); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.btn:disabled, .btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  --btn-bg:     var(--brand);
  --btn-fg:     var(--brand-contrast);
  --btn-border: var(--brand);
  --btn-hover:  var(--brand-strong);
}
.btn-primary:hover { border-color: var(--brand-strong); }

.btn-secondary {
  --btn-bg:     transparent;
  --btn-fg:     var(--ink);
  --btn-border: var(--border-strong);
  --btn-hover:  var(--surface-2);
}

.btn-ghost {
  --btn-bg:     transparent;
  --btn-fg:     var(--ink);
  --btn-border: transparent;
  --btn-hover:  var(--surface-2);
}

.btn-danger {
  --btn-bg:     transparent;
  --btn-fg:     var(--danger);
  --btn-border: var(--danger);
  --btn-hover:  var(--danger-soft);
}

.btn-sm  { padding: 0.45em 0.9em;  font-size: var(--step--1); }
.btn-lg  { padding: 0.9em 1.6em;   font-size: var(--step-1); }
.btn-block { display: flex; width: 100%; }

/* --- Card --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}
.card-flat { box-shadow: none; }
.card-raised { box-shadow: var(--shadow-md); }
.card-hover {
  transition: transform var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out);
}
.card-hover:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.card-title {
  font-family: var(--font-display);
  font-size: var(--step-3);
  font-weight: 600;
  letter-spacing: -0.015em;
  margin-bottom: var(--space-2);
}
.card-meta {
  font-size: var(--step--1);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* --- Forms --- */
.label {
  display: block;
  font-size: var(--step--1);
  font-weight: 500;
  color: var(--ink-2);
  margin-bottom: var(--space-2);
}
.label-hint {
  display: block;
  font-size: var(--step--1);
  font-weight: 400;
  color: var(--muted);
  margin-top: var(--space-1);
}

.input,
.textarea,
.select {
  display: block;
  width: 100%;
  padding: 0.65em 0.9em;
  font-family: var(--font-sans);
  font-size: var(--step-0);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--shadow-focus);
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.textarea { resize: vertical; min-height: 6rem; }

.input-error { border-color: var(--danger); }
.input-error:focus { box-shadow: 0 0 0 3px rgba(199, 40, 58, 0.25); }

.field { display: flex; flex-direction: column; }
.field + .field { margin-top: var(--space-4); }

.checkbox, .radio {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  user-select: none;
}
.checkbox input, .radio input {
  width: 1.05em;
  height: 1.05em;
  accent-color: var(--brand);
}

/* --- Alert --- */
.alert {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: var(--step-0);
}
.alert-title { font-weight: 600; color: var(--ink); margin-bottom: var(--space-1); }
.alert-info    { background: var(--info-soft);    border-color: var(--brand); }
.alert-success { background: var(--success-soft); border-color: var(--success); }
.alert-warning { background: var(--warning-soft); border-color: var(--warning); }
.alert-danger  { background: var(--danger-soft);  border-color: var(--danger); }

/* --- Badge --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.25em 0.7em;
  font-size: var(--step--1);
  font-weight: 500;
  letter-spacing: 0.02em;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--ink-2);
  border: 1px solid var(--border);
}
.badge-success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge-danger  { background: var(--danger-soft);  color: var(--danger);  border-color: transparent; }
.badge-info    { background: var(--info-soft);    color: var(--info);    border-color: transparent; }
.badge-dot::before {
  content: "";
  width: 0.5em; height: 0.5em;
  background: currentColor;
  border-radius: 50%;
  display: inline-block;
}

/* --- Nav (top bar) --- */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--border);
}
.nav-brand {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3em;
  font-family: var(--font-display);
  font-size: var(--step-2);
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.015em;
}
.nav-brand em { font-style: normal; color: var(--brand); font-weight: 600; }
.nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  list-style: none;
  padding: 0;
}
.nav-links a {
  text-decoration: none;
  color: var(--ink-2);
  font-size: var(--step-0);
}
.nav-links a:hover { color: var(--brand); }
@media (max-width: 640px) {
  .nav-links { gap: var(--space-3); }
  .nav-links .nav-secondary { display: none; }
}

/* Right-side cluster — used when nav has user info / actions on the right.
   Pushed to the end of the nav's flex row by margin-left:auto. */
.nav-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-left: auto;
}
.nav-user {
  font-size: var(--step--1);
  color: var(--muted);
  font-weight: 500;
}

/* Loading state — a centered spinner, used wherever async data is loading. */
.loading-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-7) 0;
}
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: lt-spin 0.7s linear infinite;
}
@keyframes lt-spin { to { transform: rotate(360deg); } }

/* Site footer fallback — bridges the gap until Stage D rebuilds footer.php
   with proper structured content. The current footer.php is a single
   <footer class="site-footer"><p>...</p></footer> block. */
.site-footer {
  text-align: center;
  padding: var(--space-5) 0;
  font-size: var(--step--1);
  color: var(--muted);
  border-top: 1px solid var(--border);
  margin-top: var(--space-7);
}
.site-footer p {
  margin-inline: auto;
  max-width: none;
}

/* --- Footer --- */
.footer {
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  padding-block: var(--space-7);
  margin-top: var(--space-9);
  color: var(--muted);
  font-size: var(--step--1);
}
.footer h5 {
  font-family: var(--font-sans);
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: var(--space-3);
}
.footer ul { list-style: none; padding: 0; }
.footer li + li { margin-top: var(--space-2); }
.footer a {
  color: var(--ink-2);
  text-decoration: none;
}
.footer a:hover { color: var(--brand); text-decoration: underline; }
.footer-meta {
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  justify-content: space-between;
}


/* ----- 8. Utilities --------------------------------------------------- */

.text-display  { font-family: var(--font-display); }
.text-sans     { font-family: var(--font-sans); }
.text-mono     { font-family: var(--font-mono); }

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

.text-muted    { color: var(--muted); }
.text-faint    { color: var(--faint); }
.text-brand    { color: var(--brand); }
.text-ink      { color: var(--ink); }

.text-xs { font-size: var(--step--1); }
.text-sm { font-size: var(--step-0); }
.text-lg { font-size: var(--step-1); }
.text-xl { font-size: var(--step-2); }

.fw-400 { font-weight: 400; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

/* Spacing utilities (margin) */
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.mt-6 { margin-top: var(--space-6); }
.mt-7 { margin-top: var(--space-7); }
.mt-8 { margin-top: var(--space-8); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-7 { margin-bottom: var(--space-7); }

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

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

.w-full { width: 100%; }
.h-full { height: 100%; }

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


/* ----- 9. Print ------------------------------------------------------- */

@media print {
  body { background: #fff; color: #000; }
  .nav, .footer, .btn { display: none !important; }
  a { color: #000; text-decoration: underline; }
  .card { border: 1px solid #ccc; box-shadow: none; }
}
