/* ==========================================================================
   Box Shadow: editor visual
   ========================================================================== */

@font-face { font-family: "Schibsted Grotesk"; src: url("../fonts/schibsted-grotesk-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Schibsted Grotesk"; src: url("../fonts/schibsted-grotesk-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Schibsted Grotesk"; src: url("../fonts/schibsted-grotesk-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("../fonts/jetbrains-mono-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }

:root {
  --ink: #151a23;
  --muted: #5b6475;
  --line: #dde2ea;
  --surface: #ffffff;
  --page: #f4f6f9;
  --cobalt: #2b5cff;
  --cobalt-soft: #e7edff;
  --code-bg: #151a23;
  --code-ink: #dfe6f3;

  --font: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;

  --radius: 10px;
  --gutter: clamp(1rem, 3vw, 2rem);
}

*,
*::before,
*::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 400 1rem/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

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

button { font: inherit; color: inherit; }

/* --- Cabeçalho ----------------------------------------------------------- */
.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 1.25rem;
  padding: 1.5rem var(--gutter) 1rem;
}
.masthead__title { margin: 0; font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; }
.masthead__lead { margin: 0; color: var(--muted); }
.masthead__link { margin-left: auto; color: var(--ink); font-weight: 500; text-underline-offset: 0.2em; }

/* --- Layout do editor ---------------------------------------------------- */
.editor {
  display: grid;
  gap: 1rem;
  padding: 0 var(--gutter) var(--gutter);
}
@media (min-width: 62rem) {
  .editor { grid-template-columns: 21rem minmax(0, 1fr); align-items: start; }
  .panel { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow: auto; }
}

/* No celular, a prévia vem primeiro */
@media (max-width: 61.99rem) {
  .workspace { order: -1; }
}

/* --- Painel -------------------------------------------------------------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.panel__group { padding: 1rem 1.25rem; }
.panel__group + .panel__group { border-top: 1px solid var(--line); }
.panel__row { display: flex; align-items: center; justify-content: space-between; }
.panel__title { margin: 0 0 0.75rem; font-size: 0.95rem; font-weight: 700; }
.panel__row .panel__title { margin: 0; }
.panel__actions { display: flex; gap: 0.25rem; }

.icon-button {
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}
.icon-button:hover:not(:disabled) { border-color: var(--ink); }
.icon-button:disabled { opacity: 0.4; cursor: not-allowed; }

.presets { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip {
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.875rem;
  cursor: pointer;
}
.chip:hover { border-color: var(--cobalt); color: var(--cobalt); }

.layers { display: grid; gap: 0.25rem; margin: 0.75rem 0 1rem; }
.layer {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.layer:hover { background: var(--page); }
.layer[aria-checked="true"] { background: var(--cobalt-soft); border-color: var(--cobalt); color: #12309c; font-weight: 500; }
.layer__swatch {
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 3px;
  background: var(--swatch);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}

/* --- Campos -------------------------------------------------------------- */
.fields { display: grid; gap: 0.85rem; }
.field label { display: block; margin-bottom: 0.3rem; font-size: 0.85rem; color: var(--muted); }
.field__pair { display: flex; align-items: center; gap: 0.5rem; }
.field__unit { width: 1.2rem; font-size: 0.8rem; color: var(--muted); }

.field input[type="range"] { flex: 1; min-width: 0; accent-color: var(--cobalt); }

.field__number,
.field__text {
  width: 4.25rem;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: 400 0.85rem var(--mono);
  color: var(--ink);
  background: var(--surface);
}
.field__text { width: 6rem; }

.field input[type="color"] {
  width: 2.5rem;
  height: 2rem;
  padding: 0.15rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
}

.toggle { display: flex !important; align-items: center; gap: 0.5rem; color: var(--ink) !important; cursor: pointer; }
.toggle input { width: 1rem; height: 1rem; accent-color: var(--cobalt); }

/* --- Palco: o centro da ferramenta --------------------------------------- */
.workspace { display: grid; gap: 1rem; min-width: 0; }

.stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: clamp(17rem, 58vh, 36rem);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  cursor: grab;
  touch-action: none; /* o arraste não rola a página no celular */
  user-select: none;
}
.stage.is-dragging { cursor: grabbing; }
.stage__box { width: clamp(9rem, 22vw, 15rem); aspect-ratio: 1; }
.stage__hint {
  position: absolute;
  bottom: 0.75rem;
  padding: 0 1rem;
  text-align: center;
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  pointer-events: none;
}

/* --- Código -------------------------------------------------------------- */
.output { min-width: 0; }
.output__bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.5rem; }
.output__actions { display: flex; gap: 0.5rem; }

.tabs { display: inline-flex; padding: 0.2rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.tab {
  padding: 0.35rem 0.85rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-size: 0.875rem;
  cursor: pointer;
}
.tab[aria-selected="true"] { background: var(--ink); color: #fff; }

.button {
  padding: 0.55rem 1rem;
  border: 1px solid var(--cobalt);
  border-radius: 8px;
  background: var(--cobalt);
  color: #fff;
  font-weight: 500;
  cursor: pointer;
}
.button:hover { background: #1f47d6; }
.button--quiet { background: var(--surface); color: var(--ink); border-color: var(--line); }
.button--quiet:hover { background: var(--page); border-color: var(--ink); }

.code {
  margin: 0;
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  background: var(--code-bg);
  color: var(--code-ink);
  font: 400 0.9rem/1.6 var(--mono);
  overflow-x: auto;
  white-space: pre;
}

.status { min-height: 1.5rem; margin: 0.5rem 0 0; font-size: 0.875rem; color: #12309c; }

/* --- Rodapé -------------------------------------------------------------- */
.footer { padding: 0 var(--gutter) 2rem; color: var(--muted); font-size: 0.875rem; }
.footer a { color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
