/* The glass of the portal: the sidebar and the cards of every page (loaded after all the other stylesheets, so that it wins over the sticker look of sticker.css). Measured on a
   notification of iOS 26 laid over a picture of white and red lettering on black (IMG_2382 against IMG_2383): inside, the picture is not blurred much but is faint (about a fifth of
   its contrast, over a grey that is lighter than black), the edge is thin and bright along the top and the bottom and the light there is the colour of what lies behind, the corners
   are large, and the picture bends along the border. So: a small blur, a veil that carries most of the colour, thin lines of light, and the edge of glass.js (a canvas under the
   content: the picture taken from outside the border, brightened). Nothing here is heavy: one small backdrop blur for each card, and layers that only move when the page scrolls.
   The colour of the light at the edge is the picture's: glass.js. */
:root {
  --gl-r: 24px; /* the corners (the banner of iOS has them at a quarter of its height) */
  --gl-veil-0: light-dark(rgba(255, 255, 255, 0.66), rgba(54, 58, 78, 0.74));
  --gl-veil: var(--gl-veil-0);
  --gl-blur: blur(2px) saturate(1.35);
  /* Measured on the slider of iOS 26 over black (IMG_2384): a line of one pixel along the top and the bottom edge (about a third of white), a faint glow that dies in about 14px, and
     nothing at the sides, nothing outside. */
  --gl-line: light-dark(rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0.16));
  --gl-glow: light-dark(rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.04));
}

/* ---- the cards ---- */
:is(.settings-card, .fw-card, .notice, .post-row, .post-preview, .server-storage, .mp-card, .await-note, .mc-pane, .mc-players-section, .mc-settings-section, .mc-stat, .ov-card, .ov-box, .ov-line, .ov-ai, .mc-danger, .ps-card, .intro-card) {
  position: relative;
  isolation: isolate;
  border: 0;
  border-radius: var(--gl-r);
  box-shadow: none;
  background: var(--gl-veil);
  -webkit-backdrop-filter: var(--gl-blur);
  backdrop-filter: var(--gl-blur);
}
/* The line of light: only along the top and the bottom; at the sides there is nothing but the bend. Over the edge (glass.js), under the content. */
:is(.settings-card, .fw-card, .notice, .post-row, .post-preview, .server-storage, .mp-card, .await-note, .mc-pane, .mc-players-section, .mc-settings-section, .mc-stat, .ov-card, .ov-box, .ov-line, .ov-ai, .mc-danger, .ps-card, .intro-card)::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 1px 0 var(--gl-line), inset 0 -1px 0 var(--gl-line), inset 0 7px 6px -5px var(--gl-glow), inset 0 -7px 6px -5px var(--gl-glow);
}
/* The edge: a canvas that glass.js draws (the picture from outside the border, bent and brightened), under the line and the content. */
.gl-ring {
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  pointer-events: none;
}
.post-row:hover { background: light-dark(rgba(255, 255, 255, 0.8), rgba(72, 77, 100, 0.8)); }
.fw-card[data-state="error"] { box-shadow: inset 0 0 0 1.5px var(--error); }

