/* Generated from web/src/styles/chrome.css by web/scripts/sync-account-chrome.mjs: edit that, then run npm run sync:account-chrome. */
/* The header's look, shared by korzy.co (imported first by layouts/SiteLayout.astro) and the
   account pages on app.korzy.co (copied to service/api/korzy_api/accounts/web/chrome.css by
   scripts/sync-account-chrome.mjs; tests/theme.test.ts fails when the copy is stale): the palette
   by day and by night, the theme and account menus, the account chip and the phone menu. */

/* Light by default; html[data-mode="dark"] below by night. The head script (scripts/theme-data.ts)
   sets data-mode before the first paint: the visitor's choice, else the device's setting. */
:root {
  color-scheme: light;
  --paper: #ffffff;
  --paper-light: #ffffff;
  --paper-dark: #ebe5da;
  --ink: #21151c;
  --muted: #655a5f;
  --line: rgba(33, 21, 28, .15);
  --line-strong: rgba(33, 21, 28, .3);
  --wine: #550022;
  --wine-dark: #30111f;
  --wine-light: #70475a;
  /* Wine as a surface (buttons, the featured plan, the call-to-action band); --wine is also text. */
  --wine-fill: var(--wine);
  --wine-fill-hover: var(--wine-dark);
  --on-wine: #fbfaf6;
  --on-wine-muted: #e6e6e6;
  /* Neutral greys for quiet surfaces (pills, hover fills, the account circle) and their text. */
  --tint: #eeeeee;
  --tint-strong: #cccccc;
  --tint-ink: #333333;
  /* The one signal colour: a highlighter yellow under data from Korzy's records. */
  --highlight: #fff5b1;
  --highlight-ink: currentColor;
  --shadow: 0 18px 50px -34px rgba(48, 17, 31, .45);
  /* The header's account chip and its button: plain greys and near-black ink by day, so
     nothing in the corner reads pink; by night they keep the palette above. */
  --chip-fill: #ffffff;
  --chip-ink: #444444;
  --chip-line: #dddddd;
  --chip-text: #555555;
  --chip-text-strong: #111111;
  --chip-hover: rgb(17 17 17 / 7%);
  --chip-focus: #111111;
  --header-cta: #111111;
  --header-cta-hover: #333333;

  /* Frosted glass, as the map's Classic look draws its menus (app/src/themes/classic.css). */
  --c-glass: rgb(255 255 255 / 82%);
  --c-glass-strong: rgb(255 255 255 / 95%);
  --c-blur: blur(18px) saturate(170%);
  --c-line: rgb(16 28 33 / 9%);
  --c-fill: rgb(16 28 33 / 4.5%);
  --c-fill-strong: rgb(16 28 33 / 8.5%);
  --c-shadow-pop: 0 0 0 1px rgb(16 28 33 / 6%), 0 4px 12px rgb(16 28 33 / 8%), 0 28px 60px -12px rgb(16 28 33 / 28%);
  --c-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Night: flat neutral charcoal, white type, and the same deep wine for buttons, the demo frame and
   the mark. Accents are greys (as text, #ccc: 11:1 on charcoal); the highlighter turns low gold. */
html[data-mode="dark"] {
  color-scheme: dark;
  --paper: #121415;
  --paper-light: #121415;
  --paper-dark: #1c1e1f;
  --ink: #ffffff;
  --muted: #a6a7a9;
  --line: rgb(255 255 255 / 13%);
  --line-strong: rgb(255 255 255 / 22%);
  --wine: #cccccc;
  --wine-dark: #2b0a12;
  --wine-fill: #4b0917;
  --wine-fill-hover: #5f0d1f;
  --on-wine: #ffffff;
  --on-wine-muted: #eeeeee;
  --tint: #333333;
  --tint-strong: #555555;
  --tint-ink: #cccccc;
  --highlight: rgb(255 195 0 / 17%);
  --highlight-ink: #ffe7a3;
  --shadow: 0 18px 50px -34px rgb(0 0 0 / 75%);
  --chip-fill: var(--tint);
  --chip-ink: var(--tint-ink);
  --chip-line: var(--line-strong);
  --chip-text: var(--muted);
  --chip-text-strong: var(--ink);
  --chip-hover: var(--c-fill-strong);
  --chip-focus: var(--wine);
  --header-cta: var(--wine-fill);
  --header-cta-hover: var(--wine-fill-hover);

  /* The menus and the scrolled header: translucent charcoal with a hairline. */
  --c-glass: rgb(18 20 21 / 78%);
  --c-glass-strong: rgb(18 20 21 / 92%);
  --c-blur: blur(18px) saturate(140%);
  --c-line: rgb(255 255 255 / 10%);
  --c-fill: rgb(255 255 255 / 5%);
  --c-fill-strong: rgb(255 255 255 / 9%);
  --c-shadow-pop: 0 0 0 1px rgb(0 0 0 / 40%), 0 6px 14px rgb(0 0 0 / 35%), 0 30px 64px -12px rgb(0 0 0 / 75%);
}

/* Day to night: the page fades to its new colours (scripts/theme.ts sets data-look-switching for
   the change, as the map does). The menus keep their own open and close motion. */
@media (prefers-reduced-motion: no-preference) {
  html[data-look-switching],
  html[data-look-switching] *:not(.menu-popover),
  html[data-look-switching] *::before,
  html[data-look-switching] *::after {
    transition: background-color 320ms ease, border-color 320ms ease, color 320ms ease, fill 320ms ease, stroke 320ms ease, box-shadow 320ms ease !important;
  }
}

/* The account service sets korzy_signed_in on korzy.co; see signedInScript in data/site.ts. */
html:not(.signed-in) .signed-in-only, html.signed-in .signed-out-only { display: none !important; }

.menu-button, .mobile-menu { display: none; }

/* The account link, when signed in: the initials circle and the first name, one link with one hover
   (data/site.ts signedInNameScript fills them). Without a name, a person glyph and "Account". */
.nav-account {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 34px;
  padding: 5px 12px 5px 5px;
  border-radius: 999px;
  font-size: 14px;
  line-height: 1;
  text-decoration: none;
  color: var(--chip-text-strong);
  transition: background-color .16s, color .16s;
}
.nav-account:hover, .account-menu[data-open] .nav-account { background: var(--chip-hover); }
.nav-account:focus-visible { outline: 2px solid var(--chip-focus); outline-offset: 2px; }
.nav-account-avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--chip-fill);
  box-shadow: inset 0 0 0 1px var(--chip-line);
  color: var(--chip-ink);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .03em;
}
.nav-account-avatar svg { display: block; width: 14px; height: 14px; }
.nav-account-text { max-width: 104px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* A name is quiet grey until pointed at; "Account" reads as the other header links do. */
.nav-account[data-named] .nav-account-text { color: var(--chip-text); font-size: 13px; }
.nav-account[data-named]:is(:hover, [aria-expanded="true"]) .nav-account-text { color: var(--chip-text-strong); }
/* Below the full page width the centred links leave room only for the initials. */
@media (max-width: 1319px) {
  .nav-account[data-named] { padding-right: 5px; }
  .nav-account[data-named] .nav-account-text { display: none; }
}

/* The header's button ("Sign up", "Get an API key", "Open map"): ink by day. */
.site-header .button-dark { background: var(--header-cta); color: #ffffff; }
.site-header .button-dark:hover { background: var(--header-cta-hover); }
.site-header .button-dark:focus-visible { outline-color: var(--chip-focus); }

/* The theme and account menus: a small frosted panel, as the map draws its menus. Each opens on
   hover (after a short pause), on keyboard focus, and on click or tap (scripts/popover.ts). */
.theme-menu, .account-menu { position: relative; display: flex; }
.theme-trigger {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  transition: background-color .16s, color .16s;
}
.theme-trigger:hover, .theme-trigger[aria-expanded="true"] { background: var(--c-fill-strong); color: var(--ink); }
.theme-trigger:focus-visible { outline-offset: 2px; }
.theme-trigger svg { display: none; width: 17px; height: 17px; }
html[data-mode-choice="system"] .theme-trigger [data-icon="system"],
html[data-mode-choice="light"] .theme-trigger [data-icon="light"],
html[data-mode-choice="dark"] .theme-trigger [data-icon="dark"] { display: block; }
.menu-popover {
  position: absolute;
  z-index: 60;
  top: calc(100% + 8px);
  right: 0;
  display: grid;
  gap: 1px;
  min-width: 164px;
  padding: 5px;
  border: 1px solid var(--c-line);
  border-radius: 12px;
  background: var(--c-glass);
  box-shadow: var(--c-shadow-pop);
  -webkit-backdrop-filter: var(--c-blur);
  backdrop-filter: var(--c-blur);
  text-align: left;
  transform-origin: top right;
  /* Closing: quick and eased in, as the map's menus leave (app/src/motion.css). */
  opacity: 0;
  visibility: hidden;
  scale: .97;
  translate: 0 -4px;
  pointer-events: none;
  transition:
    opacity 120ms cubic-bezier(0.4, 0, 1, 1),
    scale 120ms cubic-bezier(0.4, 0, 1, 1),
    translate 120ms cubic-bezier(0.4, 0, 1, 1),
    visibility 0s linear 120ms,
    background-color 320ms ease,
    border-color 320ms ease;
}
/* Carries the pointer across the gap under the button. */
.menu-popover::before { content: ""; position: absolute; inset: -9px 0 auto; height: 9px; }
[data-open] > .menu-popover {
  opacity: 1;
  visibility: visible;
  scale: 1;
  translate: 0 0;
  pointer-events: auto;
  transition:
    opacity 160ms var(--c-ease),
    scale 160ms var(--c-ease),
    translate 160ms var(--c-ease),
    visibility 0s,
    background-color 320ms ease,
    border-color 320ms ease;
}
.menu-popover [role="menu"] { display: grid; gap: 1px; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 400;
  justify-content: flex-start;
  line-height: 1.2;
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
}
.menu-item > svg { flex: none; width: 15px; height: 15px; color: var(--muted); }
.menu-item > .theme-check { margin-left: auto; color: var(--wine); opacity: 0; scale: .6; transition: opacity .16s, scale .16s var(--c-ease); }
.menu-item[aria-checked="true"] > .theme-check { opacity: 1; scale: 1; }
.menu-item:is(:hover, :focus-visible) { background: var(--c-fill-strong); }
.menu-item:focus-visible { outline: 0; box-shadow: inset 0 0 0 1px var(--line-strong); }
/* The account menu: the account's pages, then signing out under a hairline. */
.account-popover { min-width: 216px; }
.menu-divider { height: 1px; margin: 4px 6px; background: var(--c-line); }

/* Narrow: the phone menu takes the theme switch and the account's rows; the account chip is just
   a link to the account page. */
@media (max-width: 900px) {
  .theme-menu, .account-popover { display: none; }
  .nav-account, .nav-account[data-named] { justify-content: center; min-width: 44px; min-height: 44px; padding: 0; }
  .nav-account-text { display: none; }
  .menu-button {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    align-items: center;
    width: 44px;
    height: 44px;
    margin-right: -10px;
    padding: 0;
    background: transparent;
    border: 0;
  }
  .menu-button:hover { background: transparent; }
  .menu-button > span:not(.sr-only) { display: block; width: 21px; height: 1px; background: var(--wine); transition: transform .2s; }
  .menu-button[aria-expanded=true] > span:nth-child(2) { transform: translateY(3px) rotate(45deg); }
  .menu-button[aria-expanded=true] > span:nth-child(3) { transform: translateY(-3px) rotate(-45deg); }
  .mobile-menu.open {
    position: absolute;
    top: 76px;
    left: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    padding: 12px 24px;
    pointer-events: auto;
    background: var(--paper-light);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 15px 35px rgba(48, 17, 31, .08);
  }
  .mobile-menu a { padding: 15px 0; border-bottom: 1px solid var(--line); font-size: 16px; text-decoration: none; }
  .mobile-menu a[aria-current] { color: var(--wine); }
  .mobile-menu .mobile-account { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
  .mobile-account-name { min-width: 0; overflow: hidden; color: var(--muted); font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
  /* The theme, as a three-way switch at the foot of the menu. */
  .mobile-theme { display: grid; gap: 10px; padding: 16px 0 8px; }
  .mobile-theme-label { color: var(--muted); font-size: 14px; }
  .mobile-theme-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: 10px; }
  .mobile-theme-options button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 8px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 14px;
    font-weight: 400;
  }
  .mobile-theme-options button:hover { background: var(--c-fill); color: var(--ink); }
  .mobile-theme-options svg { width: 15px; height: 15px; }
  .mobile-theme-options [aria-checked="true"] { background: var(--tint); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
  .mobile-theme-options button:focus-visible { outline-offset: 1px; }
}
