/* ONE sheet part for the phone (job S3-04, 20 Nov 2026). The behaviour is js/sheet.js (svSheet): one layer at a time,
   Back closes it, Escape closes it, Tab stays inside. This file is the look, and only at 600px and less: a wider
   screen keeps each pop-up's own look and place. Every pupil page that has a sheet loads it just before
   css/buttons.css (which stays the last style sheet, test u106).

   On a phone a menu, a panel or a pop-up is a SHEET FROM THE FOOT: the full width (Tom's answer Q4, 18 Nov 2026),
   as tall as its contents and never taller than the screen less a strip of the page, its head a larger handle, a
   title and a 44px close (the system's square, css/buttons.css), and the page behind dimmed by one scrim. The side
   panel (a lesson's tools, a practice lesson's tools) stops short of the edge with the page dimmed behind it (Q4).
   The !important marks below are deliberate: a pop-up places itself with inline styles and with its own rules,
   and on a phone this file decides where a sheet sits. Its fill colour stays the pop-up's own. */
:root{
  --sv-scrim: rgba(28, 22, 14, .48);
  --sv-sheet-radius: 16px;
  --sv-sheet-pad: 16px;
  --sv-sheet-gap: 48px;              /* the dimmed page left in view above a sheet as tall as the screen */
  /* --sv-scrim-look: the dim behind the sheets that change the page's look (Settings, Read your way, Colour overlay).
     Unset = the same dim as every sheet. One line to change (a question for Tom in the job's report). */
}
html.dark-mode, body.dark-mode{ --sv-scrim: rgba(0, 0, 0, .62); }   /* html too: About and legal hangs its backdrop on <html> */

.sv-sheet-head, .sv-scrim{ display:none; }

