/* Sky UI (admin preview). Loaded only when html.sky is set by base.html; every rule is scoped to html.sky so the classic look is untouched.
   The living sky is a WebGL canvas (#sky-canvas, static/sky/sky.js). Content sits on frosted glass above it. */

/* ---------- theme tokens: day / night / overcast ---------- */
html.sky[data-sky="day"] {
  color-scheme: light;
  --sky-top: #2f6fd8; --sky-bot: #cfe2f6;
  --bg: #dbe9f8; --bg-2: #eef5fc;
  --surface: rgba(255,255,255,.48); --surface-solid: rgba(250,252,255,.94); --surface-2: rgba(30,80,150,.08);
  --sheet: rgba(255,255,255,.54); --glass-edge: rgba(255,255,255,.75); --glass-solid: rgba(255,255,255,.82);
  --fg: #0d1d33; --muted: #4a5d77; --line: rgba(20,60,120,.14);
  --accent: #1f63d6; --accent-2: #0ea5e9; --accent-3: #0284c7; --accent-fg: #ffffff;
  --grad: linear-gradient(100deg, #1f63d6, #3b8cf0);
  --danger: #c42a3c; --ok: #15803d; --chip: rgba(31,99,214,.09);
  --shadow: 0 10px 34px rgba(20,60,120,.14); --input-bg: rgba(255,255,255,.85);
  --hero-fg: #ffffff; --hero-muted: rgba(255,255,255,.9); --hero-shadow: 0 1px 18px rgba(10,40,90,.35);
}
html.sky[data-sky="night"] {
  color-scheme: dark;
  --sky-top: #02040d; --sky-bot: #101830;
  --bg: #070b18; --bg-2: #0c1224;
  --surface: rgba(16,24,46,.45); --surface-solid: rgba(14,20,40,.94); --surface-2: rgba(160,190,255,.09);
  --sheet: rgba(10,16,34,.48); --glass-edge: rgba(170,200,255,.16); --glass-solid: rgba(14,20,40,.8);
  --fg: #e8eefc; --muted: #9aa8c6; --line: rgba(170,200,255,.14);
  --accent: #8ab4ff; --accent-2: #c4b5fd; --accent-3: #7dd3fc; --accent-fg: #071026;
  --grad: linear-gradient(100deg, #6f9cff, #a8c4ff);
  --danger: #ff7a8e; --ok: #4ade80; --chip: rgba(138,180,255,.12);
  --shadow: 0 12px 40px rgba(0,0,0,.45); --input-bg: rgba(8,12,26,.7);
  --hero-fg: #f3f6ff; --hero-muted: #c3cde4; --hero-shadow: 0 1px 18px rgba(0,0,0,.5);
}
html.sky[data-sky="overcast"] {
  color-scheme: light;
  --sky-top: #8e979f; --sky-bot: #d9dcdf;
  --bg: #d5d9dd; --bg-2: #e6e8ea;
  --surface: rgba(244,246,248,.5); --surface-solid: rgba(246,247,249,.95); --surface-2: rgba(40,60,85,.08);
  --sheet: rgba(240,242,245,.56); --glass-edge: rgba(255,255,255,.6); --glass-solid: rgba(246,247,249,.82);
  --fg: #18222e; --muted: #4e5b69; --line: rgba(30,45,65,.15);
  --accent: #35577d; --accent-2: #5b7a99; --accent-3: #3f6f8f; --accent-fg: #ffffff;
  --grad: linear-gradient(100deg, #35577d, #4f7299);
  --danger: #b4283a; --ok: #2f7a43; --chip: rgba(53,87,125,.1);
  --shadow: 0 10px 30px rgba(30,40,55,.14); --input-bg: rgba(255,255,255,.82);
  --hero-fg: #16202b; --hero-muted: #34414f; --hero-shadow: 0 1px 16px rgba(255,255,255,.55);
}

/* ---------- page background: the sky ---------- */
html.sky body {
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bot) 62%, var(--bg) 100%) fixed;
  padding-left: 72px; transition: padding-left .25s ease;
}
html.sky body.sky-rail-open { padding-left: 232px; }
#sky-canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: -1; display: block; pointer-events: none; image-rendering: auto; }
html.sky .site-footer { border-top: 0; color: var(--hero-muted); text-shadow: var(--hero-shadow); }

/* ---------- side rail ---------- */
.sky-rail { position: fixed; z-index: 1200; top: 12px; bottom: 12px; left: 12px; width: 52px;
  display: flex; flex-direction: column; align-items: stretch; gap: 4px; padding: 10px 6px;
  border-radius: 20px; transition: width .25s ease; }
/* the glass sits on a pseudo-element so fixed menus inside the rail are not clipped by backdrop-filter */
.sky-rail::before { content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit;
  background: var(--surface); border: 1px solid var(--glass-edge); box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(22px) saturate(1.3); backdrop-filter: blur(22px) saturate(1.3); }
body.sky-rail-open .sky-rail { width: 208px; }
.sky-rail ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.rail-brand { display: flex; align-items: center; gap: 10px; padding: 2px 4px 10px; margin-bottom: 6px; border-bottom: 1px solid var(--line);
  color: var(--fg); text-decoration: none; font-weight: 600; white-space: nowrap; overflow: hidden; }
.rail-brand .logo-mark { width: 32px; height: 32px; flex: none; }
.rail-item { position: relative; display: flex; align-items: center; gap: 12px; width: 100%; height: 40px; padding: 0 10px;
  border-radius: 12px; border: 0; background: transparent; color: var(--muted); text-decoration: none; cursor: pointer;
  font: inherit; font-size: .92rem; text-align: left; white-space: nowrap; transition: background .15s, color .15s; }
.rail-item .icon { width: 20px; height: 20px; flex: none; }
.rail-item:hover, .rail-drop.open > .rail-item { background: var(--surface-2); color: var(--fg); }
.rail-item[aria-current], .rail-item[data-current] { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.rail-item[aria-current]::before { content: ""; position: absolute; left: -6px; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: var(--accent); }
.rail-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.rail-label { overflow: hidden; text-overflow: ellipsis; opacity: 0; width: 0; transition: opacity .15s; }
body.sky-rail-open .rail-label { opacity: 1; width: auto; flex: 1; }
.rail-fill { flex: 1; }
.rail-actions { display: flex; flex-direction: column; gap: 4px; padding-top: 8px; border-top: 1px solid var(--line); }
.rail-pin .icon { transition: transform .25s; }
body.sky-rail-open .rail-pin .icon { transform: scaleX(-1); }

/* tooltips (collapsed rail, mouse only) */
.rail-tip { display: none; }
@media (hover: hover) and (min-width: 761px) {
  body:not(.sky-rail-open) .rail-item:hover > .rail-tip, body:not(.sky-rail-open) .rail-item:focus-visible > .rail-tip {
    display: flex; flex-direction: column; gap: 2px; position: absolute; left: calc(100% + 14px); top: 50%; transform: translateY(-50%);
    min-width: max-content; max-width: 280px; white-space: normal; padding: 8px 12px; border-radius: 10px;
    background: var(--surface-solid); color: var(--fg); border: 1px solid var(--line); box-shadow: var(--shadow); font-size: .88rem; pointer-events: none; }
  .rail-tip small { color: var(--muted); font-size: .8rem; max-width: 260px; white-space: normal; }
}

/* menus that open from the rail: to the right, aligned with the bottom of their button */
html.sky .sky-rail .menu { position: absolute; top: auto; bottom: -6px; left: calc(100% + 14px); right: auto; min-width: 280px; max-width: min(340px, calc(100vw - 100px));
  max-height: calc(100vh - 40px); overflow: auto; margin: 0;
  background: var(--surface-solid); border: 1px solid var(--glass-edge); box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); }
html.sky .sky-rail .dropdown > .menu::before { display: none; }
/* Tools > category > tools, like the classic Tools menu: opens beside the rail, categories cascade to the right */
html.sky .sky-rail .rail-tools > .menu { top: -8px; bottom: auto; overflow: visible; max-height: none; min-width: 250px; }
html.sky .sky-rail .menu.sub { top: -8px; bottom: auto; left: calc(100% + 8px); min-width: 320px; overflow: visible; }
html.sky .sky-rail .dropdown > .menu::before, html.sky .sky-rail .menu.sub::before { display: block; content: ""; position: absolute; top: 0; bottom: 0; left: -16px; width: 16px; right: auto; height: auto; }
html.sky .sky-rail .menu-item[aria-current] { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.rail-drop.open > .rail-item > .rail-tip { display: none !important; }
html.sky .sky-rail .menu-item { border: 0; background: transparent; width: 100%; text-align: left; font: inherit; cursor: pointer; }
html.sky .sky-rail .menu-item:hover { background: var(--surface-2); }
.sky-email { text-transform: none !important; letter-spacing: 0 !important; overflow: hidden; text-overflow: ellipsis; }
.sky-seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 3px; border-radius: 12px; background: var(--surface-2); }
.sky-seg.two { grid-template-columns: 1fr 1fr; }
.sky-seg button { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 4px; border: 0; border-radius: 9px;
  background: transparent; color: var(--muted); font-size: .8rem; cursor: pointer; }
.sky-seg.two button { flex-direction: row; justify-content: center; }
.sky-seg button[aria-checked="true"] { background: var(--glass-solid); color: var(--fg); box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.sky-seg .icon { width: 18px; height: 18px; }
.sky-stats { margin: 0; font-size: .78rem; }
.sky-off { margin-top: 8px; padding: 8px; border: 1px dashed var(--line); border-radius: 10px; background: transparent; color: var(--muted); font-size: .85rem; cursor: pointer; }
.sky-off:hover { color: var(--fg); border-color: var(--accent); }

/* first-visit hint */
.sky-hint { position: fixed; z-index: 1250; left: 84px; bottom: 20px; max-width: 340px; padding: 14px 16px; border-radius: 16px;
  background: var(--surface-solid); color: var(--fg); border: 1px solid var(--glass-edge); box-shadow: var(--shadow); font-size: .9rem; }
body.sky-rail-open .sky-hint { left: 244px; }
.sky-hint p { margin: 0 0 10px; }
body:has(.sky-rail .dropdown.open) .sky-hint { display: none; }

/* ---------- surfaces: frosted glass ---------- */
html.sky main.page { margin: 20px auto; padding: 28px; border-radius: 24px; width: calc(100% - 40px);
  background: var(--sheet); border: 1px solid var(--glass-edge); box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(24px) saturate(1.2); backdrop-filter: blur(24px) saturate(1.2); }
html.sky main.page.narrow { max-width: 480px; }
html.sky .card, html.sky .steps li, html.sky .tool-card { background: var(--surface); border: 1px solid var(--glass-edge); box-shadow: none; border-radius: 18px; }
html.sky main.page .card { background: var(--glass-solid); }
html.sky .tool-card::after { display: none; }
html.sky .tool-card { -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); transition: transform .2s, box-shadow .2s; }
html.sky .tool-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
html.sky .tool-icon { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
html.sky .result, html.sky .pdm-panel { background: var(--glass-solid); border-color: var(--glass-edge); }
html.sky .menu { background: var(--surface-solid); border-color: var(--glass-edge); }
html.sky input, html.sky select, html.sky textarea { background: var(--input-bg); border-color: var(--line); border-radius: 10px; }
html.sky input:focus, html.sky select:focus, html.sky textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 0; border-color: var(--accent); }

/* ---------- buttons: quiet and flat ---------- */
html.sky .btn { border-radius: 10px; }
html.sky .btn.primary, html.sky button.primary, html.sky .button.primary { background: var(--accent); color: var(--accent-fg); border-color: transparent; box-shadow: none; }
html.sky .btn.primary:hover, html.sky button.primary:hover { transform: none; box-shadow: none; background: color-mix(in srgb, var(--accent) 86%, var(--fg)); }
html.sky .btn.outline { background: color-mix(in srgb, var(--accent) 9%, transparent); border-color: transparent; color: var(--accent); }
html.sky .btn.outline:hover { background: color-mix(in srgb, var(--accent) 16%, transparent); }
html.sky .btn.ghost:hover { background: var(--surface-2); }
html.sky button, html.sky .button { border-radius: 10px; }

/* ---------- home: the hero floats on the sky ---------- */
html.sky .hero, html.sky[data-theme="light"] .hero:not(.has-image) { background: transparent; color: var(--hero-fg); min-height: calc(86vh - 24px); }
html.sky .hero-bg, html.sky .hero-art { display: none; }
html.sky .hero-inner { grid-template-columns: 1fr; max-width: 980px; }
html.sky .hero-copy h1, html.sky[data-theme="light"] .hero:not(.has-image) h1 { background: none; color: var(--hero-fg); -webkit-text-fill-color: currentColor; text-shadow: var(--hero-shadow); }
html.sky .hero .eyebrow, html.sky[data-theme="light"] .hero:not(.has-image) .eyebrow, html.sky .hero .lead, html.sky[data-theme="light"] .hero:not(.has-image) .lead { color: var(--hero-muted); text-shadow: var(--hero-shadow); }
html.sky .hero-mark i { background: var(--hero-fg); opacity: .8; }
html.sky .hero .btn.outline, html.sky[data-theme="light"] .hero:not(.has-image) .btn.outline { color: var(--hero-fg); background: color-mix(in srgb, var(--hero-fg) 14%, transparent); border-color: color-mix(in srgb, var(--hero-fg) 35%, transparent); }
html.sky .hero.has-image { background: linear-gradient(90deg, rgba(5,10,26,.75), rgba(5,10,26,.2)), var(--hero-image) center / cover no-repeat; color: #fff; }
html.sky .section-inner { background: var(--sheet); border: 1px solid var(--glass-edge); border-radius: 24px; box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px); }
html.sky .section-inner { padding: 32px; }
html.sky .how { background: transparent; }
html.sky .pdm-panel label.check { flex-direction: row; }

/* ---------- tools ---------- */
html.sky .ds-app { --ds-head: 0px; }
html.sky .leaflet-container { border-radius: 14px; }
/* night street map: a dark filter over the OpenStreetMap tiles only; satellite / orthophoto tiles are never filtered */
html.sky[data-sky="night"]:not(.sky-mapfilter-off) img.leaflet-tile[src*="tile.openstreetmap.org"] {
  filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9) saturate(.6); }
