/* melody.games · cube anatomy — cube-specific styles on top of brand
   chrome. The 3D scene sits in a darker framed canvas so the bright sticker
   colors still pop. Tokens + reset + header/brand/explore/footer live in
   packages/brand/. */

/* The cube viewer fills the viewport so the canvas + HUD are flex children. */
body {
  height: 100dvh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

.site-header {
  min-height: 74px;
  padding: 14px 24px;
  flex-shrink: 0;
  display: grid;
  grid-template-columns: minmax(190px, 1fr) auto auto;
  align-items: center;
  gap: 18px;
  background: rgba(255, 250, 240, 0.92);
  border-bottom-color: rgba(42, 53, 84, 0.14);
}

.brand-text {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.brand-tagline {
  font-family: var(--font-cn-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panel-toggle {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  background: var(--ink);
  color: var(--paper-card);
  border: 0;
  border-radius: 999px;
  padding: 8px 16px;
  font-family: var(--font-cn);
  font-size: 13px;
  letter-spacing: 1px;
  cursor: pointer;
  transition: background .15s;
}
.panel-toggle:hover { background: var(--ink-2); }
.panel-toggle-icon {
  display: inline-block;
  width: 14px; height: 10px;
  position: relative;
}
.panel-toggle-icon::before,
.panel-toggle-icon::after,
.panel-toggle-icon {
  background: currentColor;
}
.panel-toggle-icon {
  height: 2px;
  background: currentColor;
  margin-top: 4px;
  position: relative;
}
.panel-toggle-icon::before,
.panel-toggle-icon::after {
  content: "";
  position: absolute;
  left: 0; right: 0;
  height: 2px;
  background: currentColor;
}
.panel-toggle-icon::before { top: -5px; }
.panel-toggle-icon::after  { top: 5px; }

/* ============ viewer ============ */
.viewer {
  flex: 1;
  display: flex;
  gap: 16px;
  padding: 16px;
  min-height: 0;
  position: relative;
  z-index: 5;
  overflow: hidden;
}

.canvas-frame {
  flex: 1;
  min-width: 0;
  min-height: 0;
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 42%, var(--paper-card) 0%, var(--paper-2) 80%);
  border: 2px solid var(--ink);
  box-shadow: 0 5px 0 rgba(42, 53, 84, 0.18);
}

#stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}
#stage:active { cursor: grabbing; }

.hint {
  position: absolute;
  right: 16px;
  bottom: 12px;
  font-family: var(--font-cn);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 2px;
  pointer-events: none;
  opacity: 0.7;
}

/* ============ HUD ============ */
.hud {
  position: relative;
  order: -1;
  flex: 0 0 340px;
  width: 340px;
  min-height: 0;
  max-height: 100%;
  align-self: stretch;
  overflow-y: auto;
  padding: 18px 18px 16px;
  background: var(--paper-card);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 8px;
  box-shadow: 0 5px 0 rgba(42, 53, 84, 0.18);
  transition: transform .28s cubic-bezier(.4, .0, .2, 1), opacity .22s ease;
  scrollbar-width: thin;
  scrollbar-color: rgba(42,53,84,.25) transparent;
}
.hud::-webkit-scrollbar { width: 6px; }
.hud::-webkit-scrollbar-thumb { background: rgba(42,53,84,.2); border-radius: 3px; }

.hud.collapsed {
  display: none;
}

.hud-close {
  position: absolute;
  top: 12px; right: 12px;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--paper-2);
  border: 1.5px solid var(--ink);
  color: var(--ink);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, transform .12s;
}
.hud-close:hover { background: var(--ink); color: var(--paper-card); }
.hud-close:active { transform: scale(0.94); }

.hud-title {
  font-family: var(--font-cn);
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
  letter-spacing: 1px;
  padding-right: 32px;
}

.hud-sub {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--ink-2);
  margin-bottom: 14px;
}
.hud-sub b { color: var(--coral); font-weight: 700; }

.frame-card {
  display: grid;
  gap: 10px;
  margin: 12px 0 14px;
  padding: 12px;
  background: var(--paper);
  border: 1.5px solid rgba(42, 53, 84, 0.14);
  border-radius: 8px;
}
.frame-head {
  display: grid;
  gap: 4px;
}
.frame-eyebrow {
  font-family: 'Nunito', sans-serif;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.8px;
  color: var(--ink-3);
}
.frame-head strong {
  font-family: var(--font-cn);
  font-size: 13px;
  line-height: 1.35;
  color: var(--ink);
  letter-spacing: 0.5px;
}
.frame-map {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}
.frame-map span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 9px;
  /* background is set inline by updateHeldFrame() to the current face's color
     so the chip matches the move buttons' palette and follows whole-cube
     rotations. Border/shadow mirror .move-btn. */
  background: var(--paper-card);
  border: 1.5px solid rgba(42, 53, 84, 0.24);
  border-radius: 8px;
  color: var(--paper-card);
  text-shadow: 0 1px 1px rgba(42, 53, 84, 0.34);
}
.frame-map span.frame-on-light {
  /* set by updateHeldFrame() when the chip's background is the cream-white or
     yellow face — switch to ink text so the letter stays legible. */
  color: var(--ink);
  text-shadow: none;
}
.frame-map b {
  font-family: 'Nunito', sans-serif;
  font-size: 14px;
  line-height: 1;
  font-weight: 900;
  color: inherit;
}
.frame-map em {
  font-style: normal;
  font-family: var(--font-cn);
  font-size: 12px;
  color: inherit;
}
.reset-view-btn {
  min-height: 36px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper-card);
  font-family: var(--font-cn);
  font-size: 13px;
  letter-spacing: 1px;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.reset-view-btn:hover { background: var(--ink-2); }
