/* ===============================================================
   PROJECTS — the site switcher, "Add site" and the upgrade pop-up

   Shared by dashboard.html and settings.html, with projects.js.
   Load after theme.css: every colour comes from its tokens, so
   both themes work without anything extra here.
   =============================================================== */

/* ---- the chip ----
   The chip is the switcher. With one site and no account actions
   it is just a label; otherwise it gains an arrow and opens the
   list below. */
.client-switch { position: relative; }

.client-chip {
  display: flex; align-items: center; gap: 10px;
  height: 40px; padding: 0 15px 0 5px;
  border: 1px solid var(--rule); border-radius: 999px;
  background: var(--surface); box-shadow: var(--lift);
  font-family: inherit; color: var(--ink); text-align: left;
  cursor: default;
  transition: border-color 140ms ease;
}
.client-chip.is-switchable { cursor: pointer; padding-right: 12px; }
.client-chip.is-switchable:hover { border-color: var(--muted); }
.client-text { min-width: 0; }
.client-name {
  display: block; font-weight: 500; font-size: 14px; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.client-domain {
  display: block; color: var(--faint); font-size: 11.5px; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.client-caret {
  width: 16px; height: 16px; flex: none; margin-left: 4px;
  color: var(--muted); transition: transform 160ms ease;
}
.client-chip[aria-expanded="true"] .client-caret { transform: rotate(180deg); }

.logo-box {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--onyx); color: #fff;
  display: grid; place-items: center;
  font-weight: 600; font-size: 11px;
  overflow: hidden; flex: none;
}
.logo-box img { width: 100%; height: 100%; object-fit: contain; }
/* Once a real favicon loads, drop the dark tile so icons with
   transparent backgrounds are not sitting on black. */
.logo-box.has-img { background: #fff; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.logo-box.has-img img { padding: 4px; }

/* ---- the menu ---- */
.client-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 40;
  min-width: 100%; width: 290px;
  padding: 6px; border-radius: 14px;
  border: 1px solid var(--rule); background: var(--surface);
  box-shadow: var(--lift-high);
}
.pj-list { max-height: 320px; overflow-y: auto; }

.client-opt {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 7px 9px; border: none; border-radius: 9px;
  background: transparent; color: var(--ink);
  font-family: inherit; text-align: left; cursor: pointer;
}
.client-opt:hover, .client-opt:focus-visible { background: var(--rule-soft); outline: none; }
.client-opt .logo-box { width: 28px; height: 28px; }
.client-opt .client-text { flex: 1; }
.client-check { width: 16px; height: 16px; flex: none; color: var(--up); visibility: hidden; }
.client-opt[aria-selected="true"] .client-check { visibility: visible; }
.client-opt[aria-selected="true"] .client-name { font-weight: 600; }

/* The account action sits under a rule, apart from the sites, so
   it never reads as one more site in the list. */
.pj-foot { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--rule-soft); }
.pj-icon {
  width: 28px; height: 28px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  border: 1.5px dashed var(--faint); color: var(--muted);
}
.pj-icon svg { width: 14px; height: 14px; }
.pj-action[data-action="upgrade"] .pj-icon {
  border: none; background: var(--tint-sand); color: var(--tint-ink);
}
.pj-action .client-name { font-weight: 500; }
.pj-action:hover .pj-icon { border-color: var(--muted); color: var(--ink); }

/* ===============================================================
   THE POP-UP

   A native <dialog>. showModal() makes everything behind it inert,
   traps focus, and closes on Escape without any of it being
   rebuilt by hand. The page behind is blurred by the backdrop.
   =============================================================== */
