/* Etcha Legal Documents — Shared Stylesheet
   - Etch-a-Sketch frame reused from the app (red frame + light screen by
     default; body.glow = green glowing frame + dark screen).
   - "Etcha.company" brand at the top of the frame; knobs at the bottom; the
     right knob spins on vertical scroll (see frame.js).
   - Content palette is theme-aware via CSS vars: :root = Light Mode (matches the
     app's light theme); body.glow = Dark Mode (matches trim.energy).
*/

@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@400;600;700&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=Instrument+Serif:ital@0;1&display=swap');

:root {
  /* ---- Light Mode content palette (default) ---- */
  --c-bg: #f5f2ea;
  --c-card: #ffffff;
  --c-text: #35342d;
  --c-strong: #1a1a12;
  --c-muted: #6f6c61;
  --c-faint: #9b978a;
  --c-accent: #2d8a56;
  --c-accent-bright: #3CB371;
  --c-border: rgba(0, 0, 0, 0.12);
  --c-border-strong: rgba(0, 0, 0, 0.18);
  --c-hover: rgba(0, 0, 0, 0.03);
  --c-header-bg: rgba(245, 242, 234, 0.88);

  --font-display: 'Instrument Serif', Georgia, serif;
  --font-body: 'DM Sans', system-ui, -apple-system, sans-serif;

  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 1.5rem;
  --space-lg: 2.5rem;
  --space-xl: 4rem;
  --space-2xl: 6rem;
  --max-width: 820px;
}

/* ---- Dark Mode content palette (body.glow) — matches trim.energy ---- */
body.glow {
  --c-bg: #141414;
  --c-card: #262626;
  --c-text: rgba(255, 255, 255, 0.72);
  --c-strong: #ffffff;
  --c-muted: rgba(255, 255, 255, 0.5);
  --c-faint: rgba(255, 255, 255, 0.35);
  --c-accent: #3CB371;
  --c-accent-bright: #4ade80;
  --c-border: rgba(255, 255, 255, 0.1);
  --c-border-strong: rgba(255, 255, 255, 0.16);
  --c-hover: rgba(255, 255, 255, 0.05);
  --c-header-bg: rgba(20, 20, 20, 0.86);
}

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