@media (max-width: 600px){
  /* the page behind: dimmed */
  .sv-scrim{ display:block; position:fixed; inset:0; z-index:900; background:var(--sv-scrim); touch-action:none; animation:sv-scrim-in .2s ease-out; }
  .sv-scrim[hidden]{ display:none; }
  .sv-scrim.is-look{ background:var(--sv-scrim-look, var(--sv-scrim)); }
  /* a pop-up that brings its own backdrop (translate, About and legal, the report form, the sign-out question) */
  .sv-sheet-back{ background:var(--sv-scrim) !important; padding:0 !important; align-items:flex-end !important; justify-content:center !important; }
  /* the side panel: it stops short of the edge, and the page beside it is dimmed */
  body.sidebar-panel-mode .mobile-overlay, #practice-page .panel-overlay{ background:var(--sv-scrim); }
  /* the lesson's tools: their head (title and close) spans the panel's whole width, so nothing that scrolls under it
     shows at its sides */
  body.sidebar-panel-mode .lesson-sidebar > .sidebar-panel-close{ margin-left:-1rem; margin-right:-1rem; padding-left:1rem; padding-right:1rem; }

  /* the sheet */
  .sv-sheet{
    position:fixed !important; inset:auto 0 0 0 !important; width:auto !important; min-width:0 !important; max-width:none !important;
    height:auto !important; max-height:calc(100vh - var(--sv-sheet-gap)) !important; max-height:calc(100dvh - var(--sv-sheet-gap)) !important;
    margin:0 !important; box-sizing:border-box !important;
    padding:0 var(--sv-sheet-pad) calc(var(--sv-sheet-pad) + env(safe-area-inset-bottom, 0px)) !important;
    border:0 !important; border-top:1px solid var(--sv-sheet-line, rgba(60, 45, 20, .12)) !important;
    border-radius:var(--sv-sheet-radius) var(--sv-sheet-radius) 0 0 !important;
    box-shadow:0 -14px 36px -16px rgba(30, 22, 10, .35) !important;
    overflow-x:hidden !important; overflow-y:auto !important; overscroll-behavior:contain;
    transform:none !important; translate:0 var(--sv-drag, 0px); transition:translate .22s cubic-bezier(.16, 1, .3, 1);
  }
  body.dark-mode .sv-sheet{ --sv-sheet-line: rgba(255, 255, 255, .08); }
  .sv-sheet.sv-up{ animation:sv-sheet-up .3s cubic-bezier(.16, 1, .3, 1); }
  .sv-sheet.sv-dragging{ transition:none; }
  .sv-sheet:focus{ outline:none; }
  .sv-sheet [data-sheet-own]{ display:none !important; }   /* a pop-up's own title and close: the head has them */

  /* its head: the handle, the title, the close */
  .sv-sheet-head{ display:flex; align-items:center; gap:8px; position:sticky; top:0; z-index:3;
    margin:0 calc(-1 * var(--sv-sheet-pad)) 4px; padding:18px 10px 6px var(--sv-sheet-pad); background:inherit; touch-action:none; cursor:grab; }
  .sv-sheet-head.is-grip{ padding:16px 0 0; margin-bottom:0; }
  .sv-sheet-grip{ position:absolute; top:7px; left:50%; width:48px; height:5px; margin-left:-24px; border-radius:3px; background:currentColor; opacity:.24; }
  .sv-sheet-title{ flex:1 1 auto; min-width:0; margin:0; font:700 1.1rem/1.3 'Schibsted Grotesk', system-ui, sans-serif; letter-spacing:0; text-transform:none; }
  .sv-sheet-x{ margin-left:auto; }

  /* the sheet a page places itself, with no head: the practice feedback (#pr-sheet). The same look */
  .sv-sheet-inline{ background:var(--bg-card, #fff); border-top:1px solid var(--border-light, #e8e4df); border-radius:var(--sv-sheet-radius) var(--sv-sheet-radius) 0 0;
    box-shadow:0 -12px 32px -14px rgba(40, 28, 12, .3); animation:sv-sheet-up .28s cubic-bezier(.16, 1, .3, 1); }
  body.dark-mode .sv-sheet-inline{ background:#262422; border-color:#3a3734; box-shadow:0 -12px 32px -14px rgba(0, 0, 0, .7); }

  /* the glossary: a word's meaning in a sheet at the foot, the page not dimmed (js/main/reading-tools.js) */
  .sv-term-sheet{ z-index:1300; background:var(--bg-card, #fff); color:var(--text-primary, #2d2a26); }
  .sv-term-sheet p{ margin:0 0 4px; font:400 1rem/1.55 var(--font-ui, 'Schibsted Grotesk', system-ui, sans-serif); }
  body.dark-mode .sv-term-sheet{ background:#262422; color:#f0ebe4; }
}
@keyframes sv-sheet-up{ from{ translate:0 32px; opacity:0; } to{ translate:0 0; opacity:1; } }
@keyframes sv-scrim-in{ from{ opacity:0; } to{ opacity:1; } }
@media (max-width: 600px) and (prefers-reduced-motion: reduce){
  .sv-sheet.sv-up, .sv-sheet-inline, .sv-scrim{ animation:none; }
  .sv-sheet{ transition:none; }
}

/* ==== The night look (job S6-01, 20 Nov 2026): the night's colours (css/buttons.css, --sv-night-*) ====
   The glossary's sheet, and the boxes page scripts draw over a page with the old charcoal written into them: the
   account menu and its AI allowance bar (js/ai-budget.js, js/dash-a11y.js), the sign-out question
   (js/progress-sync.js), the timer's badge (js/timer.js) and the screen between two steps of a session
   (js/plan-flow.js). Those scripts add their rules later in the page, so these carry the extra weight of "html". */
@media (max-width: 600px){
  body.dark-mode .sv-term-sheet{ background:var(--sv-night-card, #262422); color:var(--sv-night-ink, #f0ebe4); }
}
html body.dark-mode .sv-avmenu{ background:var(--sv-night-card, #211f1c); color:var(--sv-night-ink, #ece9e4); border-color:var(--sv-night-line, #36332e); }
html body.dark-mode .sv-avmenu .who{ color:var(--sv-night-mut, #8a857c); border-color:var(--sv-night-linel, #2b2925); }
html body.dark-mode .sv-aih{ border-color:var(--sv-night-linel, #2b2925); }
html body.dark-mode .sv-budget .bar{ background:var(--sv-night-page, #181614); border-color:var(--sv-night-line, #36332e); }   /* the AI allowance's bar: no cream track on a lesson at night */
html body.dark-mode .sv-avmenu > :is(a, button){ color:var(--sv-night-ink, #ece9e4); }
html body.dark-mode .sv-avmenu > :is(a, button):hover{ background:var(--sv-night-linel, #2b2925); }
html body.dark-mode #sv-so .sv-so-box{ background:var(--sv-night-card, #211f1c); color:var(--sv-night-ink, #ece9e4); }
html body.dark-mode .sv-tbadge{ background:var(--sv-night-card, #211f1c); color:var(--sv-night-ink, #ece9e4); border-color:var(--sv-night-line, #36332e); }
html body.dark-mode .svf{ background:var(--sv-night-page, #181614); color:var(--sv-night-ink, #ece9e4); }
html body.dark-mode .svf p{ color:var(--sv-night-sec, #b3aea6); }