.pj-dlg {
  width: min(560px, calc(100vw - 28px));
  max-height: calc(100vh - 40px);
  padding: 0; overflow: auto;
  border: 1px solid var(--rule); border-radius: 22px;
  background: var(--card); color: var(--ink);
  box-shadow: var(--lift-high);
}
.pj-dlg.is-wide { width: min(820px, calc(100vw - 28px)); }
.pj-dlg::backdrop {
  background: rgba(16, 19, 22, 0.32);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
[data-theme="dark"] .pj-dlg::backdrop { background: rgba(0, 0, 0, 0.5); }

/* Opening is a short rise, not a pop. Nothing moves for anyone who
   has asked for less motion. */
.pj-dlg[open] { animation: pj-rise 200ms cubic-bezier(.2, .8, .3, 1); }
@keyframes pj-rise { from { opacity: 0; translate: 0 10px; } }
@media (prefers-reduced-motion: reduce) { .pj-dlg[open] { animation: none; } }

.pj-inner { position: relative; padding: 28px 28px 24px; }

/* z-index lifts the X above .pj-inner. Both are positioned, and the
   inner area comes later in the page, so without it the inner area
   sat on top and swallowed every click on the X. */
.pj-close {
  position: absolute; top: 14px; right: 14px; z-index: 2;
  width: 34px; height: 34px; display: grid; place-items: center;
  border: none; border-radius: 50%; background: transparent;
  color: var(--muted); cursor: pointer;
}
.pj-close:hover { background: var(--rule-soft); color: var(--ink); }
.pj-close svg { width: 16px; height: 16px; }

.pj-mark {
  width: 44px; height: 44px; border-radius: 14px; margin-bottom: 16px;
  display: grid; place-items: center;
  background: var(--tint-mint); color: var(--tint-ink);
}
.pj-mark[data-kind="lock"] { background: var(--tint-sand); }
.pj-mark svg { width: 20px; height: 20px; }

.pj-dlg h2 { margin: 0 0 6px; font-size: 22px; font-weight: 600; letter-spacing: -0.025em; padding-right: 36px; }
.pj-sub { margin: 0 0 20px; color: var(--muted); font-size: 14px; max-width: 58ch; }
.pj-sub p { margin: 0 0 8px; }

.pj-notice {
  margin: 0 0 18px; padding: 10px 13px; border-radius: 10px;
  background: var(--tint-mint); color: var(--tint-ink); font-size: 13.5px;
}
.pj-notice[data-tone="info"] { background: var(--tint-lilac); }

.pj-field { display: grid; gap: 6px; margin-bottom: 14px; }
.pj-field label { font-size: 13px; font-weight: 500; }
.pj-field input, .pj-field textarea {
  width: 100%; font-family: inherit; font-size: 14px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--rule); border-radius: 10px;
  padding: 9px 12px; transition: border-color 140ms ease;
}
.pj-field input { height: 42px; }
.pj-field textarea { min-height: 104px; resize: vertical; line-height: 1.5; }
.pj-field input:hover, .pj-field textarea:hover { border-color: var(--faint); }
.pj-field input::placeholder, .pj-field textarea::placeholder { color: var(--faint); }
.pj-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pj-hint { margin: 0; font-size: 12.5px; color: var(--faint); }

/* LOCATION PICKER — shared by this modal's own location field, Settings, and onboarding
   (location-picker.js owns the behaviour; these classes are its only styling contract).
   Whichever field wraps the input+list needs position:relative — add .loc-field to it. */
.loc-field { position: relative; }
.loc-list {
  position: absolute; z-index: 5; top: calc(100% + 4px); left: 0; right: 0;
  max-height: 240px; overflow-y: auto; margin: 0; padding: 6px; list-style: none;
  background: var(--surface); border: 1px solid var(--rule); border-radius: 12px;
  box-shadow: var(--lift);
}
.loc-opt {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 10px; border-radius: 8px; font-size: 13.5px; cursor: pointer;
}
.loc-opt:hover, .loc-opt.is-active { background: var(--rule-soft); }
.loc-opt-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.loc-opt-tag { flex: none; font-size: 11px; color: var(--faint); }

/* PLACE PICKER (place-picker.js, 6 Oct 2026): a country (flags, a search box), then a town searched inside it. Used by
   the setup page, Settings and Add a site. The two fields sit side by side, and stack when their own box is narrower
   than 480px (a container query, so a phone, a dialog and a settings card all behave). The page's field class gives
   the labels their look. */
.pp { container-type: inline-size; }
.loc-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
@container (max-width: 479px) { .loc-pair { grid-template-columns: minmax(0, 1fr); } }
.loc-pair > .pp-field, .loc-pair > .pp-field + .pp-field { margin: 0; }
.pp .loc-note { margin: 8px 0 0; }
.loc-note b { color: var(--ink); font-weight: 600; }
.loc-note.is-error { color: var(--down); font-weight: 500; }

