/* "?" help buttons and their sheet (static/help.js). Colours from style.css's tokens. */
.help-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-block: -4px;             /* never makes its line taller */
  margin-inline-start: 6px;
  padding: 0;
  flex: none;
  vertical-align: middle;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  font: 700 13px/1 system-ui, sans-serif;
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.help-btn::after { content: ""; position: absolute; inset: -11px; }    /* 44 px tap area */
.help-btn:hover, .help-btn:focus-visible { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.help-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.help-btn-static { cursor: default; margin-inline-start: 0; }
.help-btn-static::after { display: none; }

/* places where the button sits beside a group instead of inside a title */
#clipViews > .help-btn { align-self: center; }
.overlay-row > .help-btn, .legend > .help-btn { margin-block: 0; }
summary > .help-btn, summary .help-btn { margin-block: -6px; }

.help-backdrop {
  position: fixed; inset: 0; z-index: 70;
  display: flex; align-items: flex-end; justify-content: center;
  padding: 16px; padding-bottom: max(16px, env(safe-area-inset-bottom));
  background: rgba(0, 0, 0, 0.55);
  animation: help-fade 0.15s ease-out;
}
.help-sheet {
  width: min(440px, 100%); max-height: 80vh; overflow: auto;
  display: grid; gap: 10px; padding: 18px 16px 16px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  animation: help-up 0.2s var(--ease, ease-out);
}
.help-title { margin: 0; font-size: 1.05rem; }
.help-body { margin: 0; color: var(--muted); line-height: 1.45; }
.help-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 4px; }
.help-actions .btn { min-height: 44px; }
@media (min-width: 900px) { .help-backdrop { align-items: center; } }
@media (orientation: landscape) and (max-height: 500px) { .help-backdrop { align-items: center; } .help-sheet { max-height: 92vh; } }

