/* ============================================================
   Sepiaki — base styles.

   RULES ONLY. Every design token lives in theme.css (spec 17 §2), which the
   import below pulls in. The `@import` must stay the *first* at-rule in this
   file: a rule before it makes the browser drop it silently, and the whole app
   then renders with no tokens at all.
   ============================================================ */
@import "theme.css";

/* The product's three families, served from THIS origin (spec 21 §6.2, spec 31
   §6). They used to arrive from Google's font CDN on every page load, which is
   a connection to a third party before the app has asked for a byte and is now
   forbidden without the PO's explicit yes. The same files are what the server
   measures A4 sheets with, so the Preview and the PDF shape text from the bytes
   the browser is displaying — same bytes on both sides.

   Eleven static woff2, one per weight in use, committed under `vendor/fonts/`;
   no `unicode-range` split, because one upstream file already covers latin +
   latin-ext. `swap` here (unlike the render, which blocks): the SPA is a UI and
   a paint delay would be worse than a re-flow, while a render that measured in
   a fallback would be silently wrong. */
@font-face { font-family: "Schibsted Grotesk"; font-style: normal; font-weight: 400; font-display: swap;
             src: url(vendor/fonts/SchibstedGrotesk-Regular.woff2) format("woff2"); }
@font-face { font-family: "Schibsted Grotesk"; font-style: normal; font-weight: 500; font-display: swap;
             src: url(vendor/fonts/SchibstedGrotesk-Medium.woff2) format("woff2"); }
@font-face { font-family: "Schibsted Grotesk"; font-style: normal; font-weight: 600; font-display: swap;
             src: url(vendor/fonts/SchibstedGrotesk-SemiBold.woff2) format("woff2"); }
@font-face { font-family: "Schibsted Grotesk"; font-style: normal; font-weight: 700; font-display: swap;
             src: url(vendor/fonts/SchibstedGrotesk-Bold.woff2) format("woff2"); }
@font-face { font-family: "Schibsted Grotesk"; font-style: normal; font-weight: 800; font-display: swap;
             src: url(vendor/fonts/SchibstedGrotesk-ExtraBold.woff2) format("woff2"); }
@font-face { font-family: "Hanken Grotesk"; font-style: normal; font-weight: 400; font-display: swap;
             src: url(vendor/fonts/HankenGrotesk-Regular.woff2) format("woff2"); }
@font-face { font-family: "Hanken Grotesk"; font-style: normal; font-weight: 500; font-display: swap;
             src: url(vendor/fonts/HankenGrotesk-Medium.woff2) format("woff2"); }
@font-face { font-family: "Hanken Grotesk"; font-style: normal; font-weight: 600; font-display: swap;
             src: url(vendor/fonts/HankenGrotesk-SemiBold.woff2) format("woff2"); }
@font-face { font-family: "Hanken Grotesk"; font-style: normal; font-weight: 700; font-display: swap;
             src: url(vendor/fonts/HankenGrotesk-Bold.woff2) format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 400; font-display: swap;
             src: url(vendor/fonts/JetBrainsMono-Regular.woff2) format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 500; font-display: swap;
             src: url(vendor/fonts/JetBrainsMono-Medium.woff2) format("woff2"); }
/* spec 34 D6 — the Sobre theme's face (Noto Sans, as the reference .docx), same bytes as the server render. */
@font-face { font-family: "Noto Sans"; font-style: normal; font-weight: 400; font-display: swap;
             src: url(vendor/fonts/NotoSans-Regular.woff2) format("woff2"); }
@font-face { font-family: "Noto Sans"; font-style: normal; font-weight: 700; font-display: swap;
             src: url(vendor/fonts/NotoSans-Bold.woff2) format("woff2"); }

/* spec 16 §3 — the three utility classes components reach for. */
.tap { min-width: var(--tap); min-height: var(--tap); }
/* SortHead (spec 14 §5.2): touch-only floor, so the desktop column headers keep
   their compact height. Twinned like the tokens (spec 17 THM-04). */
@media (pointer: coarse) {
  .sort-head { min-width: var(--tap); min-height: var(--tap); }
}
:root[data-touch="on"] .sort-head { min-width: var(--tap); min-height: var(--tap); }
.hscroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }

/* Hover feedback, structurally impossible on touch: a rule inside
   @media (hover: hover) cannot match, whereas React state set from `mouseenter`
   has no guarantee of ever being cleared (mobile browsers fire `mouseenter` on
   tap and frequently never fire `mouseleave`). `!important` is required — the
   background it overrides is an inline style. Callers tune the colours with the
   --hov-bg / --hov-bc custom properties, which are per-element and therefore
   deliberately *not* declared on :root. */
@media (hover: hover) {
  .hov:not(:disabled):hover { background: var(--hov-bg, var(--hov-bg-default)) !important; }
  .hov-b:not(:disabled):hover { border-color: var(--hov-bc, var(--hov-bc-default)) !important; }
  .pv-row:hover { background: var(--surface-2); }
}

