/* Dinoloop Mobile — mobile1.css
   v1 — Look: chunky arcade keycaps on a grape-purple stage. Every colour is a
   sound: kick = tomato, snare = sun, hihat = aqua, bass = dino lime,
   vocal = bubblegum. */

:root {
  --grape: #2a1759;
  --grape-deep: #1a0e3d;
  --ink: #14082e;
  --cloud: #fff6e6;
  --cloud-d: #b9a98e;

  --kick: #ff4f5e;   --kick-d: #a82638;
  --snare: #ffc83d;  --snare-d: #b0800e;
  --hihat: #3fd9f2;  --hihat-d: #167f96;
  --bass: #86e04e;   --bass-d: #478e22;
  --vocal: #ff8ad8;  --vocal-d: #ad3f90;
  --fx: #b8a1ff;     --fx-d: #5a3fb0;
  --violet: #5b35c9; --violet-d: #2a1480;

  --gap: 12px;
  --edge: 9px;
  --w: 100%;
  --pulse: 0;
  --tension: 0;
  --drop: #ff7a1a;   --drop-d: #a8450a;

  font-family: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

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

html, body {
  margin: 0;
  overflow-x: hidden;          /* page now scrolls vertically so the footer is reachable */
  overscroll-behavior: none;
  background: var(--grape-deep);
  color: var(--cloud);
}
body {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

/* ---------- stage: background that breathes with the kick ---------- */
.stage {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(75% 42% at 50% 40%, rgba(255, 79, 94, calc(0.07 + var(--pulse) * 0.26 + var(--tension) * 0.3)), transparent 72%),
    radial-gradient(60% 30% at 50% 100%, rgba(63, 217, 242, 0.10), transparent 70%),
    linear-gradient(180deg, var(--grape), var(--grape-deep));
}

/* ---------- layout ---------- */
.app {
  position: relative;
  z-index: 1;
  height: 100vh;
  height: 100dvh;              /* the editor fills exactly the first screen */
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding:
    max(10px, env(safe-area-inset-top, 0px))
    max(14px, env(safe-area-inset-right, 0px))
    max(12px, env(safe-area-inset-bottom, 0px))
    max(14px, env(safe-area-inset-left, 0px));
}
.app > * { width: var(--w); flex: none; }
.app > .pads { flex: 1 1 0; }

.head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 46px;
}
.brand { display: flex; align-items: center; gap: 8px; }
.dino {
  display: block;
  width: 58px;
  height: 32px;
  transform-origin: 50% 90%;
  transform: rotate(calc(var(--pulse) * -7deg)) scale(calc(1 + var(--pulse) * 0.14));
}
.dino svg { display: block; width: 100%; height: 100%; }
.word {
  font-weight: 900;
  font-size: 1.7rem;
  letter-spacing: -0.045em;
  line-height: 1;
  color: var(--cloud);
}

.hright { display: flex; align-items: center; gap: 12px; }
.hbtn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 246, 230, 0.14);
  color: var(--cloud);
  cursor: pointer;
}
.hbtn:active { background: rgba(255, 246, 230, 0.3); }
.hbtn svg { width: 20px; height: 20px; }

/* loop position: four bars, filling one after the other */
.bars { display: flex; gap: 5px; }
.bars i {
  --f: 0;
  display: block;
  width: 24px;
  height: 9px;
  border-radius: 9px;
  background: rgba(255, 246, 230, 0.16);
  overflow: hidden;
  position: relative;
}
.bars i::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--cloud);
  border-radius: inherit;
  transform-origin: 0 50%;
  transform: scaleX(var(--f));
}

.viz { height: 38px; display: block; }

/* ---------- keycaps ---------- */
.key {
  --c: var(--cloud);
  --d: var(--cloud-d);
  --r: 28px;
  position: relative;
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: var(--r);
  background: var(--d);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  box-shadow: 0 12px 20px rgba(6, 1, 26, 0.38);
  outline: none;
}
.key:focus-visible { box-shadow: 0 0 0 4px var(--cloud), 0 12px 20px rgba(6, 1, 26, 0.38); }
.cap {
  position: absolute;
  inset: 0 0 var(--edge) 0;
  border-radius: inherit;
  background: var(--c);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.5), inset 0 -5px 0 rgba(0, 0, 0, 0.07);
  transition: transform 0.07s ease-out;
  will-change: transform;
}
.key:active .cap { transform: translateY(calc(var(--edge) - 2px)); }
.key:disabled { cursor: default; opacity: 0.4; }
.key:disabled:active .cap { transform: none; }
.key svg { display: block; fill: none; }

