/* Panel */

.panel {
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
}

.empty { position: relative; }
.empty-pin { position: absolute; top: 12px; right: 12px; }
.pin-btn { color: var(--muted); }
.pin-btn.on { color: var(--accent); }

.panel-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 12px 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.panel-ref { display: flex; flex-direction: column; font-weight: 600; min-width: 0; }
.panel-ref .kind { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.panel-actions { display: flex; gap: 2px; }

.panel-body { padding: 20px 20px 32px; }

.panel-word {
  margin: 0 0 18px;
  font: 600 2.4rem/1.5 var(--reading);
  text-align: center;
  color: var(--accent-text);
}

.translation { margin: 0; font: 1.2rem/1.65 var(--serif); }

.credit { margin: 20px 0 0; font-size: 12px; color: var(--faint); }
.chapter-credit { margin: 24px 0 0; font-size: 12px; color: var(--faint); text-align: center; }
:is(.credit, .chapter-credit, .menu-note) a { color: inherit; }

.entry {
  padding: 14px 16px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
}

.entry-summary {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
}

button.entry-summary { cursor: pointer; padding-right: 28px; }
.entry-head { display: flex; align-items: baseline; gap: 10px; }

.chevron {
  position: absolute;
  right: 0;
  bottom: 2px;
  width: 18px;
  height: 18px;
  color: var(--muted);
  transform: rotate(90deg);
  transition: transform 0.2s;
}

.entry.collapsed .chevron { transform: none; }
.entry.collapsed { padding-block: 12px; }
.lemma { font: 600 1.6rem/1.3 var(--hebrew); }
.translit { font: italic 1rem var(--serif); color: var(--muted); }

.strongs {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--hover);
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.gloss { display: block; margin-top: 4px; font-weight: 600; font-size: 1.05rem; }
.parsing { display: block; margin-top: 2px; font-size: 12.5px; color: var(--muted); }
.parsing:empty { display: none; }

.defs { list-style: none; margin: 10px 0 0; padding: 10px 0 0; border-top: 1px dashed var(--line); font-size: 13.5px; color: var(--muted); }
.defs li { padding: 2px 0; }
.defs li.sub { padding-left: 1.4em; }
.defs .marker { display: inline-block; min-width: 1.8em; font-weight: 600; color: var(--text); }

.link-btn {
  padding: 0;
  margin-top: 6px;
  border: 0;
  background: none;
  color: var(--accent);
  font-weight: 500;
  cursor: pointer;
}

.link-btn:hover { text-decoration: underline; }

.empty { padding: 36px 28px; color: var(--muted); }
.empty h2 { margin: 0 0 20px; font-size: 1.05rem; color: var(--text); }
.empty ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.empty li { display: flex; align-items: center; gap: 14px; }

.empty .sample {
  flex: none;
  display: grid;
  place-items: center;
  width: 54px;
  height: 40px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--accent-text);
  font: 600 1.25rem var(--hebrew);
  vertical-align: baseline;
}

.empty .sample.vn { font: 600 13px var(--sans); color: var(--accent); }
.hebrew-numerals .empty .sample.vn { font: 600 1.15rem var(--hebrew); }
.empty .sample.key { font: 500 13px var(--sans); color: var(--text); }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.help-row { display: flex; align-items: center; gap: 12px; min-height: 36px; padding: 3px 0; font-size: 13px; line-height: 1.35; }
.help-keys { flex: none; display: flex; gap: 4px; width: 132px; flex-wrap: wrap; }
.kbd { display: inline-flex; align-items: center; padding: 2px 7px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); font: 500 12px var(--sans); color: var(--text); white-space: nowrap; }
.kbd .i { width: 16px; height: 16px; }

/* Mobile: panel becomes a bottom sheet */

@media (min-width: 1200px) {
  .layout-study.english-beside .reader > * { max-width: calc(var(--measure) * 1.7); }
  .layout-study.english-beside .verse { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 40px; align-items: start; }
  .layout-study.english-beside .verse .hebrew { order: 2; margin: 0; }
  .layout-study.english-beside .verse .english { order: 1; padding-top: 0.45em; }
}