.dd { position: relative; }
.dd-btn {
  width: 100%; height: 42px; display: flex; align-items: center; gap: 10px; padding: 0 12px;
  font: inherit; font-size: 14px; color: var(--ink); text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-control, 10px);
  transition: border-color 140ms ease;
}
.dd-btn:hover:not(:disabled), .dd-btn[aria-expanded="true"] { border-color: var(--muted); }
.dd-btn:disabled { cursor: default; background: var(--rule-soft); }
/* The app's purple focus ring, drawn just inside: outside, the Add a site dialog (overflow: auto) cut it off. */
.dd-btn:focus-visible { outline-offset: -2px; }
.dd.is-error .dd-btn { border-color: var(--down); }
.dd-value { flex: 1; min-width: 0; display: flex; align-items: center; gap: 9px; }
.dd-value span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-value.is-placeholder { color: var(--muted); }
.dd-chev { width: 16px; height: 16px; flex: none; color: var(--muted); transition: transform 160ms ease; }
.dd-btn[aria-expanded="true"] .dd-chev { transform: rotate(180deg); }
.flag { width: 20px; height: 15px; flex: none; border-radius: 3px; object-fit: cover; box-shadow: 0 0 0 1px rgba(20, 26, 34, .12); }
.dd-panel {
  position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; right: 0; min-width: 240px; padding: 6px;
  background: var(--surface); border: 1px solid var(--rule); border-radius: 12px; box-shadow: var(--lift-high);
}
.dd-search {
  display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 10px;
  border: 1px solid var(--rule); border-radius: 8px; background: var(--surface); transition: border-color 140ms ease;
}
.dd-search:focus-within { border-color: var(--muted); }
.dd-search svg { width: 15px; height: 15px; flex: none; color: var(--muted); }
/* .pp in front: the pages' own ".field input" / ".pj-field input" rules (and their :focus) must not reach this box. */
.pp .dd-search input, .pp .dd-search input:focus {
  flex: 1; min-width: 0; width: auto; height: 100%; padding: 0; border: 0; border-radius: 0; outline: 0; box-shadow: none;
  background: transparent; font: inherit; font-size: 14px; color: var(--ink);
}
.pp .dd-search input::placeholder { color: var(--faint); }
.dd-list { position: relative; list-style: none; margin: 6px 0 0; padding: 0; max-height: 264px; overflow-y: auto; overscroll-behavior: contain; }
.dd-opt { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; font-size: 14px; cursor: pointer; }
.dd-opt:hover, .dd-opt.is-active { background: var(--rule-soft); }
.dd-opt-main { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-opt-sub { flex: 1 1 0; min-width: 0; text-align: right; font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-opt.is-selected .dd-opt-main { font-weight: 600; }
.dd-opt .dd-tick { width: 15px; height: 15px; flex: none; margin-left: auto; color: var(--up); }
.dd-empty { padding: 10px; font-size: 13px; color: var(--muted); }
.pj-places { margin-bottom: 14px; }   /* the picker inside Add a site, spaced like a .pj-field */

/* Which site the keywords go to, named in the form itself. */
.pj-target {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 1px 8px; border-radius: 999px;
  background: var(--rule-soft); font-weight: 600;
}

.pj-status { min-height: 1.3em; margin: 2px 0 0; font-size: 13px; color: var(--down); }

.pj-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 18px; }
.pj-actions .pj-next { margin-left: auto; font-size: 12.5px; color: var(--faint); }

.pj-btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 40px; padding: 0 18px;
  font-family: inherit; font-size: 14px; font-weight: 500; white-space: nowrap;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--rule); border-radius: 999px; cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, opacity 140ms ease;
}
.pj-btn:hover:not(:disabled) { border-color: var(--muted); }
.pj-btn:disabled { opacity: .45; cursor: default; }
.pj-btn-primary { background: var(--onyx); border-color: var(--onyx); color: #fff; }
.pj-btn-primary:hover:not(:disabled) { border-color: var(--onyx); background: #22272A; }
[data-theme="dark"] .pj-btn-primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* ---- plan cards ---- */
.pj-plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.pj-plan {
  display: flex; flex-direction: column;
  padding: 18px; border-radius: 16px;
  border: 1px solid var(--rule); background: var(--surface);
}
.pj-plan-name { font-weight: 600; font-size: 15px; }
.pj-plan-for { color: var(--muted); font-size: 12.5px; line-height: 1.4; margin-top: 2px; min-height: 2.8em; }
/* Sites lead, because sites are what this pop-up is about. */
.pj-plan-sites { margin: 14px 0 2px; font-size: 30px; font-weight: 600; letter-spacing: -0.03em; line-height: 1; }
.pj-plan-sites span { font-size: 14px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.pj-plan-kw { font-size: 13px; color: var(--muted); }
.pj-plan-price { margin: 14px 0; padding-top: 12px; border-top: 1px solid var(--rule-soft); font-size: 14px; }
.pj-plan-price b { font-size: 18px; font-weight: 600; }
.pj-plan-price span { color: var(--muted); font-size: 12.5px; }
.pj-plan .pj-btn { margin-top: auto; width: 100%; }
/* Enterprise (3 Oct 2026): a slim row under the plans, linking to the request form on the website. */
a.pj-btn { text-decoration: none; }
.pj-plan--enterprise { grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: space-between; gap: 16px; }
.pj-plan--enterprise .pj-plan-for { min-height: 0; max-width: 56ch; }
.pj-plan--enterprise .pj-btn { margin-top: 0; width: auto; flex: none; }
@media (max-width: 520px) { .pj-plan--enterprise { flex-direction: column; align-items: stretch; } .pj-plan--enterprise .pj-btn { width: 100%; } }

.pj-loading { padding: 30px 0; color: var(--muted); font-size: 14px; }

/* ---- narrow screens ---- */
@media (max-width: 680px) {
  .client-switch { flex: 1 1 100%; order: -1; }
  .client-chip { width: 100%; }
  .client-caret { margin-left: auto; }
  .client-menu { left: 0; right: 0; width: auto; }
  .pj-inner { padding: 24px 18px 20px; }
  /* Stacked, the fields' own bottom margin is the spacing. */
  .pj-row { grid-template-columns: 1fr; gap: 0; }
  .pj-actions .pj-next { margin-left: 0; width: 100%; }
}