/* Phone navigation drawer (spec 16 §5.2). The sidebar stays an <aside> in all
   three states — two harnesses detect the booted shell with page.$('aside'). */
.nav-drawer {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 120;
  /* The resting transform stays (it is what holds the drawer off-screen at boot,
     spec 16 TCH-13); the .22s slide is gone — spec 17 §2.6.4. */
  transform: translateX(-100%);
  padding-left: env(safe-area-inset-left); box-shadow: var(--sh-lg);
}
.nav-drawer.open { transform: translateX(0); }
/* The one dim allowed by spec 15 §2 beside the re-auth overlay and the
   full-area editing modes — amended by spec 16 §4: this is not a surface
   competing with the page, it is the page's own chrome. */
.nav-scrim { position: fixed; inset: 0; z-index: 119; background: var(--scrim); }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  /* Mobile URL-bar chrome makes 100% taller than the visible viewport, which is
     what gives a full-height flex app a phantom vertical scroll (spec 16 §5.1).
     The 100% first is its own fallback. */
  height: 100%;
  height: 100dvh;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--fnt-ui);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#root { height: 100%; }

h1, h2, h3, h4 {
  font-family: var(--fnt-head);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--ink);
}

button { font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* Scrollbars */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
  background: var(--scrollbar);
  border-radius: 10px;
  border: 3px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-hover); background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ---- Reusable bits ---- */

.mono { font-family: var(--fnt-mono); }

.app-frame {
  display: flex;
  height: 100%;
  overflow: hidden;
}

/* Entrance animations — opacity only since SEPIAKI-85 (spec 17 §2.6): no frame
   here may move or resize its box. Fill-mode stays `backwards`, never
   `forwards`/`both`: harmless for an opacity animation, and kept because the
   hazard it guards is what a future author restoring the travel would re-create
   — a filled transform animation keeps applying an (identity) transform after it
   finishes, which makes the element a permanent containing block for
   position:fixed descendants, so every fixed popover, modal and click-away
   backdrop anchors to it instead of the viewport. */
.fade-in { animation: fadeIn .34s cubic-bezier(.2,.7,.2,1) backwards; }
@keyframes fadeIn { from { opacity: 0; } }

/* rise-in decorates centered modals carrying their own inline
   translate(-50%,-50%), so this animation must never touch `transform` — it
   would override the centring mid-flight. Opacity only (SEPIAKI-85). */
.rise-in { animation: riseIn .4s cubic-bezier(.2,.7,.2,1) backwards; }
@keyframes riseIn { from { opacity: 0; } }

/* Studio edit mode: the agent chat fades in (SEPIAKI-85 — it used to slide 60px
   from the right). */
.slide-in-right { animation: slideInRight .32s cubic-bezier(.2,.7,.2,1) backwards; }
@keyframes slideInRight { from { opacity: 0; } }

/* Document editor pane (PV studio/detail + template editor): full-height shell
   (the toolbar is the app's DocBar, mounted with bar:false), and the paper
   scrolls in its own area like the preview panel. overflow-x hidden: the block
   hover chrome (rail, row hover zones) sticks out a few px past the paper and
   would otherwise show a horizontal scrollbar on narrow windows. */
.doc-editor-pane .ev2-shell { display: flex; flex-direction: column; height: 100%; min-height: 0; width: 100%; max-width: none; margin: 0; }
/* overflow-x auto, not hidden: the paper is a fixed 210mm (A4) — on a viewport
   narrower than the sheet the panel scrolls sideways rather than squeezing a
   document whose whole point is its print geometry. */
