/* The drill-through (js/drill.js): the same next layer everywhere. In place on wide screens, a sheet on
   phones, a panel over the screen for items with no row to grow from. The sheet and the panel are the
   room sheet's (v2.css, "A room"): glass, the blur, a hairline, 18px top corners on phones, 14px on wide
   screens. A player's layers (tone "moon") wear the drawers' Moon body instead, so the player stays the
   player when it slides up. Uses the v2.css tokens only, plus the Moon values below (see the note). */

/* ---------- in place ---------- */

/* A layer growing under its row. drill.js animates the height; the content sets its own padding. */
[data-drill-slot][hidden] {
  display: none;
}

/* While something in a group is open, the rest of the group dims a little (treatment A). On the dark body .88 is as
   far as it can go with every chord card still at 4.5:1 (it was .55 on the light one). */
.is-dim {
  opacity: .88;
  transition: opacity 220ms var(--ease-out);
}

/* ---------- the stack over the page: a sheet on phones, a panel on wide screens ---------- */

.drill-scrim {
  position: fixed;
  inset: 0;
  z-index: 44;
  background: color-mix(in srgb, var(--space) 55%, transparent);
}

.drill-scrim[hidden],
.drill[hidden] {
  display: none;
}

.drill {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 45;
  display: flex;
  flex-direction: column;
  max-height: 88vh;
  max-height: 88dvh;
  padding-bottom: env(safe-area-inset-bottom);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 18px 18px 0 0;
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  color: var(--starlight);
}

.drill-level {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.drill-level[hidden] {
  display: none;
}

.drill-grab {
  flex: none;
  align-self: center;
  width: 36px;
  height: 4px;
  margin-top: 8px;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, currentColor 22%, transparent);
}

.drill-head {
  display: flex;
  flex: none;
  align-items: center;
  gap: 6px;
  padding: 4px 12px 6px 20px;
}

.drill-head:has(.drill-back) {
  padding-left: 8px;
}

.drill-title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 400;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.drill-back {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 2px;
  min-height: 44px;
  padding: 0 10px 0 4px;
  border-radius: var(--r-pill);
  color: var(--dust);
  font-size: 14px;
  font-weight: 500;
  transition: background-color var(--t) ease, color var(--t) ease;
}

.drill-back-ic {
  transform: rotate(180deg);
}

.drill-close {
  flex: none;
}

.drill-body {
  flex: 1;
  min-height: 0;
  padding: 4px 20px 22px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

@media (hover: hover) {
  .drill-back:hover {
    background-color: var(--lift);
    color: var(--starlight);
  }
}

/* Wide screens: a panel over the screen, the width of the room panel (or wider, for a lesson). */
@media (min-width: 640px) {
  .drill {
    top: max(72px, 9vh);
    bottom: auto;
    width: min(560px, calc(100vw - 48px));
    max-height: calc(100dvh - max(72px, 9vh) - 24px);
    margin: 0 auto;
    padding-bottom: 0;
    border-bottom: 1px solid var(--line);
    border-radius: var(--r-card);
  }

  .drill[data-size="wide"] {
    width: min(760px, calc(100vw - 48px));
  }

  .drill-grab {
    display: none;
  }

  .drill-head {
    padding-top: 12px;
  }
}

@media (max-width: 639px) {
  .drill-body {
    padding: 4px 16px 20px;
  }

  .drill-head {
    padding-left: 16px;
  }
}

/* ---------- Moon: a player's layers wear the drawers' body ----------
   The Moon tokens live on .drawers in v2.css, and the sheet sits outside .drawers, so they are repeated
   here with the same values. Dark since 2026-11-17, as the drawers are (v2.css, "Moon"). */
.drill[data-tone="moon"] {
  --moon-body: var(--panel);
  --moon-body-hi: #171A23;
  --moon-body-lo: var(--panel);
  --moon-ink: var(--starlight);
  --moon-mtext: #A6A3AC;
  --moon-line: rgba(241, 237, 228, .12);
  --moon-bevel-hi: rgba(255, 255, 255, .06);
  --moon-raised: #222632;
  --moon-raised-lo: #1A1D27;
  --moon-raised-edge: #05070D;
  --moon-raised-hl: rgba(255, 255, 255, .1);
  --moon-raised-rim: rgba(241, 237, 228, .16);
  --moon-key-hi: #F1EDE4;
  --moon-key-lo: #DAD6CF;
  --moon-key-edge: #8E8B95;
  --moon-key-ink: #05070D;
  --moon-key-rim: rgba(241, 237, 228, .4);
  --moon-trk-off: #05070D;
  --moon-trk-off-ink: #A6A3AC;
  --moon-thumb: repeating-radial-gradient(circle at 50% 50%, rgba(255, 255, 255, .14) 0 .8px, rgba(0, 0, 0, .045) .8px 2px), conic-gradient(#E8E7E4, #FFFFFF 9%, #BDBBB6 21%, #8E8C87 31%, #D0CEC9 44%, #FDFDFC 56%, #B5B3AE 69%, #8C8A85 80%, #D6D4CF 92%, #E8E7E4);
  --moon-lit: #F6AD3B;
  border-color: var(--moon-line);
  background: var(--moon-body);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  box-shadow: none;
  color: var(--moon-ink);
}

.drill[data-tone="moon"] :focus-visible {
  outline-color: var(--moon-ink);
}

.drill[data-tone="moon"] .drill-back {
  color: var(--moon-mtext);
}

.drill[data-tone="moon"] .drill-close {
  border-color: var(--moon-line);
  background: linear-gradient(180deg, var(--moon-raised), var(--moon-raised-lo));
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  color: var(--moon-ink);
}

.drill[data-tone="moon"] .drill-body {
  scrollbar-color: var(--moon-line) transparent;
}

@media (hover: hover) {
  .drill[data-tone="moon"] .drill-back:hover {
    background-color: color-mix(in srgb, var(--moon-ink) 6%, transparent);
    color: var(--moon-ink);
  }

  .drill[data-tone="moon"] .drill-close:hover {
    border-color: var(--moon-raised-edge);
    background-image: linear-gradient(180deg, var(--moon-raised), var(--moon-raised-lo));
    color: var(--moon-ink);
  }
}

@media (prefers-reduced-motion: reduce) {
  .is-dim {
    transition: none;
  }
}