.reset-view-btn:active { transform: scale(0.97); }
.whole-turn-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 5px;
}
.turn-x { background: #b44a3a; }
.turn-y { background: #d4ba4a; color: var(--ink); text-shadow: none; }
.turn-z { background: #6a9550; }

.move-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 6px 1fr 1fr;
  gap: 5px;
}
.axis-sep {
  display: flex;
  align-items: stretch;
  justify-content: center;
}
.axis-sep::after {
  content: "";
  display: block;
  width: 1px;
  background: rgba(42, 53, 84, 0.14);
  border-radius: 1px;
  margin: 3px 0;
}
.move-btn,
.turn-btn {
  min-height: 34px;
  border: 1.5px solid rgba(42, 53, 84, 0.24);
  border-radius: 8px;
  color: var(--paper-card);
  font-family: 'Nunito', sans-serif;
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
  transition: transform .1s, box-shadow .15s, opacity .15s;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.24);
  text-shadow: 0 1px 1px rgba(42, 53, 84, 0.34);
}
.move-btn:hover:not(:disabled),
.turn-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 3px 0 rgba(42, 53, 84, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.26);
}
.move-btn:active:not(:disabled),
.turn-btn:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.move-btn:disabled,
.turn-btn:disabled,
.algo-btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}
.turn-btn {
  background: var(--ink);
  color: var(--paper-card);
  text-shadow: none;
}
.move-u { background: #d4ba4a; color: var(--ink); text-shadow: none; }
.move-l { background: #e19042; }
.move-f { background: #6a9550; }
.move-r { background: #b44a3a; }
.move-b { background: #4f6f9e; }
.move-d {
  background: #f4ecdb;
  color: var(--ink);
  text-shadow: none;
}
.move-btn.move-on-light {
  color: var(--ink);
  text-shadow: none;
}
.move-btn.move-on-dark {
  color: var(--paper-card);
  text-shadow: 0 1px 1px rgba(42, 53, 84, 0.34);
}
.trigger-stack {
  display: grid;
  gap: 5px;
}
.algo-category {
  font-family: 'Nunito', sans-serif;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 1.8px;
  color: var(--ink-3);
  text-transform: uppercase;
  padding: 6px 2px 2px;
}
.trigger-stack .algo-category:first-child {
  padding-top: 0;
}
.algo-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  width: 100%;
  min-height: 32px;
  padding: 5px 10px;
  background: var(--paper-card);
  border: 1.5px solid rgba(42, 53, 84, 0.16);
  border-radius: 6px;
  color: var(--ink);
  cursor: pointer;
  transition: transform .1s, box-shadow .15s, opacity .15s;
}
.algo-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 3px 0 rgba(42, 53, 84, 0.12);
}
.algo-btn span {
  font-family: var(--font-cn);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--ink-2);
}
.algo-btn code {
  font-family: 'Nunito', sans-serif;
  font-size: 12.5px;
  font-weight: 900;
  color: var(--coral);
  white-space: nowrap;
  letter-spacing: 0.2px;
}
.trigger-status {
  margin-top: 8px;
  padding: 8px 10px;
  background: rgba(42, 53, 84, 0.06);
  border-radius: 8px;
  font-family: var(--font-cn);
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--ink-2);
}

.group {
  margin-bottom: 10px;
  padding: 10px 12px 6px;
  background: var(--paper);
  border: 1.5px solid rgba(42, 53, 84, 0.12);
  border-radius: 8px;
}

.group > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-cn);
  font-size: 13px;
  letter-spacing: 1.5px;
  color: var(--ink);
  user-select: none;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1.5px solid rgba(42, 53, 84, 0.08);
}
.group > summary::-webkit-details-marker { display: none; }
.group > summary::after {
  content: "▾";
  margin-left: auto;
  color: var(--ink-3);
  font-size: 10px;
  transition: transform 0.2s ease;
}
.group:not([open]) > summary { margin-bottom: 0; padding-bottom: 0; border-bottom: 0; }
.group:not([open]) > summary::after { transform: rotate(-90deg); }

