/* Hoist — shared styles for generator and explainer. */

:root {
  /* Soft sage — toned-down, low-glare page chrome. The preview swatches
     stay true #fff / #111 (set on .swatch-light / .swatch-dark) so the
     badge is always shown against real backgrounds, not the page tint. */
  --ink: #232a24;
  --paper: #e7ebe2;
  --muted: #5c665a;
  --rule: #d0d7c9;
  --field-bg: #f4f7f0;
  --accent: #6d28d9;        /* 4.5:1+ on --paper */
  --focus: #1d4ed8;
}

* { box-sizing: border-box; }

body {
  margin: 0 auto;
  padding: 0 1rem 3rem;
  max-width: 56rem;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
}

header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  justify-content: space-between;
  align-items: baseline;
  padding: 1rem 0;
  border-bottom: 1px solid var(--rule);
}

.brand { margin: 0; font-size: 1.1rem; }

h1 { font-size: 1.7rem; margin: 1.2rem 0 0.4rem; }
h2 { font-size: 1.15rem; margin: 0 0 0.5rem; }
h3 { font-size: 1.05rem; }

.lede { color: var(--muted); max-width: 44rem; margin-top: 0; }

a { color: var(--accent); }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ----- generator layout ----- */

.generator {
  display: grid;
  grid-template-columns: minmax(16rem, 22rem) 1fr;
  gap: 2rem;
  margin-top: 1.5rem;
}

@media (max-width: 44rem) {
  .generator { grid-template-columns: 1fr; }
}

/* ----- form ----- */

#controls { display: flex; flex-direction: column; gap: 1.1rem; }

.field { display: flex; flex-direction: column; gap: 0.25rem; }

.field > label, legend { font-weight: 600; }

fieldset {
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 0.6rem 0.8rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0;
}

select, input[type="url"], input[type="text"], textarea {
  font: inherit;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--muted);
  border-radius: 4px;
  background: var(--field-bg);
  color: var(--ink);
}

input[type="url"]:disabled {
  background: #eee;
  color: var(--muted);
}

.sizes { flex-direction: row; flex-wrap: wrap; gap: 0.5rem 1rem; }

.sizes label { white-space: nowrap; }

.hint { margin: 0.15rem 0 0; font-size: 0.85rem; color: var(--muted); }

/* ----- preview ----- */

.result { display: flex; flex-direction: column; gap: 1.5rem; }

.swatches { display: flex; gap: 1rem; flex-wrap: wrap; }

.swatches figure { margin: 0; }

.swatch {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 11rem;
  min-height: 8rem;
  padding: 1rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
}

.swatch-light { background: #fff; }
.swatch-dark  { background: #111; }

figcaption { font-size: 0.85rem; color: var(--muted); text-align: center; }

/* ----- output ----- */

#output {
  width: 100%;
  font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
  font-size: 0.82rem;
  resize: vertical;
}

.output-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.4rem;
}

button {
  font: inherit;
  font-weight: 600;
  padding: 0.45rem 1rem;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

button:hover { filter: brightness(1.12); }

#charcount { font-size: 0.85rem; color: var(--muted); }

#copy-status { min-height: 1.4em; margin: 0.3rem 0 0; font-size: 0.9rem; }

.error {
  border: 1px solid #b91c1c;
  border-radius: 6px;
  background: #fef2f2;
  color: #7f1d1d;
  padding: 0.7rem 1rem;
}

/* ----- explainer ----- */

.flag-entry {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding: 1rem 0;
  border-bottom: 1px solid var(--rule);
}

.flag-entry img { flex-shrink: 0; margin-top: 0.3rem; }

.flag-entry h3 { margin: 0 0 0.3rem; }

.flag-entry p { margin: 0 0 0.3rem; }

.license-line { font-size: 0.85rem; color: var(--muted); }

.flags-cta { margin-top: 1.2rem; }

table { border-collapse: collapse; }

th, td {
  text-align: left;
  padding: 0.35rem 0.9rem 0.35rem 0;
  border-bottom: 1px solid var(--rule);
}

footer {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font-size: 0.9rem;
  color: var(--muted);
}
