/* Brava — mobile-first. Same ink and Typekit kit as Linkplant and Grid. */

:root {
  --ink: #272e45;
  --ink-60: rgba(39, 46, 69, 0.6);
  --ink-30: rgba(39, 46, 69, 0.3);
  --ink-12: rgba(39, 46, 69, 0.12);
  --paper: #fdfbf6;
  --gold: #ffc32b;
  --radius: 12px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "soleil", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
}

.wordmark {
  margin: 0;
  font-family: "etna-condensed", sans-serif;
  font-weight: 600;
  font-size: 34px;
  letter-spacing: -0.5px;
  line-height: 1;
}

.wordmark-initial {
  font-family: "feline", cursive;
  font-weight: 400;
}

.ghost-btn {
  border: 1.5px solid var(--ink-30);
  background: none;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
}

.ghost-btn:active { background: var(--ink-12); }

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

.stage {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--paper);
  padding: 4px 20px 14px;
  border-bottom: 1px solid var(--ink-12);
}

.stage-inner {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: min(42vh, 380px);
}

/* The checkerboard lives on the canvas itself, not the container, so what you
   see is exactly what exports, edge to edge — and the transparency is never in
   doubt. Its tone flips with the colour mode, because a white overlay on a pale
   backdrop is invisible exactly when you need the preview most. */
#preview {
  display: block;
  /* The canvas is cropped to its contents, so its aspect ratio changes with
     whatever is in the stack. Cap both axes and let it size itself. */
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: min(42vh, 380px);
  border-radius: var(--radius);
  border: 1px solid var(--ink-12);
  --sq: 9px;
  --check-a: #4a4a52;
  --check-b: #3a3a41;
  background-color: var(--check-a);
  background-image:
    linear-gradient(45deg, var(--check-b) 25%, transparent 25%, transparent 75%, var(--check-b) 75%),
    linear-gradient(45deg, var(--check-b) 25%, transparent 25%, transparent 75%, var(--check-b) 75%);
  background-size: calc(var(--sq) * 2) calc(var(--sq) * 2);
  background-position: 0 0, var(--sq) var(--sq);
}

.stage-inner.for-dark #preview {
  --check-a: #ffffff;
  --check-b: #e2ded4;
}

/* ---------- controls ---------- */

.controls {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.field { display: block; }

.field-row {
  display: flex;
  gap: 12px;
}

.field-row .field { flex: 1; }

.field-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.1px;
  text-transform: uppercase;
  color: var(--ink-60);
  margin-bottom: 8px;
}

.field-label b {
  color: var(--ink);
  font-family: "etna-condensed", sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

input[type="number"] {
  width: 100%;
  font: inherit;
  font-family: "etna-condensed", sans-serif;
  font-size: 24px;
  font-weight: 600;
  color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--ink-12);
  border-radius: var(--radius);
  padding: 12px 14px;
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

input:focus { outline: 2px solid var(--ink); outline-offset: -1px; }

/* segmented control */

.segmented {
  display: flex;
  background: var(--ink-12);
  border-radius: var(--radius);
  padding: 3px;
  gap: 3px;
}

.seg {
  flex: 1;
  border: 0;
  background: none;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  color: var(--ink-60);
  padding: 10px 8px;
  border-radius: 9px;
  cursor: pointer;
}

.seg.is-on {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(39, 46, 69, 0.14);
}

/* chips */

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  border: 1.5px solid var(--ink-12);
  background: #fff;
  color: var(--ink-60);
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  padding: 9px 14px;
  border-radius: 999px;
  cursor: pointer;
}

.chip.is-on {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

/* upload */

.upload {
  display: block;
  position: relative;
  border: 1.5px dashed var(--ink-30);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  font-weight: 600;
  font-size: 14px;
  color: var(--ink-60);
  background: #fff;
  cursor: pointer;
}

.upload input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload.has-cover {
  border-style: solid;
  border-color: var(--ink);
  color: var(--ink);
}

/* range */

input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  background: none;
  height: 32px;
  margin: 0;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: var(--ink-12);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 28px;
  height: 28px;
  margin-top: -12px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid var(--ink);
}

input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: var(--ink-12);
}

input[type="range"]::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid var(--ink);
}

/* stack order list */

.stack-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stack-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1.5px solid var(--ink-12);
  border-radius: var(--radius);
  padding: 10px 10px 10px 14px;
  font-size: 14px;
  font-weight: 600;
}

.stack-list li span { flex: 1; }

.move {
  border: 0;
  background: var(--ink-12);
  color: var(--ink);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.move:disabled { opacity: 0.3; cursor: default; }

/* export */

.primary-btn {
  width: 100%;
  border: 0;
  background: var(--ink);
  color: #fff;
  font: inherit;
  font-weight: 600;
  font-size: 17px;
  padding: 17px;
  border-radius: var(--radius);
  cursor: pointer;
}

.primary-btn:active { opacity: 0.85; }

.export { display: flex; flex-direction: column; gap: 10px; }

.text-btn {
  border: 0;
  background: none;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  color: var(--ink-60);
  padding: 6px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.export .note {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--ink-60);
  text-align: center;
}

/* ---------- library ---------- */

.library {
  padding: 4px 20px 32px;
  border-top: 1px solid var(--ink-12);
  margin-top: 8px;
}

.section-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.1px;
  text-transform: uppercase;
  color: var(--ink-60);
  margin: 20px 0 12px;
}

.thumbs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 10px;
}

.thumbs button {
  display: block;
  width: 100%;
  aspect-ratio: 215.789 / 328;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 10px;
  overflow: hidden;
  background: var(--ink-12);
  cursor: pointer;
}

.thumbs button.is-current { border-color: var(--ink); }

.thumbs img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: 999px;
  z-index: 20;
  max-width: calc(100vw - 40px);
  text-align: center;
}

[hidden] { display: none !important; }

/* ---------- desktop ---------- */

@media (min-width: 720px) {
  body {
    max-width: 560px;
    margin: 0 auto;
    border-left: 1px solid var(--ink-12);
    border-right: 1px solid var(--ink-12);
    min-height: 100vh;
  }
  #preview { height: 46vh; max-height: 460px; }
}
