/*
 * sermon-tools-v1: the Sermon tools pull tab and drawer on every interactive sermon page.
 * Loaded once per page (<link ... data-ffa-sermon-tools-v1>), drawn by assets/sermon-tools-v1.js.
 * Uses the page's own colour variables, so light and dark themes follow the page.
 */

/* Your thoughts and the Discussion Guide moved into the drawer: hide their old page buttons.
   The buttons stay in the page (hidden), so the drawer reuses their exact behaviour. */
html.st-v1 #my-notes-link,
html.st-v1 #discussion-guide-link,
html.st-v1 .workspace-tab[data-panel="thoughts"]{ display:none !important; }

/* Pull tab on the right edge (a bit taller than the FFA Connect admin tab: 26x84 vs 26x60). */
.st-handle{
  position:fixed; z-index:950; right:0; top:50%; transform:translateY(-50%);
  width:26px; height:84px; padding:0; margin:0;
  border:0; border-radius:14px 0 0 14px;
  background:var(--gold, #A9793F); cursor:pointer;
  box-shadow:-3px 3px 12px rgba(0,0,0,.22);
  display:flex; align-items:center; justify-content:center;
  -webkit-tap-highlight-color:transparent;
}
.st-handle[hidden]{ display:none; }
.st-handle::before{ content:""; position:absolute; top:-6px; bottom:-6px; left:-18px; right:0; } /* ~44x96 touch target */
.st-handle::after{ content:""; width:3px; height:24px; border-radius:2px; background:rgba(255,255,255,.75); }
.st-handle:hover{ filter:brightness(1.06); }
.st-handle:focus-visible{ outline:3px solid var(--ink, #2B2620); outline-offset:2px; }
:root[data-theme="dark"] .st-handle{ box-shadow:-3px 3px 14px rgba(0,0,0,.5); }
:root[data-theme="dark"] .st-handle::after{ background:rgba(20,17,13,.55); }
:root[data-theme="dark"] .st-handle:focus-visible{ outline-color:#F4F0E8; }

/* Phone held sideways: slimmer, so it covers less of the tool column. */
@media (max-width:900px) and (orientation:landscape){
  .st-handle{ width:16px; height:76px; }
  .st-handle::after{ width:2px; height:20px; }
  html.st-v1 .app{ padding-right:22px; } /* a clear lane for the tab beside the tool column */
}
/* Phone held upright: centred on the right edge like desktop and landscape (centre of the safe area), slimmer. */
@media (max-width:560px) and (orientation:portrait){
  .st-handle{ top:calc(50% + (env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)) / 2); bottom:auto; transform:translateY(-50%); width:22px; }
  /* A clear lane on both sides (kept symmetric), so the centred tab never sits on the page's buttons or tabs. */
  html.st-v1 .app{ padding-left:24px; padding-right:24px; }
}
@media (max-width:560px) and (orientation:portrait) and (max-height:700px){
  .st-handle{ width:18px; height:72px; }
  .st-handle::after{ width:2px; height:20px; }
  html.st-v1 .app{ padding-left:20px; padding-right:20px; }
}
html.kbd-open .st-handle{ display:none; } /* on-screen keyboard open (portrait writing) */

.st-backdrop{
  position:fixed; inset:0; z-index:1690;
  background:rgba(20,17,13,.38); opacity:0; transition:opacity .25s ease;
}
.st-backdrop.open{ opacity:1; }
.st-drawer{
  position:fixed; z-index:1700; top:0; right:0; bottom:0;
  width:min(320px, 86vw); box-sizing:border-box;
  padding:calc(18px + env(safe-area-inset-top, 0px)) 16px calc(18px + env(safe-area-inset-bottom, 0px));
  background:var(--card, #fff); color:var(--ink, #2B2620);
  border-left:1px solid var(--line, #E3D9C6);
  box-shadow:-12px 0 32px rgba(0,0,0,.18);
  overflow-y:auto; transform:translateX(100%); transition:transform .25s ease;
  font-family:-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
:root[data-theme="dark"] .st-drawer{ box-shadow:-12px 0 32px rgba(0,0,0,.5); }
.st-drawer.open{ transform:none; }
/* Shown by the guided tour: no slide, and under the tour's dimmer and card (the tour spotlights one row at a time). */
.st-drawer.st-touring{ z-index:999; transition:none; }
.st-drawer[hidden], .st-backdrop[hidden]{ display:none; }
.st-head{ display:flex; align-items:center; justify-content:space-between; gap:12px; margin:0 0 16px; }
.st-head h2{ margin:0; font:700 22px/1.2 Georgia, "Times New Roman", serif; color:var(--ink, #2B2620); }
.st-close{
  width:36px; height:36px; flex:none; display:grid; place-items:center;
  border:1px solid var(--line, #E3D9C6); border-radius:50%;
  background:var(--card, #fff); color:var(--ink-soft, #5B5347);
  font-size:20px; line-height:1; cursor:pointer; padding:0;
}
.st-close:hover{ border-color:var(--gold, #A9793F); color:var(--gold, #A9793F); }
.st-list{ display:grid; gap:8px; margin:0; padding:0; list-style:none; }
.st-row{
  display:flex; align-items:center; gap:12px; width:100%; min-height:54px; box-sizing:border-box;
  padding:10px 12px; margin:0;
  border:1px solid var(--line, #E3D9C6); border-radius:12px;
  background:var(--parchment, #F6F1E7); color:var(--ink, #2B2620);
  font:inherit; font-size:15px; font-weight:600; text-align:left; text-decoration:none; cursor:pointer;
}
.st-row:hover{ border-color:var(--gold, #A9793F); }
.st-row:focus-visible, .st-close:focus-visible{ outline:2px solid var(--gold, #A9793F); outline-offset:2px; }
.st-ic{
  width:34px; height:34px; flex:none; display:grid; place-items:center; border-radius:10px;
  background:rgba(169,121,63,.12); color:var(--gold, #A9793F);
}
:root[data-theme="dark"] .st-ic{ background:rgba(217,167,92,.14); }
.st-ic svg, .st-end svg{ width:18px; height:18px; display:block; }
.st-end{ margin-left:auto; color:var(--ink-soft, #5B5347); display:flex; }
.st-end svg{ width:16px; height:16px; }
.st-label{ min-width:0; }

/* ---- Your thoughts: inside the tray, popped out as a floating panel, or in its own small window ---- */
.st-view[hidden]{ display:none !important; }
.st-drawer.st-mode-thoughts{ width:min(400px, 92vw); display:flex; flex-direction:column; }
.st-view-thoughts{ display:flex; flex-direction:column; flex:1; min-height:0; }
.st-head-th{ justify-content:flex-start; gap:8px; }
.st-head-th h2{ flex:1; min-width:0; font-size:20px; }
.st-icon-btn, .st-dock{
  height:36px; min-width:36px; flex:none; display:inline-flex; align-items:center; justify-content:center; gap:6px;
  padding:0; border:1px solid var(--line, #E3D9C6); border-radius:18px;
  background:var(--card, #fff); color:var(--ink-soft, #5B5347); cursor:pointer; font:inherit; font-size:13px; font-weight:600;
}
.st-icon-btn svg, .st-dock svg{ width:17px; height:17px; display:block; }
.st-dock{ padding:0 12px; }
.st-icon-btn:hover, .st-dock:hover{ border-color:var(--gold, #A9793F); color:var(--gold, #A9793F); }
.st-icon-btn:focus-visible, .st-dock:focus-visible, .st-th-actions button:focus-visible{ outline:2px solid var(--gold, #A9793F); outline-offset:2px; }
.st-th-body{ display:flex; flex-direction:column; flex:1; min-height:0; gap:8px; }
.st-sr{ position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; }
.st-th-text{
  flex:1; min-height:180px; width:100%; box-sizing:border-box; resize:none; margin:0;
  padding:12px 14px; border:1px solid var(--line, #E3D9C6); border-radius:12px;
  background:var(--parchment, #F6F1E7); color:var(--ink, #2B2620);
  font:16px/1.55 Georgia, "Times New Roman", serif;
}
.st-th-text:focus{ outline:none; border-color:var(--gold, #A9793F); box-shadow:0 0 0 3px rgba(169,121,63,.18); }
.st-th-text::placeholder{ color:var(--ink-soft, #5B5347); opacity:.7; }
.st-th-hint{ margin:0; font-size:12px; color:var(--ink-soft, #5B5347); }
.st-th-actions{ display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.st-th-actions button{
  min-height:38px; padding:6px 10px; border:1px solid var(--line, #E3D9C6); border-radius:10px;
  background:var(--card, #fff); color:var(--ink, #2B2620); font:inherit; font-size:13px; font-weight:600; cursor:pointer;
}
.st-th-actions button:hover{ border-color:var(--gold, #A9793F); color:var(--gold, #A9793F); }

/* Floating panel (pop-out when a separate window is not possible): movable by its header, resizable from the corner. */
.st-float{
  position:fixed; z-index:1650; right:24px; bottom:24px; width:380px; height:470px;
  min-width:300px; min-height:320px; max-width:calc(100vw - 16px); max-height:calc(100vh - 16px);
  box-sizing:border-box; padding:14px 14px 16px; display:flex; flex-direction:column; resize:both; overflow:hidden;
  background:var(--card, #fff); color:var(--ink, #2B2620);
  border:1px solid var(--line, #E3D9C6); border-radius:16px; box-shadow:0 18px 48px rgba(0,0,0,.24);
  font-family:-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
:root[data-theme="dark"] .st-float{ box-shadow:0 18px 48px rgba(0,0,0,.6); }
.st-float-head{ cursor:move; user-select:none; touch-action:none; margin-bottom:12px; justify-content:flex-start; gap:8px; }
.st-float-head h2{ flex:1; font-size:19px; }
/* Phones: a full-screen sheet instead. */
.st-float.st-sheet{
  inset:0; width:auto; height:auto; max-width:none; max-height:none; min-width:0; min-height:0; resize:none; border-radius:0; border:0;
  padding:calc(16px + env(safe-area-inset-top, 0px)) 16px calc(16px + env(safe-area-inset-bottom, 0px));
}
.st-float.st-sheet .st-float-head{ cursor:default; }

/* The separate pop-out window. */
body.st-popup{
  margin:0; padding:16px; box-sizing:border-box; height:100vh; display:flex; flex-direction:column;
  background:var(--card, #fff); color:var(--ink, #2B2620); font-family:-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.st-pop-head{ display:flex; align-items:center; gap:12px; margin:0 0 12px; }
.st-pop-head > div{ flex:1; min-width:0; }
.st-pop-head h1{ margin:0; font:700 20px/1.2 Georgia, "Times New Roman", serif; }
.st-pop-head p{ margin:2px 0 0; font-size:12px; color:var(--ink-soft, #5B5347); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

@media (prefers-reduced-motion:reduce){ .st-drawer, .st-backdrop{ transition:none; } }
@media print{ .st-handle, .st-drawer, .st-backdrop, .st-float{ display:none !important; } }
