/* ============================================================
   GRUMPY DZYNRZ TOOLS — main.css
   Default: Dark theme (Off-Black bg, Bone text)
   Toggle:  body.theme-light switches to light
   Jonquil yellow = accent only — btn-primary, max 5–10%
   ============================================================ */

/* ── BRAND TOKENS (never change) ── */
:root {
  --off-black:   #1A1A1A;
  --cool-gray:   #999999;
  --jonquil:     #F7D000;
  --eerie-black: #242424;
  --bone:        #F5F5F5;
  --white:       #FFFFFF;

  --green:       #34A853;
  --red:         #EA4335;

  --font:        Arial, sans-serif;
  --font-mono:   'Courier New', Courier, monospace;
  --max-width:   920px;
  --topbar-h:    52px;
  --radius:      6px;
  --radius-pill: 999px;
  --transition:  0.13s ease;
}

/* ── DARK THEME (default) ── */
:root {
  --bg:           #1A1A1A;
  --surface:      #242424;
  --surface-2:    #2e2e2e;
  --surface-3:    #383838;
  --border:       #333333;
  --border-mid:   #444444;

  --text-primary: #F5F5F5;
  --text-muted:   #999999;
  --text-faint:   #555555;
  --text-on-dark: #F5F5F5;

  --input-bg:     #2e2e2e;
  --input-border: #444444;

  --shadow:       0 2px 12px rgba(0,0,0,0.4);
  --shadow-sm:    0 1px 4px rgba(0,0,0,0.3);
}

/* ── LIGHT THEME (:root.theme-light on <html>) ── */
:root.theme-light {
  --bg:           #F5F5F5;
  --surface:      #FFFFFF;
  --surface-2:    #F0F0F0;
  --surface-3:    #E8E8E8;
  --border:       #E0E0E0;
  --border-mid:   #CCCCCC;

  --text-primary: #242424;
  --text-muted:   #666666;
  --text-faint:   #AAAAAA;
  --text-on-dark: #F5F5F5;

  --input-bg:     #FFFFFF;
  --input-border: #E0E0E0;

  --shadow:       0 2px 10px rgba(0,0,0,0.09);
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.07);
}

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 13px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition), color var(--transition);
  display: flex;
  flex-direction: column;
}
a { color: var(--text-primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--cool-gray); }
img, svg { display: block; }
img { max-width: 100%; }
input, select, button, textarea { font-family: inherit; }

/* ── TYPOGRAPHY ── */
h1 { font-size: 20px; font-weight: bold; color: var(--text-primary); }
h2 { font-size: 16px; font-weight: bold; color: var(--text-primary); }
h3 { font-size: 14px; font-weight: bold; color: var(--text-primary); }

code, .mono {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--border);
  color: var(--text-primary);
}

/* ── LAYOUT ── */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin-inline: auto;
  padding-inline: 24px;
}
.page-main { padding-bottom: 48px; flex: 1; }

/* ============================================================
   TOPBAR — always Off-Black regardless of theme
   ============================================================ */
.site-header {
  background: var(--off-black);
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid #2e2e2e;
}
.site-header .inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}
.site-logo {
  color: var(--bone);
  font-size: 14px;
  font-weight: bold;
  letter-spacing: 0.4px;
}
.site-logo span {
  color: #666;
  font-weight: normal;
  font-size: 12px;
  margin-left: 8px;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Header pill buttons (back link, CRM link, theme toggle) */
.back-link,
.crm-chip,
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: 1px solid #333;
  color: #888;
  font-size: 11px;
  font-weight: bold;
  padding: 5px 14px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
  letter-spacing: 0.3px;
  text-decoration: none;
  white-space: nowrap;
  /* Reset browser button defaults */
  appearance: none;
  -webkit-appearance: none;
  line-height: 1;
  font-family: var(--font);
}
.back-link:hover,
.crm-chip:hover,
.theme-toggle:hover {
  border-color: #888;
  color: var(--bone);
}
.back-link svg { width: 12px; height: 12px; flex-shrink: 0; }