@media (min-width: 1100px) {
  .layout-focus.english-beside .focus-verse { display: grid; grid-template-columns: 1fr 1fr; gap: 56px; align-items: center; max-width: 76rem; }
  .layout-focus.english-beside .focus-hebrew { order: 2; }
  .layout-focus.english-beside .focus-verse .english { order: 1; margin: 0; text-align: left; }
}

@media (min-width: 800px) {
  .layout-scroll.english-beside .scroll-sheet { column-width: min(calc(36rem * var(--scale)), calc(100vw - 72px)); }
  .layout-scroll.english-beside .scroll-verse { display: grid; grid-template-columns: 1.3fr 1fr; gap: 28px; align-items: start; }
  .layout-scroll.english-beside .scroll-verse .english { margin-top: 0.3em; }
}

@media (min-width: 960px) {
  .panel-pinned.panel-top, .panel-pinned.panel-bottom { --dock-h: 36dvh; }

  .panel-pinned.panel-left .layout, .panel-pinned.panel-right .layout { display: grid; }
  .panel-pinned.panel-right .layout { grid-template-columns: minmax(0, 1fr) var(--panel-w); }
  .panel-pinned.panel-left .layout { grid-template-columns: var(--panel-w) minmax(0, 1fr); }

  .panel-pinned .panel {
    position: sticky;
    top: var(--bar-h);
    z-index: 10;
    height: calc(var(--app-h) - var(--bar-h));
    transition: top 0.25s ease, height 0.25s ease;
  }

  .panel-pinned.panel-right .panel { border-left: 1px solid var(--line); }
  .panel-pinned.panel-left .panel { order: -1; border-right: 1px solid var(--line); }
  .bar-hidden .autohide:not(.menu-open).panel-pinned:is(.panel-left, .panel-right) .panel { top: 0; height: var(--app-h); }

  .panel-pinned.panel-top .layout, .panel-pinned.panel-bottom .layout { display: flex; flex-direction: column; align-items: stretch; }
  .panel-pinned.panel-top .panel { order: -1; height: var(--dock-h); border-bottom: 1px solid var(--line); box-shadow: 0 6px 18px -12px var(--shade); }
  .panel-pinned.panel-bottom .panel { top: auto; bottom: 0; height: var(--dock-h); border-top: 1px solid var(--line); box-shadow: 0 -6px 18px -12px var(--shade); }
  .panel-pinned.panel-top .reader, .panel-pinned.panel-bottom .reader { width: 100%; }

  .panel-floating .panel {
    position: fixed;
    top: calc(var(--bar-h) + 16px);
    z-index: 20;
    width: 380px;
    max-height: calc(var(--app-h) - var(--bar-h) - 32px);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
  }

  .panel-floating .panel-head { border-radius: 16px 16px 0 0; }
  .panel-floating.panel-left .panel { left: 16px; transform: translateX(-12px); }
  .panel-floating.panel-right .panel { right: 16px; transform: translateX(12px); }
  .panel-floating.panel-top .panel, .panel-floating.panel-bottom .panel { left: 50%; width: min(860px, calc(100vw - 32px)); max-height: 42dvh; }
  .panel-floating.panel-top .panel { transform: translate(-50%, -12px); }
  .panel-floating.panel-bottom .panel { top: auto; bottom: 16px; transform: translate(-50%, 12px); }
  .panel-floating.has-selection .panel { opacity: 1; visibility: visible; transform: none; }
  .panel-floating.has-selection:is(.panel-top, .panel-bottom) .panel { transform: translateX(-50%); }

  .panel-top .panel-body, .panel-bottom .panel-body {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 12px;
    align-items: start;
    direction: rtl;
  }

  :is(.panel-top, .panel-bottom) .panel-body > * { direction: ltr; }
  .panel-top .panel-word, .panel-bottom .panel-word { margin: 0; align-self: center; }
  .panel-top .entry, .panel-bottom .entry { margin: 0; }
  :is(.panel-top, .panel-bottom) .panel-body > :is(.link-btn, .credit, .translation) { grid-column: 1 / -1; justify-self: end; margin: 0; }
  :is(.panel-top, .panel-bottom) .empty ul { grid-template-columns: repeat(3, 1fr); }
  :is(.panel-top, .panel-bottom) .empty { padding: 24px 28px; }

  .layout-scroll.panel-pinned.panel-right .reader::before { right: var(--panel-w); }
  .layout-scroll.panel-pinned.panel-left .reader::after { left: var(--panel-w); }
  .layout-scroll.panel-pinned.panel-top .reader::before, .layout-scroll.panel-pinned.panel-top .reader::after { top: calc(var(--bar-h) + var(--dock-h)); }
  .layout-scroll.panel-pinned.panel-bottom .reader::before, .layout-scroll.panel-pinned.panel-bottom .reader::after { bottom: var(--dock-h); }

  .layout-focus.panel-floating.has-selection.panel-left .focus { padding-left: 420px; }
  .layout-focus.panel-floating.has-selection.panel-right .focus { padding-right: 420px; }
  .layout-focus.panel-floating.has-selection.panel-top .focus { padding-top: 44dvh; }
  .layout-focus.panel-floating.has-selection.panel-bottom .focus { padding-bottom: 44dvh; }
}

