/* ── Variables ──────────────────────────────────────────────────── */
:root {
  --flame-dark:   #a2532f;
  --flame-mid:    #c1683f;
  --flame-light:  #d99566;
  --bg:           #faf7f1;
  --bg-panel:     #f2ecdf;
  --bg-card:      #ffffff;
  --bg-input:     #f5f0e6;
  --border:       #e3ddcc;
  --border-dim:   #ece5d4;
  --text:         #2b2e28;
  --text-dim:     #565b4f;
  --text-muted:   #8a8f80;
  --accent:       #c1683f;
  --accent-hover: #a2532f;
  --weak:         #ef4444;
  --fair:         #f59e0b;
  --strong:       #22c55e;
  --radius:       12px;
  --radius-sm:    8px;
}

/* ── Reset & Base ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; }

body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
}

/* ── Header ─────────────────────────────────────────────────────── */
#app-header {
  background: linear-gradient(135deg, var(--flame-dark) 0%, var(--flame-mid) 50%, var(--flame-light) 100%);
  border-bottom: 1px solid rgba(0,0,0,0.3);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  text-decoration: none;
}

.brand > div {
  min-width: 0;
}

.brand img {
  height: 2.5rem;
  width: 2.5rem;
  object-fit: contain;
}

.brand-name {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #fff;
  line-height: 1.2;
}

.brand-tagline {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.65);
  letter-spacing: 0.03em;
}

/* ── Main ───────────────────────────────────────────────────────── */
main {
  flex: 1;
  padding: 1.5rem;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

/* ── Accessibility toolbar ────────────────────────────────────────── */
#a11y-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  margin-top: 1rem;
}

.a11y-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.a11y-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-right: 0.15rem;
}

.a11y-btn {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.7rem;
  font-family: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.a11y-btn:hover { background: #ece5d4; border-color: var(--accent); }
.a11y-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.a11y-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); }

.a11y-btn-wide { padding: 0.35rem 1rem; }

/* ── Generator layout ─────────────────────────────────────────────── */
#generator-screen {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.5rem;
  align-items: start;
  margin-top: 1rem;
}

@media (max-width: 900px) {
  #generator-screen { grid-template-columns: 1fr; }
}

.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.editor-header span {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ── Password box ──────────────────────────────────────────────────
   #password-box and #controls-panel accept a --fs custom property
   (set via JS) to scale their text independently of the rest of the
   page — this backs the font-size buttons. Elements outside these
   two containers never have --fs set, so var(--fs, 1) simply falls
   back to 1 and their size is unaffected. */
#password-box { display: flex; flex-direction: column; gap: 0; border-radius: var(--radius); }

#password-display {
  background: var(--bg-panel);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius);
  padding: 1.25rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

#password-output {
  flex: 1;
  min-width: 0;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: calc(1.25rem * var(--fs, 1));
  letter-spacing: 0.03em;
  color: var(--text);
  word-break: break-all;
  user-select: all;
}

#copy-btn {
  width: auto;
  flex-shrink: 0;
  padding: 0.6rem 1.25rem;
}

#copy-btn.copied { background: var(--strong); color: #06210f; }

/* ── Strength meter ─────────────────────────────────────────────── */
#strength-row { margin-top: 1rem; }

#strength-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--bg-input);
  overflow: hidden;
}

#strength-fill {
  height: 100%;
  width: 0%;
  background: var(--weak);
  border-radius: 999px;
  transition: width 0.2s ease, background 0.2s ease;
}

/* ── Generate button ────────────────────────────────────────────── */
#generate-btn { margin-top: 1.25rem; }

/* ── SEO content block ──────────────────────────────────────────── */
.seo-block { text-align: center; margin-top: 2.5rem; }

.seo-block h1 {
  font-family: Georgia, 'Iowan Old Style', 'Palatino Linotype', serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.75rem;
}

.seo-block p {
  font-size: 0.825rem;
  color: var(--text-dim);
  line-height: 1.7;
  max-width: 520px;
  margin: 0 auto 1rem;
}

.network-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
}

.network-chips span {
  font-size: 0.7rem;
  padding: 0.2rem 0.75rem;
  border-radius: 999px;
  background: var(--bg-card);
  color: var(--text-dim);
  border: 1px solid var(--border-dim);
}