/* A table cannot have a child that is not a row: the glass of it is its own background and a line, with no edge. */
.table {
  border: 0;
  border-radius: calc(var(--gl-r) - 6px);
  background: var(--gl-veil);
  box-shadow: inset 0 1px 0 var(--gl-line), inset 0 -1px 0 var(--gl-line), inset 0 7px 6px -5px var(--gl-glow), inset 0 -7px 6px -5px var(--gl-glow);
  -webkit-backdrop-filter: var(--gl-blur);
  backdrop-filter: var(--gl-blur);
}
@container table-wrap (max-width: 800px) {
  .table { background: none; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
}

/* ---- the sidebar: a pane that floats 12px from the edges of the window, as the sidebar pane of macOS 26 System Settings does ----
   Its body and its 1px line are painted by glass.js from the picture behind the page (side-glass.js has the measured model): colours that follow the picture (not the dimming of the page: the sidebar is the same on every page), one opaque line, no
   glow, no blur, and the soft shadow of a window. Until they are painted (and where no canvas is possible) the pane is a flat colour. The narrow one, a bar, keeps what sticker.css gives it. */
:root {
  --side-flat: light-dark(#e9edf6, #1d2027);
  --side-shadow: light-dark(rgba(30, 40, 70, 0.26), rgba(0, 0, 0, 0.55));
  --side-shadow-near: light-dark(rgba(30, 40, 70, 0.16), rgba(0, 0, 0, 0.4));
}
@media (min-width: 761px) {
  .shell { grid-template-columns: 264px minmax(0, 1fr); } /* 240px of pane (as wide as the pane of Safari's sidebar next to it in a screenshot), and 12px of air on each side */
  .sidebar {
    top: 12px;
    height: calc(100dvh - 24px);
    margin: 12px;
    border: 0;
    border-radius: 17px; /* the pane of System Settings and the one of Safari are 16.7-17.5px to the centre of the line */
    isolation: isolate;
    background: var(--side-flat);
    box-shadow: 0 14px 60px 2px var(--side-shadow), 0 2px 8px var(--side-shadow-near); /* the shadow of a window of macOS, spread wide */
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .shell:has(.cap-page) { grid-template-columns: 92px minmax(0, 1fr); }
  .shell:has(.cap-page) .sidebar:is(:hover, :focus-within) { width: 240px; }
  /* The list as the sidebar of Safari lays it out (measured on a screenshot next to ours): rows of 32px with no gap, 10px in from the line on both sides, the icon's ink 22px and the
     label 50px from the line, the label 13.5px semibold (a little tighter: its words are as wide as there). */
  .side-nav { padding: 4px 10px 0; }
  .side-item { margin: 0; }
  .side-link { gap: 9px; padding: 0 4px 0 6.5px; font-size: 13.5px; font-weight: 600; letter-spacing: -0.2px; }
  /* The current page is a flat pill, as in Safari's sidebar (radius 8px, no border), in the colour of the line of the logo. */
  .side-link { border-radius: 8px; }
  .side-link[aria-current="page"] { border-width: 1.5px; border-color: transparent; background: var(--logo-ink); }
  /* The logo and the name sit in the row where Safari's sidebar has its two icons: 10px below the top and 10px from the left end, 17px high; the name has the colour of the logo (in the dark: white at half strength);
     the list starts 54px down. */
  .sidebar .brand { align-self: flex-start; height: 17px; margin: 10px 0 23px 10px; color: var(--logo-ink); font-size: 17px; line-height: 17px; }
  .sg-body, .sg-line { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: inherit; pointer-events: none; }
  .sg-body { z-index: -2; }
  .sg-line { z-index: -1; }
}
/* In the dark the labels and the icons are white, as in Safari's sidebar (the current page keeps its own colours). */
@media (min-width: 761px) {
  :root[data-theme="dark"] .sidebar .side-link:not([aria-current="page"]) { color: #fff; }
  :root[data-theme="dark"] .sidebar .side-link:not([aria-current="page"]) .side-icon { color: #f2f5fb; }
  :root[data-theme="dark"] .sidebar .brand { color: rgba(255, 255, 255, 0.5); }
}
@media (min-width: 761px) and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sidebar .side-link:not([aria-current="page"]) { color: #fff; }
  :root:not([data-theme="light"]) .sidebar .side-link:not([aria-current="page"]) .side-icon { color: #f2f5fb; }
  :root:not([data-theme="light"]) .sidebar .brand { color: rgba(255, 255, 255, 0.5); }
}
/* No shadow where the page dims the picture behind it (the pages of a server, the plan builder, 구독 관리, an opened notice: the dark appearance only, backdrop.css). */
@media (min-width: 761px) {
  :root[data-theme="dark"] body:has(.dash-page, .pb, .pm, .post-area) .sidebar { box-shadow: none; }
}
@media (min-width: 761px) and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body:has(.dash-page, .pb, .pm, .post-area) .sidebar { box-shadow: none; }
}
@media (max-width: 760px), (forced-colors: active) { .sg-body, .sg-line { display: none; } }
@media (forced-colors: active) { .sidebar { border: 1px solid CanvasText; } }

/* ---- no transparency asked for: solid ---- */
@media (prefers-reduced-transparency: reduce) {
  :root { --gl-veil-0: light-dark(#f2f3f7, #2c2f42); --gl-blur: none; }
  .gl-ring { display: none; }
}
/* A browser that cannot blur a backdrop: a denser veil. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root { --gl-veil-0: light-dark(rgba(255, 255, 255, 0.86), rgba(48, 54, 82, 0.9)); }
}