html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Light Mode frame: the red Etch-a-Sketch shell (from the app) */
  background: linear-gradient(145deg, #d42426 0%, #b91c1c 50%, #991b1b 100%);
}
/* Dark Mode frame: the app's glow-in-the-dark green shell */
body.glow {
  background:
    radial-gradient(120% 80% at 30% 0%, rgba(214, 255, 150, 0.55) 0%, rgba(214, 255, 150, 0) 60%),
    linear-gradient(145deg, #c7ff70 0%, #8fe53a 45%, #5fae20 100%);
}

/* ============================ ETCH-A-SKETCH FRAME ======================== */
.etch-a-sketch { display: flex; flex-direction: column; width: 100%; height: 100vh; }
.frame { display: flex; flex-direction: column; align-items: center; width: 100%; flex: 1; min-height: 0; padding: 12px; }

.brand {
  display: flex; flex-direction: row; align-items: center; justify-content: space-between;
  /* Full width (no cap) so the header aligns with the content box below it:
     logo flush-left with the box's left edge, nav flush with its right edge.
     The 12px side padding matches the frame padding for a small, even inset. */
  width: 100%; max-width: none; margin: 6px auto 12px; padding: 0 12px; gap: 24px; flex-wrap: wrap;
}
/* Brand wordmark — matches the Etcha.company homepage logo (Etcha/index.html
   .logo): Caveat script in etcha-gold with an etcha-gold-dark drop shadow.
   Same in both themes (gold reads on the light theme's red frame and the glow
   theme's green frame alike). */
.brand-text {
  font-family: 'Caveat', cursive;
  font-size: 2.5rem; font-weight: 700; letter-spacing: 2px;
  color: #C5A356; text-shadow: 2px 2px 0 #A68A3C;
  text-decoration: none;
}
/* Dark mode: the glow frame is bright green, where gold washes out — use the
   dark green of the glow nav links with a light etched shadow instead. */
body.glow .brand-text { color: #123305; text-shadow: 2px 2px 0 rgba(255, 255, 255, 0.35); }

/* Nav links live in the frame's top border, right of the brand. */
.frame-nav .nav-links { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: clamp(12px, 3vw, 26px); list-style: none; }
.frame-nav .nav-links a {
  font-family: var(--font-body); font-size: 0.9rem; font-weight: 600; letter-spacing: 0.02em;
  text-decoration: none; position: relative; transition: color 0.2s, opacity 0.2s;
  color: #fde68a; opacity: 0.85; /* Light Mode: cream lettering on the red frame */
}
.frame-nav .nav-links a::after { display: none; }
.frame-nav .nav-links a:hover { opacity: 1; color: #fff8d6; }
.frame-nav .nav-links a.active { opacity: 1; color: #ffffff; text-decoration: underline; text-underline-offset: 3px; }
/* Glow Mode: dark ink on the green frame, matching the brand */
body.glow .frame-nav .nav-links a { color: #123305; opacity: 0.68; }
body.glow .frame-nav .nav-links a:hover { opacity: 1; color: #0a1f03; }
body.glow .frame-nav .nav-links a.active { opacity: 1; color: #0a1f03; text-decoration: underline; text-underline-offset: 3px; }

@media (max-width: 640px) {
  .brand { flex-direction: column; gap: 6px; }
  .frame-nav .nav-links { justify-content: center; }
}

.screen-container {
  background: var(--c-bg);
  border-radius: 8px;
  padding: 0;
  box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.3), inset 0 -2px 4px rgba(255, 255, 255, 0.1);
  width: 100%; flex: 1 1 0; min-height: 0; display: flex; overflow: hidden;
}
body.glow .screen-container {
  box-shadow: inset 0 0 26px rgba(51, 255, 51, 0.10), inset 0 4px 8px rgba(0, 0, 0, 0.65), inset 0 -2px 4px rgba(51, 255, 51, 0.05);
}
/* The scrollable document surface (its scroll drives the right knob). */
.legal-screen { flex: 1 1 0; min-height: 0; width: 100%; overflow-y: auto; border-radius: 8px; background: var(--c-bg); color: var(--c-text); }

/* Bottom controls: knobs flanking the frame */
.controls { display: grid; grid-template-columns: minmax(56px, auto) 1fr minmax(56px, auto); align-items: center; width: 100%; padding: 10px 16px 12px; flex-shrink: 0; }
.knob-container { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.knob-container.left { justify-self: start; }
.knob-container.right { justify-self: end; }
.knob {
  width: 50px; height: 50px; border-radius: 50%;
  background: linear-gradient(145deg, #f5f5f5 0%, #e5e5e5 50%, #d4d4d4 100%);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4), inset 0 2px 4px rgba(255, 255, 255, 0.8), inset 0 -2px 4px rgba(0, 0, 0, 0.2);
  display: flex; align-items: center; justify-content: center; transition: transform 0.05s linear;
}
body.glow .knob { background: linear-gradient(145deg, #e9ffd0 0%, #c9f0a4 50%, #a6d97e 100%); }
.knob-inner {
  width: 40px; height: 40px; border-radius: 50%; position: relative;
  background: linear-gradient(145deg, #ffffff 0%, #f0f0f0 100%);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
  display: flex; align-items: center; justify-content: center;
}
body.glow .knob-inner { background: linear-gradient(145deg, #f3ffe4 0%, #d8f3bd 100%); }
.knob-grip { position: absolute; width: 4px; height: 12px; border-radius: 2px; background: linear-gradient(90deg, #a3a3a3 0%, #d4d4d4 50%, #a3a3a3 100%); }
body.glow .knob-grip { background: linear-gradient(90deg, #8fb56b 0%, #c4e3a2 50%, #8fb56b 100%); }
.knob-grip:nth-child(1) { transform: rotate(0deg) translateY(-12px); }
.knob-grip:nth-child(2) { transform: rotate(90deg) translateY(-12px); }
.knob-grip:nth-child(3) { transform: rotate(180deg) translateY(-12px); }
.knob-grip:nth-child(4) { transform: rotate(270deg) translateY(-12px); }

@media (max-width: 700px), (pointer: coarse) {
  .controls { grid-template-columns: 52px minmax(0, 1fr) 52px; padding: 8px 10px 10px; }
  .knob { width: 46px; height: 46px; }
  .knob-inner { width: 36px; height: 36px; }
  .brand-text { font-size: 2rem; }
}

/* ============================ DOCUMENT CONTENT ========================== */
.site-header {
  position: sticky; top: 0; z-index: 100;
  padding: var(--space-md) 0;
  background: var(--c-header-bg);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid var(--c-border);
}
.header-inner { max-width: var(--max-width); margin: 0 auto; padding: 0 var(--space-lg); display: flex; align-items: center; justify-content: flex-end; gap: var(--space-md); }
.nav-links { display: flex; gap: var(--space-md); list-style: none; }
.nav-links a {
  font-size: 0.875rem; font-weight: 500; letter-spacing: 0.01em;
  color: var(--c-muted); text-decoration: none; padding: var(--space-xs) 0; position: relative; transition: color 0.25s;
}
.nav-links a::after { content: ''; position: absolute; bottom: 0; left: 0; width: 0; height: 1.5px; background: var(--c-accent); transition: width 0.3s cubic-bezier(0.25,0.46,0.45,0.94); }
.nav-links a:hover { color: var(--c-strong); }
.nav-links a:hover::after { width: 100%; }
.nav-links a.active { color: var(--c-strong); }
.nav-links a.active::after { width: 100%; }

.main-content { max-width: var(--max-width); margin: 0 auto; padding: var(--space-xl) var(--space-lg) var(--space-2xl); }

.document-title { font-family: var(--font-display); font-size: 3.25rem; font-weight: 400; letter-spacing: -0.01em; line-height: 1.1; margin-bottom: var(--space-xl); color: var(--c-strong); }
.document-meta { display: flex; align-items: center; gap: var(--space-md); margin-bottom: var(--space-xl); padding-bottom: var(--space-lg); border-bottom: 1px solid var(--c-border); }
.document-date { font-size: 0.875rem; color: var(--c-muted); }
.document-badge { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--c-accent); background: color-mix(in srgb, var(--c-accent) 12%, transparent); border: 1px solid color-mix(in srgb, var(--c-accent) 34%, transparent); padding: var(--space-xs) var(--space-sm); border-radius: 4px; }

.article-content { font-size: 1.0625rem; color: var(--c-text); }
.article-content p { margin-bottom: var(--space-md); }
.article-content strong { font-weight: 600; color: var(--c-strong); }
.article-content h2 { font-family: var(--font-display); font-size: 1.875rem; font-weight: 400; letter-spacing: -0.01em; color: var(--c-strong); margin-top: var(--space-xl); margin-bottom: var(--space-md); padding-bottom: var(--space-xs); border-bottom: 2px solid var(--c-accent); display: inline-block; }
.article-content h3 { font-size: 1.1875rem; font-weight: 600; color: var(--c-strong); margin-top: var(--space-lg); margin-bottom: var(--space-sm); }
.article-content h4 { font-size: 1rem; font-weight: 600; color: var(--c-accent); margin-top: var(--space-md); margin-bottom: var(--space-sm); }
.article-content ul, .article-content ol { margin-bottom: var(--space-md); padding-left: var(--space-lg); }
.article-content li { margin-bottom: var(--space-xs); }
.article-content li::marker { color: var(--c-accent); }
.article-content ul ul, .article-content ol ol, .article-content ul ol, .article-content ol ul { margin-top: var(--space-xs); margin-bottom: 0; }
.article-content a { color: var(--c-accent); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--c-accent) 40%, transparent); text-underline-offset: 2px; transition: all 0.2s ease; }
.article-content a:hover { color: var(--c-accent-bright); text-decoration-color: var(--c-accent-bright); }
.definition-term { font-weight: 600; color: var(--c-strong); }

.table-wrapper { overflow-x: auto; margin: var(--space-lg) 0; border-radius: 10px; border: 1px solid var(--c-border); }
table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
thead { background: var(--c-card); }
th { font-weight: 600; text-align: left; padding: var(--space-sm) var(--space-md); border-bottom: 2px solid var(--c-accent); color: var(--c-strong); white-space: nowrap; }
td { padding: var(--space-sm) var(--space-md); border-bottom: 1px solid var(--c-border); vertical-align: top; color: var(--c-text); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--c-hover); }

.callout { background: var(--c-card); border-left: 3px solid var(--c-accent); padding: var(--space-md) var(--space-lg); margin: var(--space-lg) 0; border-radius: 0 10px 10px 0; color: var(--c-text); box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.callout p:last-child { margin-bottom: 0; }
.callout strong { color: var(--c-strong); }

.section-divider { display: flex; align-items: center; gap: var(--space-md); margin: var(--space-xl) 0; }
.section-divider::before, .section-divider::after { content: ''; flex: 1; height: 1px; background: linear-gradient(to right, transparent, var(--c-border-strong), transparent); }
.section-divider span { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--c-muted); }

.related-docs { margin-top: var(--space-2xl); padding-top: var(--space-xl); border-top: 1px solid var(--c-border); }
.related-docs h3 { font-size: 0.875rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--c-muted); margin-bottom: var(--space-md); }
.related-docs-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space-sm); }
.related-doc-link { display: flex; align-items: center; gap: var(--space-sm); padding: var(--space-sm) var(--space-md); background: var(--c-card); border: 1px solid var(--c-border); border-radius: 8px; text-decoration: none; color: var(--c-text); font-size: 0.9375rem; font-weight: 500; transition: all 0.2s ease; }
.related-doc-link:hover { border-color: var(--c-accent); color: var(--c-strong); transform: translateY(-1px); }
.related-doc-link::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--c-border-strong); flex-shrink: 0; }
.related-doc-link:hover::before { background: var(--c-accent); }

.site-footer { max-width: var(--max-width); margin: 0 auto; padding: var(--space-xl) var(--space-lg); border-top: 1px solid var(--c-border); display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: var(--space-md); }
.footer-brand { font-size: 0.875rem; color: var(--c-muted); }
.footer-brand strong { color: var(--c-strong); font-weight: 600; }
.footer-links { display: flex; gap: var(--space-md); }
.footer-links a { font-size: 0.875rem; color: var(--c-muted); text-decoration: none; transition: color 0.2s ease; }
.footer-links a:hover { color: var(--c-accent); }

@media (max-width: 768px) {
  :root { --space-lg: 1.5rem; --space-xl: 2.5rem; --space-2xl: 4rem; }
  .document-title { font-size: 2.25rem; }
  .article-content h2 { font-size: 1.5rem; }
  .nav-links { flex-wrap: wrap; justify-content: center; }
  .header-inner { justify-content: center; }
  .site-footer { flex-direction: column; text-align: center; }
}

@media print {
  body { height: auto; overflow: visible; background: #fff; }
  .brand, .controls, .site-header, .site-footer, .related-docs { display: none; }
  .etch-a-sketch, .frame, .screen-container, .legal-screen { display: block; height: auto; overflow: visible; box-shadow: none; background: #fff; }
  .frame { padding: 0; }
  .document-title, .article-content, .article-content p, .article-content h2, .article-content h3, .article-content h4, .article-content strong { color: #000; }
  .main-content { max-width: 100%; padding: 0; }
  .article-content a { color: inherit; text-decoration: none; }
  .article-content a[href]::after { content: " (" attr(href) ")"; font-size: 0.8em; color: #555; }
}

.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; }
.text-center { text-align: center; }
.text-muted { color: var(--c-muted); }
.font-mono { font-family: 'DM Mono', ui-monospace, monospace; }
