/* ==========================================================================
   Earendil Ray — app chrome
   The snippet frame itself is styled by SNIPPET_CSS in app.js so that the
   preview and the exports share one source of truth.
   ========================================================================== */

@font-face {
  font-family: 'Departure Mono';
  src: url('fonts/DepartureMono-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Commit Mono';
  src: url('fonts/CommitMono-400-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Commit Mono';
  src: url('fonts/CommitMono-400-Italic.woff2') format('woff2');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'PlantinNow';
  src: url('fonts/PlantinNowVariable-Italic.woff2') format('woff2-variations'),
       url('fonts/PlantinNowVariable-Italic.woff2') format('woff2');
  font-weight: 200 800;
  font-style: italic;
  font-display: swap;
}

:root {
  --cursor-star: url('assets/cursor-dark.svg') 12 12;
  --cursor-star-hover: url('assets/cursor-light.svg') 12 12;
  --mono: 'Departure Mono', 'SFMono-Regular', ui-monospace, monospace;
  --serif: 'PlantinNow', 'Plantin MT Pro', Georgia, serif;
  --app-bg: #eae5e1;
  --app-ink: #57504b;
  --app-ink-strong: #37322e;
  --app-ink-faint: rgba(87, 80, 75, 0.55);
  --chrome-inset: 44px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  background: var(--app-bg);
  color: var(--app-ink);
  font: 14px/1.4 var(--mono);
  cursor: var(--cursor-star), auto;
  overflow: hidden;
}

button, select, [contenteditable] { cursor: inherit; }

button:hover { cursor: var(--cursor-star-hover), pointer; }

::selection { background: rgba(87, 80, 75, 0.22); }

/* --------------------------------------------------------------------------
   Brand (top left)
   -------------------------------------------------------------------------- */

.brand {
  position: fixed;
  top: var(--chrome-inset);
  left: var(--chrome-inset);
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--app-ink-strong);
}

.brand-emblem {
  width: 46px;
  height: 35px;
  flex: 0 0 auto;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-name {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 450;
  font-size: 21px;
  line-height: 1;
  letter-spacing: 0.01em;
}

.brand-sub {
  font: 10px/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--app-ink-faint);
}

/* --------------------------------------------------------------------------
   Controls (top right) — click a label to cycle its value
   -------------------------------------------------------------------------- */

.controls {
  position: fixed;
  top: var(--chrome-inset);
  right: var(--chrome-inset);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.control {
  appearance: none;
  border: 0;
  background: none;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font: 13px/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--app-ink);
  transition: color 0.2s ease;
}

.control:hover { color: var(--app-ink-strong); }

.control-label { color: var(--app-ink-faint); transition: color 0.2s ease; }

.control:hover .control-label { color: var(--app-ink); }

.control-value {
  position: relative;
  color: inherit;
}

.control:hover .control-value::after {
  content: "";
  position: absolute;
  right: -20px;
  top: 50%;
  width: 13px;
  height: 13px;
  margin-top: -7px;
  background: currentColor;
  -webkit-mask: url('assets/cursor-light.svg') center/contain no-repeat;
  mask: url('assets/cursor-light.svg') center/contain no-repeat;
  animation: starSpin 0.85s linear infinite;
}

@keyframes starSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .control:hover .control-value::after { animation: none; }
}

/* Language picker: a real <select> stretched invisibly over the control */
.control--lang {
  position: relative;
}

.control--lang select {
  position: absolute;
  inset: -4px -8px;
  opacity: 0;
  font: inherit;
  width: calc(100% + 16px);
}

.control--lang:hover { color: var(--app-ink-strong); }
.control--lang:hover .control-label { color: var(--app-ink); }

/* --------------------------------------------------------------------------
   Stage
   -------------------------------------------------------------------------- */

.stage {
  position: fixed;
  inset: 0;
  z-index: 100;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 130px 60px 120px;
}

.stage > * {
  margin: auto; /* keeps the frame centered but scrollable when larger */
}

/* --------------------------------------------------------------------------
   Footer hint (bottom left) + exports (bottom right)
   -------------------------------------------------------------------------- */

.hint {
  position: fixed;
  bottom: var(--chrome-inset);
  left: var(--chrome-inset);
  z-index: 200;
  font: 11px/1.5 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--app-ink-faint);
  max-width: 40vw;
}

.exports {
  position: fixed;
  bottom: var(--chrome-inset);
  right: var(--chrome-inset);
  z-index: 200;
  display: flex;
  align-items: baseline;
  gap: 18px;
}

.exports-label {
  font: 11px/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--app-ink-faint);
  margin-right: 4px;
}

.export-btn {
  appearance: none;
  border: 0;
  background: none;
  font: 13px/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--app-ink);
  padding: 4px 0;
  border-bottom: 1px dotted rgba(87, 80, 75, 0.45);
  transition: color 0.2s ease, border-color 0.2s ease;
}

.export-btn:hover {
  color: var(--app-ink-strong);
  border-bottom-color: var(--app-ink-strong);
}

.export-btn:disabled {
  opacity: 0.4;
}

/* --------------------------------------------------------------------------
   Toast
   -------------------------------------------------------------------------- */

.toast {
  position: fixed;
  bottom: calc(var(--chrome-inset) + 40px);
  right: var(--chrome-inset);
  z-index: 210;
  font: 12px/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--app-bg);
  background: var(--app-ink-strong);
  padding: 9px 14px;
  border-radius: 3px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

/* --------------------------------------------------------------------------
   Small screens
   -------------------------------------------------------------------------- */

@media (max-width: 760px) {
  :root { --chrome-inset: 20px; }

  .controls {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-end;
    max-width: 60vw;
    gap: 8px 14px;
  }

  .stage { padding: 120px 20px 110px; }

  .hint { display: none; }
}