.group-no {
  display: inline-block;
  font-family: 'Nunito', sans-serif;
  font-size: 10px;
  font-weight: 700;
  color: var(--paper-card);
  background: var(--ink);
  padding: 3px 7px;
  border-radius: 999px;
  letter-spacing: 1px;
}

.slider {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 10px;
  font-family: var(--font-cn);
  font-size: 12px;
  letter-spacing: 1px;
  color: var(--ink-2);
}

.slider input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: rgba(42, 53, 84, 0.12);
  border-radius: 2px;
  outline: none;
}

.slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--paper-card);
  border: 2px solid var(--ink);
  cursor: grab;
  transition: transform 0.12s ease;
}
.slider input[type="range"]::-webkit-slider-thumb:active { cursor: grabbing; transform: scale(1.12); }
.slider input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--paper-card); border: 2px solid var(--ink); cursor: grab;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-family: var(--font-cn);
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
  letter-spacing: 0.5px;
}
.check input[type="checkbox"] {
  appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid var(--ink);
  border-radius: 5px;
  background: var(--paper-card);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.12s ease;
  flex-shrink: 0;
}
.check input[type="checkbox"]:checked {
  background: var(--ink);
  border-color: var(--ink);
}
.check input[type="checkbox"]:checked::after {
  content: "";
  width: 5px; height: 9px;
  border: solid var(--paper-card);
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}

.reset-btn {
  display: inline-block;
  margin-top: 4px;
  padding: 8px 18px;
  font-family: var(--font-cn);
  font-size: 13px;
  letter-spacing: 1px;
  color: var(--paper-card);
  background: var(--ink);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s;
}
.reset-btn:hover { background: var(--ink-2); }