/* ============================================================
   PAGE HERO
   ============================================================ */
.page-hero {
  background: var(--surface);
  padding: 28px 24px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  margin-left: -24px;
  margin-right: -24px;
}
.page-hero .label {
  font-size: 10px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-faint);
  margin-bottom: 4px;
}
.page-hero h1 { margin-bottom: 4px; }
.page-hero p  { color: var(--text-muted); font-size: 12px; max-width: 560px; }

/* ============================================================
   CARD
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 12px;
}
.card-title {
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  margin-bottom: 16px;
}

/* ============================================================
   FORM ELEMENTS
   ============================================================ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}
.form-group:last-child { margin-bottom: 0; }
.form-group label {
  font-size: 11px;
  font-weight: bold;
  color: var(--text-muted);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

.input-wrap   { position: relative; }
.input-suffix {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-faint);
  pointer-events: none;
  user-select: none;
}

input[type="number"],
input[type="text"],
input[type="email"],
input[type="url"],
select,
textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 12px;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}
input[type="number"]:focus,
input[type="text"]:focus,
input[type="email"]:focus,
select:focus,
textarea:focus {
  border-color: var(--cool-gray);
  box-shadow: 0 0 0 2px rgba(153,153,153,0.15);
}
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { opacity: 0.4; }
input.has-suffix { padding-right: 32px; }

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7' viewBox='0 0 12 7'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23999' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  cursor: pointer;
}
select option { background: var(--surface-2); color: var(--text-primary); }

input[type="range"] {
  width: 100%;
  height: 4px;
  background: var(--border-mid);
  border-radius: var(--radius-pill);
  border: none;
  padding: 0;
  cursor: pointer;
  accent-color: var(--cool-gray);
  margin-top: 6px;
}
input[type="range"]:focus { outline: none; box-shadow: none; }

/* ============================================================
   BUTTONS — all pill-shaped
   Yellow = btn-primary only
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 20px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  border: none;
  transition: opacity var(--transition);
  white-space: nowrap;
  letter-spacing: 0.3px;
}
.btn:hover { opacity: 0.8; }
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.btn-sm   { padding: 5px 14px; font-size: 11px; }
.btn-full { width: 100%; }

/* PRIMARY — yellow, used sparingly */
.btn-primary { background: var(--jonquil); color: var(--eerie-black); }

/* SECONDARY — quiet, uses surface colors */
.btn-secondary {
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border-mid);
}

/* GHOST — no fill, just a border */
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-mid);
}
.btn-ghost:hover { border-color: var(--cool-gray); color: var(--text-primary); opacity: 1; }

/* DANGER */
.btn-danger { background: var(--red); color: var(--bone); }

/* ICON BUTTON — functional, not decorative */
.btn-icon {
  padding: 7px 10px;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-pill);
}
.btn-icon:hover { background: var(--surface-3); border-color: var(--cool-gray); color: var(--text-primary); opacity: 1; }
.btn-icon:disabled { opacity: 0.3; cursor: not-allowed; pointer-events: none; }

/* ============================================================
   OUTPUT BOX
   ============================================================ */
.output-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  word-break: break-all;
  min-height: 42px;
  display: flex;
  align-items: center;
  color: var(--text-primary);
  transition: border-color var(--transition), background var(--transition);
}
.output-box.has-value {
  cursor: copy;
  border-color: var(--cool-gray);
  background: var(--surface);
  color: var(--text-primary);
  font-weight: bold;
}
.output-box.has-value:hover { border-color: var(--bone); }
.output-box.is-empty {
  color: var(--text-faint);
  font-family: var(--font);
  font-size: 12px;
  font-style: italic;
}
.output-box.is-error {
  color: var(--red);
  font-family: var(--font);
  font-size: 12px;
}
.output-row { display: flex; align-items: stretch; gap: 8px; }
.output-row .output-box { flex: 1; }

