/* ============================================================
   Audio Terrain — minimal dark UI
   ============================================================ */

:root {
  --navy:   #05060f;
  --panel:  rgba(18, 22, 48, 0.55);
  --border: rgba(140, 160, 255, 0.18);
  --text:   #e7e9ff;
  --muted:  #8b90c0;
  --accent: #FFC07F; /* warm orange, this tool's identity color */
  /* instrument-readout mono, using whatever the OS ships */
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;          /* no pull-to-refresh / rubber-banding */
  background: var(--navy);
  color: var(--text);
  font-family: var(--mono);
  -webkit-font-smoothing: antialiased;
}

/* The 3D canvas fills the whole window */
#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;                 /* touch drags the camera, not the page */
}

.hidden { display: none !important; }

/* ---------- Brand card (top left): one click, straight home ---------- */
#brand {
  position: fixed;
  top: 28px;
  left: 32px;
  z-index: 30;             /* above the drop overlay, so the link is clickable */
  display: block;
  padding: 10px 16px 12px;
  background: #ececef;
  color: #0d0e12;
  border-radius: 2px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  text-decoration: none;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: background 0.18s ease;
}
#brand:hover { background: #ffffff; }
#brand span {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.18em;
  text-transform: lowercase;
  color: #6a6b73;
}

/* ---------- Tool tag (bottom left): name + what it does ---------- */
#tool-tag {
  position: fixed;
  left: 32px;
  bottom: 26px;
  z-index: 5;
  padding: 10px 14px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: 2px;
  pointer-events: none;
  user-select: none;
}
#tool-tag strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text);
}
#tool-tag span {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
}

/* ---------- Drop / upload hint ---------- */
#drop-hint {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: opacity 0.4s ease;
}
#drop-hint.dragover .drop-inner {
  border-color: var(--accent);
  background: rgba(255, 192, 127, 0.08);
  transform: scale(1.02);
}
.drop-inner {
  position: relative;
  text-align: center;
  padding: 54px 72px;
  border: 1.5px dashed var(--border);
  border-radius: 2px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: all 0.25s ease;
}
.drop-inner .big {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 500;
  color: var(--text);
}
.drop-inner .small {
  margin: 10px 0;
  color: var(--muted);
  font-size: 13px;
}
.drop-inner .formats {
  margin: 22px 0 0;
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--muted);
}
.upload-btn {
  display: inline-block;
  cursor: pointer;
  padding: 11px 26px;
  border-radius: 2px;
  font-size: 14px;
  font-weight: 500;
  color: var(--navy);
  background: var(--accent);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  box-shadow: 0 6px 24px rgba(255, 192, 127, 0.25);
}
.upload-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 30px rgba(255, 192, 127, 0.35);
}

/* ---------- Status line ---------- */
#status {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 20;
  padding: 16px 28px;
  border-radius: 2px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  font-size: 14px;
  color: var(--text);
  text-align: center;
}
#status.error { color: #ff8a8a; border-color: rgba(255, 138, 138, 0.4); }

/* ---------- Transport bar ---------- */
#transport {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  width: min(680px, calc(100vw - 48px));
  border-radius: 2px;
  background: var(--panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

#transport button,
#transport .new-file {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  cursor: pointer;
  transition: background 0.18s ease;
}
#transport button:hover,
#transport .new-file:hover { background: rgba(255, 255, 255, 0.14); }

/* Fly mode engaged: the paper plane lights up */
#transport #fly-btn.active {
  background: var(--accent);
  color: var(--navy);
}

#transport svg { width: 20px; height: 20px; fill: currentColor; }

/* toggle play/pause icons */
.icon-pause { display: none; }
#transport.playing .icon-play  { display: none; }
#transport.playing .icon-pause { display: block; }

.time {
  flex: none;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--muted);
  width: 38px;
  text-align: center;
}

/* ---------- Side panels (print model + image synth) ---------- */
#print-panel, #image-panel {
  position: fixed;
  top: 90px;
  right: 28px;
  z-index: 10;
  width: 250px;
  padding: 18px 20px;
  border-radius: 2px;
  background: var(--panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}
#print-panel h2, #image-panel h2 {
  margin: 0 0 2px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text);
  border-left: 3px solid var(--accent);
  padding-left: 9px;
}
#print-panel .hint, #image-panel .hint {
  margin: 0 0 16px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
}
#print-panel .ctl, #image-panel .ctl { display: block; margin-bottom: 14px; }
#print-panel .ctl > span, #image-panel .ctl > span {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
#print-panel .ctl em, #image-panel .ctl em { color: var(--text); font-style: normal; }
#print-panel input[type="range"], #image-panel input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 5px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
  outline: none;
}
#print-panel input[type="range"]::-webkit-slider-thumb,
#image-panel input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 9px; height: 20px;
  border-radius: 3px;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(255, 192, 127, 0.25);
}