.t-KICK  { --c: var(--kick);  --d: var(--kick-d); }
.t-SNARE { --c: var(--snare); --d: var(--snare-d); }
.t-HIHAT { --c: var(--hihat); --d: var(--hihat-d); }
.t-BASS  { --c: var(--bass);  --d: var(--bass-d); }
.t-VOCAL { --c: var(--vocal); --d: var(--vocal-d); }
.t-FX    { --c: var(--fx);    --d: var(--fx-d); }

/* ---------- sound boxes (6): grid fills the free height ---------- */
.pads {
  flex: 1 1 0 !important;
  min-height: 0;
  max-height: 400px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: var(--gap);
}
.pad {
  min-width: 0;
  min-height: 0;
  container-type: size;
  --r: 17%;
}
.pad .cap {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 8px 10px 8px 12px;
  text-align: left;
  overflow: hidden;
}
.pad:active .cap { transform: none; }
.pad:has(.hit:active) .cap { transform: translateY(calc(var(--edge) - 2px)); }
.hit {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  border-radius: inherit;
  cursor: pointer;
}
.pad .top, .pad .mid, .pad .namerow { position: relative; pointer-events: none; }
.ctl { position: relative; z-index: 2; pointer-events: auto; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.lbl {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 4px 6px 4px 0;
  margin: -4px 0;
  font-weight: 900;
  font-size: clamp(0.82rem, 9cqw, 1.08rem);
  letter-spacing: 0.02em;
  line-height: 1;
  cursor: pointer;
}
.lbl .caret { width: 0.9em; height: 0.9em; opacity: 0.6; flex: none; }
.lbl select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  font-size: 16px;
  border: 0;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.tools { display: flex; gap: 4px; margin: -4px -4px -4px 0; flex: none; }
.lock, .mute {
  flex: none;
  display: grid;
  place-items: center;
  width: clamp(26px, 17cqw, 34px);
  height: clamp(26px, 17cqw, 34px);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(20, 8, 46, 0.12);
  color: rgba(20, 8, 46, 0.7);
  cursor: pointer;
}
.lock svg, .mute svg { width: 58%; height: 58%; }
.pad.locked .lock, .pad.muted .mute { background: var(--ink); color: var(--c); }
.pad.muted .cap { filter: saturate(0.3) brightness(0.92); }
.pad.muted .num, .pad.muted .name { opacity: 0.45; }
.pad.locked .cap { box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.5), inset 0 0 0 3px var(--ink); }

.mid { display: flex; align-items: center; justify-content: space-between; gap: 2px; }
.arr {
  flex: none;
  display: grid;
  place-items: center;
  width: clamp(28px, 18cqw, 40px);
  height: clamp(28px, 18cqw, 40px);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(20, 8, 46, 0.12);
  color: var(--ink);
  cursor: pointer;
}
.arr:active { background: rgba(20, 8, 46, 0.28); }
.arr svg { width: 62%; height: 62%; }
.pad .num {
  font-weight: 900;
  font-size: 2.2rem;
  font-size: min(23cqw, 32cqh);
  line-height: 0.9;
  letter-spacing: -0.05em;
  font-variant-numeric: tabular-nums;
  text-align: center;
  white-space: nowrap;
}
.pad .num small { font-size: 0.34em; letter-spacing: 0; opacity: 0.55; margin-left: 3px; }
.pad .name {
  font-weight: 800;
  font-size: clamp(0.72rem, 8cqw, 0.95rem);
  line-height: 1.08;
  text-align: center;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  min-height: 1.08em;
  min-width: 0;
}
.is-loading .name { opacity: 0.45; }
.pad.shake .cap { animation: shake 0.28s; }
@keyframes shake { 20% { translate: -4px 0; } 50% { translate: 4px 0; } 80% { translate: -2px 0; } }

.namerow { display: flex; align-items: center; justify-content: center; gap: 5px; min-width: 0; }
.new {
  flex: none;
  padding: 2px 6px 3px;
  border-radius: 99px;
  background: var(--ink);
  color: var(--snare);
  font-weight: 900;
  font-size: 0.6rem;
  line-height: 1;
  transform: rotate(-4deg);
}
.new[hidden] { display: none; }

/* ---------- transport ---------- */
.ctrl {
  display: grid;
  grid-template-columns: 1fr 1.75fr 1fr;
  gap: 10px;
}
.tool { height: 76px; --r: 24px; }
.tool .cap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.tool svg { width: 26px; height: 26px; }
.tl { font-weight: 900; font-size: 0.72rem; letter-spacing: 0.04em; line-height: 1; }