/* ── Controls panel ─────────────────────────────────────────────── */
#controls-panel {
  background: #ffffff;
  border: 1px solid #e3ddcc;
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.ctrl-section { display: flex; flex-direction: column; gap: 0.6rem; }

.ctrl-label {
  font-size: calc(0.65rem * var(--fs, 1));
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

hr.ctrl-divider { border: none; border-top: 1px solid var(--border-dim); }

/* ── Form elements ──────────────────────────────────────────────── */
input[type="number"] {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  font-size: calc(0.8rem * var(--fs, 1));
  font-family: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  transition: border-color 0.15s;
}

input[type="number"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(193,104,63,0.25);
}

/* ── Range slider ───────────────────────────────────────────────── */
.range-header {
  display: flex;
  justify-content: space-between;
  font-size: calc(0.7rem * var(--fs, 1));
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.range-header .range-val { color: var(--accent); font-family: monospace; }

input[type="range"] {
  width: 100%;
  height: 4px;
  background: var(--bg-input);
  border-radius: 999px;
  border: none;
  accent-color: var(--accent);
  padding: 0;
  cursor: pointer;
}

.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: calc(0.65rem * var(--fs, 1));
  color: var(--text-muted);
  margin-top: 0.2rem;
  margin-bottom: 0.6rem;
}

/* ── Checkboxes ─────────────────────────────────────────────────── */
.check-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: calc(0.8rem * var(--fs, 1));
  color: var(--text-dim);
}

.check-option input[type="checkbox"] {
  width: auto;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
  width: 100%;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  border: none;
  font-size: calc(0.8rem * var(--fs, 1));
  font-family: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.btn-secondary {
  background: var(--bg-input);
  color: var(--text-dim);
}

.btn-secondary:hover { background: #ece5d4; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  box-shadow: 0 4px 20px rgba(193,104,63,0.35);
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Utility ─────────────────────────────────────────────────────── */
[hidden] { display: none !important; }

.crop-hint {
  font-size: calc(0.7rem * var(--fs, 1));
  color: var(--weak);
  margin-top: 0.25rem;
}

/* ── High-contrast light mode (scoped to password box & controls box) ──
   Toggled via body.a11y-light — the rest of the page stays dark. */
body.a11y-light #password-box {
  background: #ffffff;
  border: 2px solid #000;
  padding: 1rem;
  gap: 0.75rem;
}

body.a11y-light #controls-panel {
  background: #ffffff;
  border: 2px solid #000;
}

body.a11y-light #password-display {
  background: #ffffff;
  border: none;
  padding: 0;
}

body.a11y-light #strength-row { margin-top: 0; }

body.a11y-light #password-output { color: #000; }

body.a11y-light #copy-btn {
  background: #000;
  color: #fff;
}
body.a11y-light #copy-btn:hover { background: #262626; }
body.a11y-light #copy-btn.copied { background: #15803d; color: #fff; }

body.a11y-light #strength-bar {
  background: #d4d4d4;
  border: 1px solid #000;
}

body.a11y-light #password-box .range-header span,
body.a11y-light #controls-panel .range-header span,
body.a11y-light #controls-panel .ctrl-label,
body.a11y-light #controls-panel .range-labels span,
body.a11y-light #controls-panel .check-option {
  color: #000;
}

body.a11y-light #password-box .range-val,
body.a11y-light #controls-panel .range-val {
  color: #1d4ed8;
}

body.a11y-light #controls-panel input[type="number"] {
  background: #ffffff;
  color: #000;
  border: 2px solid #000;
}

body.a11y-light #controls-panel input[type="range"] {
  background: #d4d4d4;
  accent-color: #000;
}

body.a11y-light #controls-panel .check-option input[type="checkbox"] {
  accent-color: #000;
  outline: 1px solid #000;
  outline-offset: 1px;
}

body.a11y-light #options-warning { color: #b91c1c; }

/* ── Sticky global header ─────────────────────────────────────── */
.global-header {
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0.85rem 1.5rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.global-header a {
  font-family: Georgia, 'Iowan Old Style', 'Palatino Linotype', serif;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
  text-decoration: none;
}

.global-header a:hover {
  color: var(--accent);
}