.doc-editor-pane .ev2-paperwrap { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: auto; padding: var(--page-pad-y) var(--page-pad-x) 60px; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulseDot { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

.caret { display: inline-block; width: 2px; height: 1.05em; margin-left: 2px; border-radius: 2px; background: var(--accent); vertical-align: -2px; animation: caretBlink .9s step-end infinite; }
@keyframes caretBlink { 50% { opacity: 0; } }

/* Markdown (agent chat bubbles) */
.md-body > :first-child { margin-top: 0; }
.md-p { margin: 0; }
.md-p + .md-p, .md-h, .md-list, .md-pre, .md-quote { margin-top: 8px; }
.md-h { font-family: var(--fnt-head, inherit); font-weight: 700; line-height: 1.3; }
.md-h1 { font-size: 15px; }
.md-h2 { font-size: 14px; }
.md-h3 { font-size: 13.5px; }
.md-list { margin-bottom: 0; padding-left: 20px; }
.md-li { margin: 2px 0; }
.md-li::marker { color: var(--muted); }
.md-code { font-family: var(--fnt-mono); font-size: .88em; background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: .5px 4px; }
.md-pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 10px 12px; overflow-x: auto; }
.md-pre code { font-family: var(--fnt-mono); font-size: 12.5px; line-height: 1.5; white-space: pre; background: none; border: none; padding: 0; }
.md-quote { margin-bottom: 0; padding: 2px 0 2px 10px; border-left: 3px solid var(--border-strong); color: var(--ink-2); }
.md-link { color: var(--accent-deep); text-decoration: underline; }
.md-table-wrap { overflow-x: auto; max-width: 100%; margin-top: 8px; }
.md-table { border-collapse: collapse; font-size: 12.5px; }
.md-table th, .md-table td { border: 1px solid var(--border); padding: 4px 8px; vertical-align: top; text-align: left; overflow-wrap: normal; word-break: normal; min-width: 3em; }
.md-table th { background: var(--surface-2); font-weight: 600; }

/* Voice waveform */
.wave { display: flex; align-items: center; gap: 2.5px; height: 32px; }
.wave i {
  width: 3px; border-radius: 3px; background: currentColor;
  animation: waveJump 1s ease-in-out infinite;
}
@keyframes waveJump {
  0%, 100% { height: 5px; opacity: .55; }
  50% { height: 26px; opacity: 1; }
}
/* The one .spinring in the tree: the shared <Spinner> of spec 17 §5 owns it,
   and both colours come from tokens (the ten hand-rolled copies each pinned
   the *old* accent in their track). */
.spinring {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid var(--spin-track); border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}

.shimmer {
  background: linear-gradient(100deg, var(--skeleton-a) 30%, var(--skeleton-b) 50%, var(--skeleton-a) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite linear;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.progress-track { height: 6px; border-radius: 6px; background: var(--border); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--accent), var(--accent-deep)); transition: width .3s ease; }

/* Striped image placeholder */
.ph {
  background-color: var(--ph-bg);
  background-image: repeating-linear-gradient(135deg, var(--ph-stripe) 0 9px, var(--ph-bg) 9px 18px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted-2);
  font-family: var(--fnt-mono);
  font-size: 10px;
  letter-spacing: .04em;
  text-transform: uppercase;
  border-radius: var(--r-sm);
  overflow: hidden;
}

/* focus ring */
.focusable:focus-visible,
input:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* .pv-row:hover lives in the @media (hover: hover) block above — spec 16 §5.4:
   on a touch device the rule must be unable to match, or a tapped row keeps its
   highlight until another is tapped. */

/* ============================================================
   the per-role ceiling slider (spec 27 §6.3)

   The one native range input in the app. It is a choice on a discrete ladder,
   and a stack of buttons would hide the shape of that ladder. Track and thumb
   use the same tokens as the segmented control. The 20 px height and the 16 px
   thumb are the export's own sizing and are what keep it above the coarse
   pointer floor.
   ============================================================ */
.u-range{-webkit-appearance:none;appearance:none;height:20px;background:transparent;cursor:pointer;margin:0}
.u-range::-webkit-slider-runnable-track{height:6px;border-radius:6px;background:var(--surface-2);border:1px solid var(--border)}
.u-range::-moz-range-track{height:6px;border-radius:6px;background:var(--surface-2);border:1px solid var(--border)}
.u-range::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:16px;height:16px;margin-top:-5px;border-radius:50%;background:var(--surface);border:2px solid var(--accent);box-shadow:var(--sh-sm)}
.u-range::-moz-range-thumb{width:16px;height:16px;border-radius:50%;background:var(--surface);border:2px solid var(--accent);box-shadow:var(--sh-sm)}
.u-range:focus-visible::-webkit-slider-thumb{box-shadow:0 0 0 3px var(--accent-soft)}
.u-range:disabled{opacity:.5;cursor:default}

/* Sectioned template panel (SEPIAKI-69, spec 29 §8.4): « Informations » above,
   « Configuration » — the filiation colour and the deletions switch — below.
   Own templates only: a preset carries no row menu and cannot reach this. */
.cfg-section { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border); }
.cfg-section-h { font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
                 color: var(--muted); margin-bottom: 12px; }

/* Spec 04 §11.4.3 (SEPIAKI-190) — the support-session banner, above the top bar. */
.support-banner { display: flex; align-items: center; gap: 10px; flex-shrink: 0;
                  padding: 6px 20px; padding-top: max(6px, env(safe-area-inset-top));
                  background: var(--c-vif-amber-soft); border-bottom: 1px solid var(--c-vif-amber-bc);
                  color: var(--c-vif-amber-deep); font-size: 13px; font-weight: 600; }
.support-banner__exit { min-height: var(--tap); padding: 0 14px; border-radius: var(--r-sm); cursor: pointer;
                        border: 1px solid var(--c-vif-amber-deep); background: var(--surface); color: var(--c-vif-amber-deep);
                        font: inherit; }