.drop { --c: var(--drop); --d: var(--drop-d); }
.drop.building .cap { animation: building 0.16s linear infinite alternate; }
@keyframes building { from { filter: brightness(1); } to { filter: brightness(1.5) saturate(1.2); } }

.play { --r: 28px; }
.play svg { width: 34px; height: 34px; }
.play .tl { font-size: 0.8rem; }
.play .ico-stop { display: none; }
.play.on { --c: var(--ink); --d: #000; color: var(--cloud); }
.play.on .ico-play { display: none; }
.play.on .ico-stop { display: block; }
.play.on .cap { animation: ring 0.5s ease-out infinite alternate; }
@keyframes ring {
  from { box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.12), 0 0 0 3px rgba(255, 246, 230, 0.9); }
  to   { box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.12), 0 0 0 7px rgba(255, 246, 230, 0.15); }
}

.act { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.act-key { height: 60px; --r: 20px; --c: var(--violet); --d: var(--violet-d); color: var(--cloud); }
.act-key .cap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.22), inset 0 -5px 0 rgba(0, 0, 0, 0.1);
}
.act-key svg { width: 22px; height: 22px; }
.act-key .tl { font-size: 0.62rem; letter-spacing: 0.02em; white-space: nowrap; }
.act-key.busy .cap { animation: busy 0.8s ease-in-out infinite alternate; }
@keyframes busy { from { filter: brightness(1); } to { filter: brightness(1.35); } }
.sheet-key { height: 54px; --r: 20px; --c: var(--violet); --d: var(--violet-d); color: var(--cloud); }
.sheet-key .cap { display: flex; align-items: center; justify-content: center; gap: 9px; }
.sheet-key svg { width: 22px; height: 22px; }
.sheet-key .tl { font-size: 0.82rem; }
.sheet-key.hero { height: 64px; --r: 22px; --c: var(--snare); --d: var(--snare-d); color: var(--ink); }
.sheet-key.hero svg { width: 26px; height: 26px; }
.sheet-key.hero .tl { font-size: 0.95rem; }

/* ---------- sheet (video) ---------- */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(14, 5, 38, 0.84);
}
.sheet[hidden] { display: none; }
.card {
  width: min(100%, 380px);
  max-height: 100%;
  overflow: auto;
  padding: 22px 20px 16px;
  border-radius: 32px;
  background: var(--cloud);
  color: var(--ink);
  text-align: center;
  box-shadow: 0 10px 0 var(--cloud-d), 0 24px 50px rgba(0, 0, 0, 0.5);
}
.card h2 { margin: 0 0 6px; font-size: 1.5rem; font-weight: 900; letter-spacing: -0.03em; line-height: 1.1; }
.card p { margin: 0 0 14px; font-size: 0.98rem; font-weight: 700; line-height: 1.35; opacity: 0.8; }
.meter { height: 14px; border-radius: 14px; background: rgba(20, 8, 46, 0.14); overflow: hidden; margin-bottom: 14px; }
.meter i { display: block; height: 100%; width: 100%; background: var(--kick); border-radius: inherit; transform-origin: 0 50%; transform: scaleX(0); }
.card video {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 44vh;
  max-height: 44dvh;
  margin: 0 auto 16px;
  border-radius: 18px;
  background: #000;
  aspect-ratio: 9 / 16;
}
.card video[hidden] { display: none; }
.sheet-actions { display: grid; gap: 12px; margin: 0 4px 6px; }
.sheet-actions .key[hidden] { display: none; }
.sheet-close {
  margin-top: 10px;
  padding: 10px 18px;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-weight: 900;
  font-size: 0.95rem;
  opacity: 0.7;
  cursor: pointer;
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom, 0px));
  z-index: 30;
  max-width: 88vw;
  padding: 11px 18px;
  border-radius: 99px;
  background: var(--ink);
  color: var(--cloud);
  font-weight: 800;
  font-size: 0.92rem;
  line-height: 1.2;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transform: translate(-50%, 16px);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- small phones (short portrait) ---------- */
@media (max-height: 740px) {
  :root { --gap: 9px; }
  .app { gap: 8px; }
  .head { height: 38px; }
  .dino { width: 50px; height: 28px; }
  .word { font-size: 1.5rem; }
  .viz { height: 26px; }
  .tool { height: 62px; }
  .act-key { height: 52px; }
}
@media (max-height: 620px) {
  .viz { display: none; }
  .tool { height: 54px; }
  .tool svg { width: 22px; height: 22px; }
  .play svg { width: 28px; height: 28px; }
  .act-key { height: 46px; }
  .pad .name { -webkit-line-clamp: 1; }
}