html.sky[data-sky="night"] .leaflet-container { background: #0b1222; }
.sky-mapfilter { position: absolute; z-index: 1001; left: 50%; bottom: 10px; transform: translateX(-50%); display: none;
  padding: 5px 12px; border-radius: 999px; border: 1px solid var(--glass-edge); background: var(--surface-solid); color: var(--fg);
  font-size: .8rem; cursor: pointer; box-shadow: var(--shadow); }
html.sky[data-sky="night"] .sky-mapfilter.has-street { display: block; }
.sky-globe { position: absolute; inset: 0; z-index: 1100; width: 100%; height: 100%; border-radius: inherit; cursor: pointer; }
.sky-globe-hint { position: absolute; z-index: 1101; left: 50%; bottom: 16px; transform: translateX(-50%); padding: 6px 14px; border-radius: 999px;
  background: var(--surface-solid); color: var(--fg); font-size: .85rem; pointer-events: none; transition: opacity .4s; white-space: nowrap; }

/* ---------- admin button in the classic gear menu ---------- */
.sky-try { width: 100%; white-space: normal; text-align: center; }

/* ---------- phones: the rail becomes a bottom bar ---------- */
@media (max-width: 760px) {
  html.sky body, html.sky body.sky-rail-open { padding-left: 0; padding-bottom: 76px; }
  .sky-rail, body.sky-rail-open .sky-rail { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; height: 60px; flex-direction: row; align-items: center; padding: 6px; gap: 2px; }
  .sky-rail::before { background: var(--surface-solid); }
  .rail-brand, .rail-pin, .rail-fill { display: none; }
  .sky-rail ul.rail-list { flex-direction: row; flex: 1; overflow-x: auto; scrollbar-width: none; gap: 2px; }
  .sky-rail ul.rail-list::-webkit-scrollbar { display: none; }
  .rail-actions { flex-direction: row; border-top: 0; border-left: 1px solid var(--line); padding: 0 0 0 4px; }
  .rail-item { flex-direction: column; justify-content: center; gap: 2px; width: 58px; height: 48px; padding: 0 2px; font-size: .64rem; }
  .rail-list .rail-label, body.sky-rail-open .rail-list .rail-label { opacity: 1; width: auto; max-width: 56px; flex: none; }
  .rail-actions .rail-item { width: 42px; }
  .rail-actions .rail-label { display: none; }
  .rail-item[aria-current]::before { left: 14px; right: 14px; top: auto; bottom: -6px; width: auto; height: 3px; }
  html.sky .sky-rail .menu { position: fixed; left: 8px; right: 8px; bottom: 76px; top: auto; min-width: 0; max-width: none; max-height: 70vh; }
  html.sky .section-inner { padding: 20px 16px; }
  html.sky main.page { width: calc(100% - 16px); margin: 8px auto; padding: 18px 14px; border-radius: 18px; }
  .sky-hint { display: none; }
  html.sky .sky-rail .rail-tools > .menu { top: auto; bottom: 76px; overflow: auto; max-height: 70vh; }
  html.sky .sky-rail .menu.sub { position: static; display: flex; min-width: 0; margin: 2px 0 6px 14px; padding: 2px 0;
    background: transparent; border: 0; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
  html.sky .sky-rail .dropdown > .menu::before, html.sky .sky-rail .menu.sub::before { display: none; }
  html.sky .sky-rail .has-sub .chev { display: none; }
}
@media (prefers-reduced-motion: reduce) { .sky-rail, html.sky body, .rail-label { transition: none; } }