/* Notch marks under panel sliders (spans injected by ticks.js) */
.ticks {
  display: flex;
  justify-content: space-between;
  padding: 5px 3px 0;
}
.ticks span {
  width: 1px;
  height: 5px;
  background: rgba(140, 160, 255, 0.35);
}
#print-panel .dims {
  margin: 2px 0 14px;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
#print-export,
#image-panel button:not(.panel-close) {
  width: 100%;
  padding: 11px;
  border: none;
  border-radius: 2px;
  font-size: 14px;
  font-weight: 500;
  color: var(--navy);
  cursor: pointer;
  background: var(--accent);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  box-shadow: 0 6px 24px rgba(255, 192, 127, 0.2);
}
#print-export:hover,
#image-panel button:not(.panel-close):hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 30px rgba(255, 192, 127, 0.3);
}

/* Small X to dismiss a panel / the upload card (reveals the spectrogram) */
.panel-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  padding: 0;
  border: none;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}
.panel-close:hover { background: rgba(255, 255, 255, 0.16); color: var(--text); }

/* A checkbox row (Invert) */
#image-panel .ctl.checkbox {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
}
#image-panel .ctl.checkbox input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }
#image-panel .ctl.checkbox span { font-size: 12px; color: var(--muted); margin: 0; }

/* "Download audio" is a quieter, secondary button under "Regenerate" */
#image-panel #img-download.secondary {
  margin-top: 9px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: none;
}
#image-panel #img-download.secondary:hover {
  background: rgba(255, 255, 255, 0.16);
  box-shadow: none;
}

/* "or" divider + ghost upload button on the landing card */
.or-divider {
  margin: 20px 0 14px;
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--muted);
  text-transform: uppercase;
}
.upload-btn.ghost {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: none;
  border: 1px solid var(--border);
}
.upload-btn.ghost:hover {
  background: rgba(255, 255, 255, 0.14);
  box-shadow: none;
}

/* Dropdowns (view mode + color mode) */
#palette, #mode {
  flex: none;
  height: 40px;
  padding: 0 12px;
  border: none;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  transition: background 0.18s ease;
}
#palette:hover, #mode:hover { background: rgba(255, 255, 255, 0.14); }
#palette option, #mode option { background: #12162f; color: var(--text); }

/* Seek slider */
#seek {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 5px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
  outline: none;
}
#seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(255, 192, 127, 0.25);
  transition: box-shadow 0.15s ease;
}
#seek::-webkit-slider-thumb:hover { box-shadow: 0 0 0 6px rgba(255, 192, 127, 0.35); }
#seek::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border: none;
  border-radius: 50%;
  background: #fff;
}

/* ============================================================
   Responsive / mobile  (portrait + landscape, with notch insets)
   ============================================================ */

/* Keep UI clear of notches & home indicators on all screens */
#brand     { top: max(28px, env(safe-area-inset-top)); left: max(32px, env(safe-area-inset-left)); }
#transport { bottom: max(26px, env(safe-area-inset-bottom)); }

/* ---- Narrow / portrait phones ---- */
@media (max-width: 600px) {
  #brand { top: max(14px, env(safe-area-inset-top)); left: max(14px, env(safe-area-inset-left)); padding: 8px 12px 10px; font-size: 13px; }
  #tool-tag { display: none; }

  .drop-inner { padding: 34px 26px; max-width: 86vw; }
  .drop-inner .big { font-size: 17px; }

  /* Transport wraps to two rows: [play | time | seek | time] then the
     dropdowns + load button. (seek is flex:1 so it pushes them down.) */
  #transport {
    width: calc(100vw - 16px);
    bottom: max(10px, env(safe-area-inset-bottom));
    flex-wrap: wrap;
    gap: 8px;
    row-gap: 10px;
    padding: 10px 12px;
  }
  .time { width: 32px; }
  #mode, #palette { flex: 1 1 0; min-width: 0; font-size: 12px; padding: 0 8px; }

  /* Side panels move to a full-width strip below the title */
  #print-panel, #image-panel {
    top: 56px;
    bottom: auto;
    left: 8px;
    right: 8px;
    width: auto;
    padding: 12px 16px;
  }
  #print-panel .hint, #image-panel .hint { display: none; }
}

/* ---- Short landscape phones ---- */
@media (orientation: landscape) and (max-height: 500px) {
  #brand { top: max(8px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left)); padding: 7px 10px 8px; font-size: 12px; }
  #tool-tag { display: none; }

  #transport { bottom: max(8px, env(safe-area-inset-bottom)); padding: 8px 12px; gap: 10px; }

  /* Keep the side panels on the right but let them scroll if tall */
  #print-panel, #image-panel {
    top: max(8px, env(safe-area-inset-top));
    right: max(8px, env(safe-area-inset-right));
    max-height: calc(100% - 16px);
    overflow-y: auto;
  }
  #print-panel .hint, #image-panel .hint { display: none; }
}