.help-flash { animation: help-ring 0.8s ease-in-out 3; border-radius: 10px; }
@keyframes help-ring { 0%, 100% { box-shadow: 0 0 0 0 rgba(217, 242, 74, 0); } 50% { box-shadow: 0 0 0 4px var(--accent); } }
@keyframes help-fade { from { opacity: 0; } }
@keyframes help-up { from { transform: translateY(16px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .help-backdrop, .help-sheet { animation: none; } .help-flash { animation: none; outline: 3px solid var(--accent); } }

/* first-run line on Home */
.help-hint {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 10px; padding: 8px 6px 8px 12px;
  border: 1px solid var(--line); border-radius: var(--radius, 14px);
  background: var(--surface); color: var(--muted); font-size: 0.9rem;
}
[dir="rtl"] .help-hint { padding: 8px 12px 8px 6px; }
.help-hint-text { flex: 1; min-width: 0; }
.help-hint-close {
  flex: none; width: 44px; height: 44px; margin: -8px 0;
  border: 0; background: none; color: var(--faint); font-size: 22px; cursor: pointer;
}

.help-hint-tour { font-size: inherit; white-space: nowrap; }

/* Welcome tour (static/tour.js): full screen, 5 slides that swipe sideways. */
html.tour-open, html.tour-open body { overflow: hidden; }
.tour {
  position: fixed; inset: 0; z-index: 80;
  display: flex; flex-direction: column;
  padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: var(--bg); color: var(--text);
  overscroll-behavior: contain;
  animation: help-fade 0.2s ease-out;
}
.tour-top { display: flex; align-items: center; justify-content: space-between; min-height: 44px; }
.tour-count { color: var(--faint); font-size: 0.85rem; }
.tour-skip { min-width: 44px; min-height: 44px; padding: 0 10px; border: 0; background: none; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; }
.tour-track {
  flex: 1; min-height: 0; display: flex;
  overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; overscroll-behavior: contain;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.tour-track::-webkit-scrollbar { display: none; }
.tour-slide {
  flex: 0 0 100%; min-width: 0; scroll-snap-align: start; scroll-snap-stop: always;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  padding: 4px 2px;
  overflow: hidden;                /* a picture's shadow never shows on the next slide (iPhone: a dark edge) */
}
/* The picture box takes the room the words leave (capped), and the picture fills it by object-fit.
   No %-height inside a flex box of unknown height: iPhone WebKit drew the tall slide-5 picture as nothing. */
.tour-pic { position: relative; flex: 1 1 auto; min-height: 120px; max-height: 54vh; width: 100%; max-width: 440px; }
.tour-pic img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
  filter: drop-shadow(0 10px 22px rgba(0, 0, 0, 0.5));
}
.tour-text { width: 100%; max-width: 440px; text-align: center; overflow-y: auto; overscroll-behavior: contain; }
.tour-title { margin: 0 0 8px; font-family: var(--display); font-size: 1.5rem; line-height: 1.15; }
.tour-body { margin: 0; color: var(--muted); line-height: 1.5; }
.tour-dots { display: flex; justify-content: center; gap: 0; margin: 8px 0 6px; }
.tour-dot { width: 28px; height: 28px; padding: 0; border: 0; background: none; cursor: pointer; display: grid; place-items: center; }
.tour-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--line); transition: width 0.2s, background 0.2s; }
.tour-dot.is-on::before { width: 22px; border-radius: 4px; background: var(--accent); }
.tour-nav { display: flex; gap: 10px; width: 100%; max-width: 440px; margin: 0 auto; }
.tour-nav .btn { flex: 1; min-height: 48px; }
.tour-nav .btn:disabled { opacity: 0.35; }
@media (orientation: landscape) and (max-height: 560px) {
  .tour-slide { flex-direction: row; gap: 24px; padding: 0 8px; }
  .tour-pic { flex: 1 1 55%; max-height: 100%; height: 100%; max-width: none; }
  .tour-text { flex: 1 1 45%; text-align: start; max-height: 100%; }
  .tour-title { font-size: 1.3rem; }
  .tour-dots { margin: 4px 0; }
  .tour-nav { max-width: 520px; }
  .tour-nav .btn { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) { .tour { animation: none; } .tour-dot::before { transition: none; } }

/* tour slide 6: home-screen steps drawn as icons (tour.js installPicture) */
.tour-pic.tour-steps { position: static; display: flex; flex: 0 0 auto; min-height: 0; max-height: none; max-width: none; height: auto; align-items: center; justify-content: center; gap: 8px; flex-wrap: nowrap; padding: 18px 8px; }
.tour-step { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 92px; text-align: center; }
.tour-step-icon {
  display: grid; place-items: center; width: 72px; height: 72px;
  border: 1px solid var(--line); border-radius: 20px; background: var(--surface); color: var(--accent);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
}
.tour-step-icon svg { width: 34px; height: 34px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tour-step-word { font-size: 0.85rem; font-weight: 600; line-height: 1.25; color: var(--text); }
.tour-step-arrow { color: var(--faint); font-size: 1.3rem; margin-bottom: 30px; }
[dir="rtl"] .tour-step-arrow { transform: scaleX(-1); }
.tour-note { margin: 10px 0 0; color: var(--faint); font-size: 0.9rem; line-height: 1.45; }
.tour-install { margin-top: 12px; min-height: 44px; padding: 0 22px; }

/* Folds (user 2026-11-23: show that a section opens / closes). One chevron for every <details> row, the day /
   court groups on Home (.court-head, aria-expanded) and the Profile / Coming soon rows in More: down = closed,
   up = open, at the row's logical end (left in Hebrew). The whole row stays the tap target, >= 44 px. */
:root {
  --fold-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
details > summary { list-style: none; display: flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
details > summary::-webkit-details-marker { display: none; }
details[class] > summary { min-height: 44px; }   /* style.css gave some folds 40 px */
details > summary::marker { content: ""; }
details > summary::after,
[dir] .court-group .court-head:not(.is-selectable)::after {
  content: ""; flex: none; width: 20px; height: 20px; margin-inline-start: auto;
  background: currentColor; opacity: 0.75;
  -webkit-mask: var(--fold-chevron) center / contain no-repeat; mask: var(--fold-chevron) center / contain no-repeat;
  transition: transform 0.2s var(--ease, ease);
}
details[open] > summary::after,
[dir] .court-group .court-head[aria-expanded="true"]:not(.is-selectable)::after { transform: rotate(180deg); }
/* Closed folds look tappable: a card fold gets the More rows' tint, a fold inside a card is a small button. */
details.card:not([open]) { background: linear-gradient(100deg, rgba(43, 98, 224, 0.2), var(--surface) 70%); cursor: pointer; }
@media (hover: hover) { details.card:not([open]):hover { border-color: #46616a; } details:not(.card) > summary:hover { border-color: #46616a; } }
details:not(.card) > summary { padding: 0 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2, var(--surface)); color: var(--text); }
details:not(.card)[open] > summary { margin-bottom: 8px; }
/* More: Profile / Coming soon open a panel below them: their › turns into the same down / up chevron. */
.wiki-entry[aria-expanded] .wiki-chevron { display: inline-block; transform: rotate(90deg); transition: transform 0.2s var(--ease, ease); }
.wiki-entry[aria-expanded="true"] .wiki-chevron { transform: rotate(-90deg); }
/* Hebrew: the page draws "›" mirrored (‹), so the turn goes the other way. */
[dir="rtl"] .wiki-entry[aria-expanded] .wiki-chevron { transform: rotate(-90deg); }
[dir="rtl"] .wiki-entry[aria-expanded="true"] .wiki-chevron { transform: rotate(90deg); }
@media (prefers-reduced-motion: reduce) { details > summary::after, .court-head::after, .wiki-entry[aria-expanded] .wiki-chevron { transition: none; } }