.cube-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 4px 0 10px;
}
.action-btn {
  padding: 9px 8px;
  font-family: var(--font-cn);
  font-size: 13px;
  letter-spacing: 1px;
  color: var(--paper-card);
  background: var(--ink);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s, opacity .15s, transform .1s;
}
.action-btn:hover:not(:disabled) { background: var(--ink-2); }
.action-btn:active:not(:disabled) { transform: scale(0.96); }
.action-btn:disabled {
  background: var(--paper-2);
  color: var(--ink-3);
  cursor: not-allowed;
}
.action-shuffle { background: var(--coral); }
.action-shuffle:hover:not(:disabled) { background: #b66a4d; }


.group-hint {
  font-size: 11.5px;
  color: var(--ink-2);
  line-height: 1.5;
  margin-bottom: 10px;
}

.face-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--paper-card);
  border: 1.5px solid rgba(42, 53, 84, 0.12);
  border-radius: 8px;
  margin: 10px 0;
}
.face-status-label {
  font-family: 'Nunito', sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--ink-3);
  text-transform: uppercase;
}
.face-status-value {
  font-family: var(--font-cn);
  font-size: 14px;
  color: var(--ink-3);
  letter-spacing: 1px;
  font-weight: 600;
}
.face-status-value.active { color: var(--coral); }

.rotate-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.rotate-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 8px;
  font-family: var(--font-cn);
  font-size: 13px;
  letter-spacing: 1px;
  color: var(--paper-card);
  background: var(--ink);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s, opacity .15s, transform .1s;
}
.rotate-btn:hover:not(:disabled) { background: var(--ink-2); }
.rotate-btn:active:not(:disabled) { transform: scale(0.96); }
.rotate-btn:disabled {
  background: var(--paper-2);
  color: var(--ink-3);
  cursor: not-allowed;
}
.rot-icon { font-size: 18px; line-height: 1; }

/* Footer is a flex-shrink:0 strip beneath the cube viewer; shared margin-top
   is replaced with a uniform padding so it doesn't push the canvas off-screen. */
.site-footer {
  margin-top: 0;
  padding: 14px;
  flex-shrink: 0;
}
.site-footer .dot { color: var(--coral); opacity: .8; }

/* ============ responsive — mobile bottom sheet ============ */
@media (max-width: 900px) {
  .site-header {
    min-height: 68px;
    grid-template-columns: minmax(0, 1fr) auto auto;
    padding: 12px 14px;
    gap: 8px 10px;
  }
  .brand-name { font-size: 17px; }
  .brand-tagline { font-size: 10px; letter-spacing: 1.5px; }
  .panel-toggle { padding: 8px 16px; font-size: 13px; }
  .site-footer { display: none; }

  .viewer {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    padding: 10px 10px var(--sheet-visible, 64px);
  }
  .canvas-frame { border-radius: 8px; border-width: 1.5px; }

  /* HUD becomes a bottom sheet that's detached from the canvas frame */
  .hud {
    display: block;
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    flex: none;
    max-height: min(62dvh, 540px);
    padding: 30px 16px max(16px, env(safe-area-inset-bottom));
    border: 1.5px solid var(--ink);
    border-bottom: 0;
    border-radius: 8px 8px 0 0;
    box-shadow: 0 -6px 24px rgba(42, 53, 84, 0.18);
    z-index: 25;
  }
  /* drag-handle pill on top */
  .hud::before {
    content: "";
    position: absolute;
    top: 9px;
    left: 50%;
    transform: translateX(-50%);
    width: 44px;
    height: 5px;
    border-radius: 999px;
    background: rgba(42, 53, 84, 0.22);
    pointer-events: none;
  }
  .hud.collapsed {
    display: block;
    transform: translateY(calc(100% - 64px));
    opacity: 1;
    pointer-events: auto;
  }
  /* When collapsed, tapping the visible top strip re-opens */
  .hud.collapsed::after {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 64px;
    cursor: pointer;
  }
  .hud-close { top: 8px; right: 14px; }
  .hud-title { font-size: 16px; }
  .hud-sub { font-size: 12px; }

  .hint { display: none; }
}

@media (max-width: 460px) {
  .brand-mark { width: 30px; height: 30px; flex-basis: 30px; }
  .brand-tagline { display: none; }
  .frame-map { grid-template-columns: repeat(2, 1fr); }
  .whole-turn-grid { grid-template-columns: repeat(2, 1fr); }
  .panel-toggle-label { display: none; }
  .panel-toggle {
    width: 38px;
    justify-content: center;
    padding: 8px;
  }
}