@media (max-width: 959px) {
  .layout { display: block; }
  .wide-only, .pin-btn, .empty-pin { display: none; }
  .menu-section:has(+ .wide-only:last-child) { border-bottom: 0; padding-bottom: 0; }
  .reader { padding: 32px 20px 72px; }
  .has-selection .reader { padding-bottom: calc(var(--sheet-h) + 32px); }
  .layout-focus.has-selection .focus { padding-bottom: calc(var(--sheet-h) + 16px); }
  .scroll-sheet { --sheet-pad: 20px; --edge-w: 148px; column-gap: 40px; }
  .scroll-edge .ref { white-space: normal; text-wrap: balance; }

  .panel {
    position: fixed;
    inset: calc(var(--vv-bottom, 100dvh) - var(--sheet-h)) 0 auto 0;
    z-index: 20;
    height: var(--sheet-h);
    padding-bottom: env(safe-area-inset-bottom);
    border: 1px solid var(--line);
    border-bottom: 0;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -8px 32px rgb(0 0 0 / 0.12);
    transform: translateY(calc(100% + 40px));
    visibility: hidden;
    transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0.28s;
  }

  .has-selection .panel { transform: none; visibility: visible; }
  .panel-head { border-radius: 18px 18px 0 0; padding-top: 16px; touch-action: none; cursor: grab; }

  .panel-head::before {
    content: "";
    position: absolute;
    top: 6px;
    left: 50%;
    width: 36px;
    height: 4px;
    margin-left: -18px;
    border-radius: 99px;
    background: var(--line);
  }

  .panel-word { font-size: 2rem; margin-bottom: 12px; }
}

@media (max-width: 600px) {
  :root { --bar-h: 56px; }
  .bar { gap: 6px; padding-inline: 10px; }
  .brand-name { display: none; }
  .tools { gap: 0; }
  .focus-hebrew { font-size: calc(1.9rem * var(--scale)); }
  .brand { flex: none; }
  .picker { flex: 1; justify-content: center; gap: 2px; }
  .tools { flex: none; }
  .ref-btn { padding-inline: 10px; }
  .icon-btn { width: 34px; }
  .reader { padding-inline: 16px; }
  .chapter-head { margin-bottom: 28px; }
  .prose > p, .verse .hebrew { font-size: calc(1.5rem * var(--scale)); text-align: right; }
  .verse { padding-inline: 12px; margin-inline: -12px; }
  .chapter-link { padding: 8px 12px; }
  .menu {
    position: fixed;
    inset: auto 0 0 0;
    width: auto;
    max-height: 85dvh;
    padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
    border-radius: 20px 20px 0 0;
    border-bottom: 0;
    animation: sheet-up 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
  }

  .menu-backdrop { background: rgb(0 0 0 / 0.32); animation: fade-in 0.2s; }
}

@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes fade-in { from { opacity: 0; } }

@media (max-width: 420px) {
  .brand { display: none; }
}
