/* ==========================================================================
   ToolRegal — Global Stylesheet
   Design: clean, lightweight, readable. Client-side only (no framework).
   ========================================================================== */

:root {
  --color-bg: #f6f7f9;
  --color-surface: #ffffff;
  --color-surface-2: #eef0f3;
  --color-text: #1b2430;
  --color-text-muted: #5c6b7a;
  --color-primary: #2563eb;
  --color-primary-dark: #1e40af;
  --color-accent: #7c3aed;
  --color-border: #d8dde3;
  --color-success: #15803d;
  --color-warning: #b45309;
  --color-danger: #b91c1c;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 8px 24px rgba(16, 24, 40, 0.10);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --header-h: 64px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #0f1420;
    --color-surface: #171e2b;
    --color-surface-2: #1f2837;
    --color-text: #e8edf3;
    --color-text-muted: #9aa8b8;
    --color-border: #2b3648;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

/* ---------- Layout ---------- */

.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 20px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  height: var(--header-h);
  display: flex;
  align-items: center;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.brand {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-decoration: none;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand .logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  color: #fff;
  font-size: 16px;
}

.main-nav {
  display: flex;
  gap: 4px;
  align-items: center;
}

.main-nav a {
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 0.925rem;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
}

.main-nav a:hover { color: var(--color-text); background: var(--color-surface-2); }

@media (max-width: 640px) {
  .main-nav { display: none; }
}

.site-main {
  padding: 36px 0 64px;
  min-height: calc(100vh - var(--header-h) - 180px);
}

.site-footer {
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
  padding: 28px 0 36px;
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.site-footer .footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
  align-items: center;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}

.footer-links a { color: var(--color-text-muted); text-decoration: none; }
.footer-links a:hover { color: var(--color-text); text-decoration: underline; }

/* ---------- Typography ---------- */

h1, h2, h3 {
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin: 0 0 0.5em;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.35rem; margin-top: 1.2em; }
h3 { font-size: 1.05rem; }

@media (max-width: 640px) {
  h1 { font-size: 1.5rem; overflow-wrap: break-word; }
  h2 { font-size: 1.15rem; overflow-wrap: break-word; }
  p, li { overflow-wrap: break-word; }
  .tool-shell a { overflow-wrap: anywhere; }
}

p { margin: 0 0 1em; }
.muted { color: var(--color-text-muted); }

.hero {
  text-align: center;
  padding: 24px 0 8px;
  margin-bottom: 28px;
}

.hero h1 { font-size: 2.4rem; }
.hero .sub { font-size: 1.1rem; color: var(--color-text-muted); max-width: 620px; margin: 0 auto; }

/* ---------- Tool grid ---------- */

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}

.tool-card {
  display: block;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  text-decoration: none;
  color: var(--color-text);
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
}

.tool-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--color-primary);
}

.tool-card .tool-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  background: var(--color-surface-2);
  margin-bottom: 12px;
}

.tool-card h2 { margin: 0 0 6px; font-size: 1.15rem; }
.tool-card p { margin: 0; font-size: 0.925rem; color: var(--color-text-muted); }

/* ---------- Tool pages ---------- */

.breadcrumb {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 16px;
}

.breadcrumb a { color: var(--color-primary); text-decoration: none; }

.tool-shell {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  max-width: 760px;
}

.tool-shell.wide { max-width: 940px; }

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 6px;
}

.input,
.select,
textarea.input {
  width: 100%;
  padding: 10px 12px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus,
.select:focus,
textarea.input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

textarea.input { min-height: 120px; resize: vertical; }

.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 160px; }

.btn {
  appearance: none;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 10px 18px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.05s;
}

.btn:hover { background: var(--color-surface-2); }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}
.btn-primary:hover { background: var(--color-primary-dark); }

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.result-box {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 14px 16px;
  font-size: 1.05rem;
  margin-top: 8px;
  word-break: break-word;
}

.result-box.big { font-size: 1.5rem; font-weight: 700; }

.mono { font-family: var(--mono); font-size: 0.9em; }

.notice {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-primary);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 0.9rem;
  margin: 14px 0;
}

/* ---------- Tabs ---------- */

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.tab-btn {
  border: none;
  background: none;
  font: inherit;
  font-weight: 600;
  color: var(--color-text-muted);
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab-btn.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Misc ---------- */

.copy-btn { margin-top: 8px; }

.qr-canvas { background: #fff; padding: 8px; border: 1px solid var(--color-border); border-radius: 8px; max-width: 240px; }

.consent-placeholder {
  border: 2px dashed var(--color-warning);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin: 12px 0;
}

/* ---------- Consent-Banner (CMO-Deliverable THI-21) ---------- */
#consent-banner { font-family: var(--font); }
.consent-banner {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 9999;
  background: #1e293b; color: #f8fafc; box-shadow: 0 -4px 16px rgba(0,0,0,.25);
  padding: 14px 18px; font-size: 14px; line-height: 1.45;
}
.consent-banner-inner { max-width: 1100px; margin: 0 auto; display: flex;
  gap: 16px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.consent-banner p { margin: 0; max-width: 720px; }
.consent-banner a { color: #93c5fd; }
.consent-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.consent-btn { border: 0; border-radius: 8px; padding: 9px 14px; font-size: 14px;
  cursor: pointer; font-weight: 600; }
.consent-btn-accept { background: #2563eb; color: #fff; }
.consent-btn-necessary { background: #334155; color: #e2e8f0; }
.consent-btn-settings { background: transparent; color: #cbd5e1; border: 1px solid #64748b; }
.consent-dialog { position: fixed; inset: 0; z-index: 10000; background: rgba(15,23,42,.6);
  display: none; align-items: center; justify-content: center; padding: 16px; }
.consent-dialog.open { display: flex; }
.consent-dialog-card { background: #fff; color: #0f172a; max-width: 560px; width: 100%;
  border-radius: 12px; padding: 22px; }
.consent-dialog-card h3 { margin-top: 0; }
.consent-row { display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid #e2e8f0; gap: 12px; }
.consent-row strong { display: block; }
.consent-row span { font-size: 13px; color: #475569; display: block; margin-top: 2px; }
.consent-switch:disabled { opacity: .5; }
.consent-dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--color-primary);
  color: #fff;
  padding: 8px 12px;
  z-index: 100;
}
.skip-link:focus { left: 8px; top: 8px; }

@media print {
  .site-header, .site-footer, .breadcrumb, .btn { display: none; }
}