/* ============================================================
   TOOL INDEX — Card grid
   ============================================================ */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
}
.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-decoration: none;
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.tool-card:hover {
  border-color: var(--cool-gray);
  box-shadow: var(--shadow);
  color: var(--text-primary);
}
.tool-card .tool-icon {
  width: 36px;
  height: 36px;
  background: var(--surface-3);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  margin-bottom: 4px;
  flex-shrink: 0;
  border: 1px solid var(--border-mid);
}
.tool-card .tool-icon svg { width: 18px; height: 18px; }
.tool-card .tool-name  { font-weight: bold; font-size: 13px; color: var(--text-primary); }
.tool-card .tool-desc  { font-size: 11px; color: var(--text-muted); line-height: 1.5; flex: 1; }
.tool-card .tool-arrow {
  margin-top: 6px;
  font-size: 11px;
  font-weight: bold;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  gap: 4px;
  letter-spacing: 0.2px;
  transition: color var(--transition);
}
.tool-card:hover .tool-arrow { color: var(--text-primary); }
.tool-card .tool-arrow svg { width: 11px; height: 11px; }

/* ============================================================
   INFO PILLS & STATE CHIPS
   ============================================================ */
.info-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.info-pill {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 2px 9px;
}

.state-chip {
  font-size: 10px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
}
/* Fluid — neutral, just surfaced */
.state-fluid { background: var(--surface-2); color: var(--text-muted);  border: 1px solid var(--border-mid); }
/* At min — faint, clamped low */
.state-min   { background: var(--surface-2); color: var(--text-faint);  border: 1px solid var(--border); }
/* At max — bone/cool-gray, clamped high */
.state-max   { background: var(--surface-3); color: var(--text-primary); border: 1px solid var(--border-mid); }

/* ============================================================
   MATH BREAKDOWN
   ============================================================ */
.breakdown {
  margin-top: 12px;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 11px;
  color: var(--text-muted);
  line-height: 2;
}
.breakdown strong { color: var(--text-primary); font-family: var(--font-mono); }

.breakdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: bold;
  color: var(--text-faint);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  margin-top: 12px;
  letter-spacing: 0.2px;
  transition: color var(--transition);
}
.breakdown-toggle:hover { color: var(--text-primary); }
.breakdown-toggle svg { transition: transform 0.2s ease; flex-shrink: 0; }
.breakdown-toggle.open svg { transform: rotate(180deg); }

/* ============================================================
   MISC COMPONENTS
   ============================================================ */
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: bold;
  letter-spacing: 0.3px;
}
.badge-neutral { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.badge-success { background: rgba(52,168,83,0.15); color: #6fcf97; }
.badge-error   { background: rgba(234,67,53,0.15); color: #eb7b74; }

.hint { font-size: 11px; color: var(--text-faint); margin-top: 6px; }

.section-label {
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.back-link-footer { display: flex; justify-content: center; margin-top: 32px; }

/* Standalone back link used outside the dark header (e.g. bottom of page) */
.back-link-light {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: 1px solid var(--border-mid);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: bold;
  padding: 5px 14px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
  letter-spacing: 0.3px;
  text-decoration: none;
}
.back-link-light:hover { border-color: var(--cool-gray); color: var(--text-primary); }
.back-link-light svg { width: 12px; height: 12px; flex-shrink: 0; }

/* ============================================================
   TOAST
   ============================================================ */
.gd-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface-3);
  border: 1px solid var(--border-mid);
  color: var(--text-primary);
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: bold;
  z-index: 9999;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  box-shadow: var(--shadow);
}
.gd-toast.show { opacity: 1; transform: translateY(0); }
/* Checkmark — one justified use of yellow as a success signal */
.gd-toast .toast-icon { color: var(--jonquil); display: flex; align-items: center; }

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 18px 0;
  margin-top: 32px;
  text-align: center;
  color: var(--text-faint);
  font-size: 11px;
  background: var(--surface);
}
.site-footer a { color: var(--text-muted); }
.site-footer a:hover { color: var(--text-primary); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 640px) {
  .form-row,
  .form-row-3 { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .page-hero { padding: 20px 16px 16px; margin-left: -16px; margin-right: -16px; }
  .container { padding-inline: 16px; }
  .tool-grid { grid-template-columns: 1fr; }
}