/* ---------- landscape phones: boxes left, controls right ---------- */
@media (orientation: landscape) and (max-height: 560px) {
  .app {
    max-width: none;
    display: grid;
    grid-template-columns: minmax(0, 58vw) minmax(0, 1fr);
    grid-template-rows: auto auto auto auto;
    grid-template-areas: "pads head" "pads ctrl" "pads act" "pads .";
    align-content: center;
    column-gap: 20px;
    row-gap: 12px;
    padding-left: max(18px, env(safe-area-inset-left, 0px));
    padding-right: max(18px, env(safe-area-inset-right, 0px));
  }
  .app > * { width: auto; }
  .viz { display: none; }
  .head { grid-area: head; }
  .ctrl { grid-area: ctrl; }
  .act { grid-area: act; }
  .tool { height: 64px; }
  .act-key { height: 54px; }
  .pad .name { -webkit-line-clamp: 1; }
  .app > .pads {
    grid-area: pads;
    max-height: none;
    height: calc(100vh - 28px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    align-self: center;
  }
}
@supports (height: 100dvh) {
  @media (orientation: landscape) and (max-height: 560px) {
    .app > .pads { height: calc(100dvh - 28px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); }
  }
}

@media (prefers-reduced-motion: reduce) {
  .dino { transform: none; }
  .play.on .cap, .act-key.busy .cap, .pad.shake .cap, .drop.building .cap { animation: none; }
  .toast { transition: none; }
}

/* ---------- backups ---------- */
.bk-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; margin-bottom: 14px; text-align: left; }
.bk-row { display: flex; align-items: center; gap: 8px; padding: 9px 10px 9px 14px; border-radius: 18px; background: rgba(20, 8, 46, 0.08); }
.bk-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.bk-info b { font-weight: 900; font-size: 0.95rem; }
.bk-info span { font-weight: 700; font-size: 0.72rem; opacity: 0.7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bk-load { flex: none; padding: 9px 14px; border: 0; border-radius: 99px; background: var(--ink); color: var(--cloud); font: inherit; font-weight: 900; font-size: 0.85rem; cursor: pointer; }
.bk-del { flex: none; width: 34px; height: 34px; border: 0; border-radius: 50%; background: rgba(20, 8, 46, 0.12); color: var(--ink); font: inherit; font-weight: 900; font-size: 1.2rem; line-height: 1; cursor: pointer; }


/* ---------- footer (below the editor, reached by scrolling) ---------- */
.foot {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  padding: 100px 18px max(28px, env(safe-area-inset-bottom, 0px));   /* 150px below the editor, then Ko-fi */
  display: flex;
  flex-direction: column;
  gap: 18px;
  text-align: center;
  -webkit-user-select: text;
  user-select: text;
}
.foot a { color: inherit; }

.desk-block,
.kofi-block {
  padding: 20px 18px;
  border-radius: 26px;
  background: rgba(255, 246, 230, 0.07);
  border: 2px solid rgba(255, 246, 230, 0.12);
}
.desk-title,
.kofi-text {
  margin: 0 0 14px;
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.4;
  color: var(--cloud);
}
.desk-title strong { color: var(--hihat); font-weight: 900; }
.desk-list { margin: 0 0 16px; padding: 0; list-style: none; font-size: 0.82rem; font-weight: 700; line-height: 1.7; opacity: 0.75; }

.desk-btn,
.kofi-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 50px;
  padding: 0 22px;
  border-radius: 18px;
  font-size: 0.9rem;
  font-weight: 900;
  letter-spacing: 0.01em;
  text-decoration: none;
  transition: transform 0.08s;
}
.desk-btn:active,
.kofi-btn:active { transform: translateY(4px); }

.desk-btn { background: var(--violet); color: var(--cloud); box-shadow: 0 5px 0 var(--violet-d); }
.kofi-btn { background: var(--snare); color: var(--ink); box-shadow: 0 5px 0 var(--snare-d); }
.kofi-btn img { display: block; }

.foot-copy {
  margin: 250px 0 0;   /* + 18px flex gap = 200px below the desktop block */
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.6;
  opacity: 0.6;
}
.foot-copy a { text-decoration: underline; text-underline-offset: 3px; }

.desk-link { margin: 14px 0 0; width: 100%; text-align: center; }
.desk-link .l_b_1 {
  display: inline-block;
  padding: 10px 14px;
  font-size: 0.86rem;
  font-weight: 800;
  line-height: 1.3;
  color: var(--cloud);
  text-decoration: underline;
  text-decoration-color: rgba(255, 246, 230, 0.35);
  text-underline-offset: 4px;
}
.desk-link .l_b_1:active { color: var(--snare); }
