/* =========================================================================
   common.css — shared by every page (loaded after style.css)
   All colours live in :root below (style.css has none of its own). Colours, navbar profile menu, buttons, notices, dialogs, form controls.
   Page-specific styles live in dist/css/pages/<page>.css.
   ========================================================================= */

:root {
  /* ---- Brand: MillionPodcasts primary (#4b5fc9). Change these and the whole site follows. ---- */
  --brand: #4b5fc9;
  --brand-deep: #3a4aa8;      /* hover / pressed, dark links */
  --brand-soft: #eef0fb;      /* light backgrounds: active nav on phone, badges, quiet-button hover */
  --brand-tint: #dfe4f8;      /* selected rows, text selection */
  --ring: 0 0 0 3px rgba(75, 95, 201, .24);

  /* ---- Neutrals (slightly cool, to sit with the blue) ---- */
  --ink: #161a2b;             /* headings, strong text */
  --ink-2: #363c52;           /* body copy */
  --muted: #5d6478;           /* secondary text */
  --faint: #9097aa;           /* placeholders, captions */
  --line-strong: #b8bfd2;     /* control hover border */
  --line: #dde1eb;            /* card borders */
  --ctl-line: #d5dae6;        /* form control borders */
  --hairline: #e9ecf2;        /* dividers */
  --mist: #f4f5fa;            /* tinted section / hover background */
  --panel: #f8f9fc;           /* sidebars, table heads */
  --shade: 22, 26, 43;        /* rgb of --ink, for shadows and backdrops: rgba(var(--shade), .5) */

  /* ---- Code panels ---- */
  --code-bg: #1d1f27;
  --code-panel: #171921;
  --code-card: #141830;       /* product page sample */

  /* ---- Status & accent ---- */
  --success: #2f7a52;
  --success-soft: #e7f3ec;
  --warning: #9a5b00;
  --warning-soft: #fdf3e3;
  --danger: #a1352b;
  --danger-soft: #fbeceb;
  --pollen: #e9b44c;          /* gold accent: API tag, highlights */
  --pollen-soft: #fbf1dc;

  /* ---- HTTP method badges (docs) ---- */
  --get: #2563eb;    --get-bg: #eaf1fe;
  --post: #15803d;   --post-bg: #e9f7ee;
  --put: #b45309;    --put-bg: #fbf1e1;
  --delete: #c0392b; --delete-bg: #fbeae8;
  --patch: #7c3aed;  --patch-bg: #f2ecfb;

  /* ---- Names style.css uses (kept as aliases so its rules pick up the palette) ---- */
  --accent: var(--brand);
  --accent-dark: var(--brand-deep);
  --accent-soft: var(--brand-soft);
  --ink-soft: var(--muted);
  --ink-faint: var(--faint);
  --line-soft: var(--hairline);

  /* ---- Type & shape ---- */
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --display: var(--sans);
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(var(--shade), .04), 0 1px 1px rgba(var(--shade), .03);
  --shadow-md: 0 8px 24px rgba(var(--shade), .08), 0 2px 6px rgba(var(--shade), .05);
}

/* ---------- Navbar (views/common/navbar.php) ----------
   Selectors start with header.topbar so older generic "header …" rules in style.css don't leak in. */
header.topbar { position: sticky; top: 0; z-index: 40; display: block; height: auto; padding: 0; margin: 0; gap: 0;
                background: rgba(255, 255, 255, .92); -webkit-backdrop-filter: saturate(160%) blur(10px); backdrop-filter: saturate(160%) blur(10px);
                border-bottom: 1px solid var(--hairline); }
header.topbar .tb-inner { display: flex; align-items: center; gap: 20px; height: 60px; padding: 0 24px; box-sizing: border-box; }
header.topbar a { text-decoration: none; }

header.topbar .tb-brand { display: inline-flex; align-items: center; gap: 10px; flex: none; color: var(--ink); border-radius: 10px; }
header.topbar .tb-brand:focus-visible { outline: none; box-shadow: var(--ring); }
header.topbar .tb-mark { width: 32px; height: 32px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center;
                         background: var(--brand); color: #fff; font-size: 16px; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .18); }
header.topbar .tb-brand:hover .tb-mark { background: var(--brand-deep); }
header.topbar .tb-word { font-family: var(--display); font-size: 17px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
header.topbar .tb-tag { font-family: var(--sans); font-size: 11px; font-weight: 600; letter-spacing: .04em; padding: 3px 7px; border-radius: 6px;
                        background: var(--pollen-soft); color: #7a5a14; border: 1px solid #f0dcae; }

header.topbar .tb-search { position: relative; flex: 0 1 380px; margin-left: 8px; }
header.topbar .tb-search input { display: block; width: 100%; height: 36px; box-sizing: border-box; padding: 0 36px 0 36px; margin: 0;
                                 font: inherit; font-size: 14px; color: var(--ink); background: var(--mist); border: 1px solid transparent; border-radius: 9px;
                                 transition: border-color .15s, background-color .15s, box-shadow .15s; -webkit-appearance: none; appearance: none; }
header.topbar .tb-search input::placeholder { color: var(--faint); }
header.topbar .tb-search input:hover { border-color: var(--line); }
header.topbar .tb-search input:focus { outline: none; background: #fff; border-color: var(--brand); box-shadow: var(--ring); }
header.topbar .tb-search input::-webkit-search-cancel-button { display: none; }
header.topbar .tb-search-icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); font-size: 13px; color: var(--muted); pointer-events: none; }
header.topbar .tb-kbd { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); min-width: 18px; padding: 1px 5px; box-sizing: border-box;
                        font-family: var(--sans); font-size: 11px; line-height: 16px; text-align: center; color: var(--muted);
                        background: #fff; border: 1px solid var(--line); border-radius: 5px; pointer-events: none; }
header.topbar .tb-search input:focus ~ .tb-kbd { display: none; }

header.topbar .tb-menu { display: flex; align-items: center; gap: 18px; margin-left: auto; }
header.topbar .tb-links { display: flex; align-items: center; gap: 4px; margin: 0; }
header.topbar .tb-links a { position: relative; display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 12px; border-radius: 8px;
                            font-size: 14px; font-weight: 600; color: var(--muted); white-space: nowrap; }
header.topbar .tb-links a i { font-size: 12px; opacity: .8; }
header.topbar .tb-links a:hover { color: var(--ink); background: var(--mist); }
header.topbar .tb-links a:focus-visible { outline: none; box-shadow: var(--ring); }
header.topbar .tb-links a.is-active { color: var(--brand); }
header.topbar .tb-links a.is-active::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -12px; height: 2px; border-radius: 2px; background: var(--brand); }

header.topbar .tb-toggle { display: none; margin-left: auto; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 9px;
                           background: #fff; color: var(--ink); font-size: 16px; cursor: pointer; }
header.topbar .tb-toggle:focus-visible { outline: none; box-shadow: var(--ring); }

/* Tablet: drop the icons, keep everything on one row */
@media (max-width: 1080px) {
  header.topbar .tb-links a i { display: none; }
  header.topbar .tb-inner { gap: 14px; padding: 0 18px; }
}

/* Phone: links + profile fold into a menu; docs search moves to its own row */
@media (max-width: 760px) {
  header.topbar .tb-inner { flex-wrap: wrap; height: auto; min-height: 56px; padding: 9px 16px; row-gap: 9px; }
  header.topbar .tb-word { font-size: 16px; }
  header.topbar .tb-toggle { display: inline-flex; align-items: center; justify-content: center; }
  header.topbar .tb-search { order: 3; flex: 1 0 100%; margin: 0; }
  header.topbar .tb-kbd { display: none; }
  header.topbar .tb-menu { display: none; order: 2; flex: 1 0 100%; flex-direction: column; align-items: stretch; gap: 8px;
                           margin: 0; padding: 8px 0 6px; border-top: 1px solid var(--hairline); }
  header.topbar.is-open .tb-menu { display: flex; }
  header.topbar .tb-links { flex-direction: column; align-items: stretch; gap: 2px; }
  header.topbar .tb-links a { height: 42px; font-size: 15px; }
  header.topbar .tb-links a i { display: inline-block; width: 16px; text-align: center; }
  header.topbar .tb-links a.is-active { background: var(--brand-soft); }
  header.topbar .tb-links a.is-active::after { display: none; }
  header.topbar .auth-nav { padding: 8px 12px 2px; border-top: 1px solid var(--hairline); }
  header.topbar .auth-login { flex: 1; justify-content: center; text-align: center; }
  header.topbar .auth-dropdown { position: static; margin-top: 8px; box-shadow: none; }
}
@media (max-width: 380px) {
  header.topbar .tb-word { display: none; }
}

/* ---------- Navbar: login button / profile menu ---------- */
.auth-nav { display: flex; align-items: center; gap: 10px; }
.auth-login { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; padding: 8px 16px; font-size: 14px; border-radius: 8px; background: var(--brand); color: #fff; font-weight: 600; text-decoration: none; }
.auth-login:hover { background: var(--brand-deep); }
.auth-menu { position: relative; }
.auth-menu > summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; }
.auth-menu > summary::-webkit-details-marker { display: none; }
.auth-menu > summary:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 999px; }
.auth-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--line);
               display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: var(--brand); }
.auth-dropdown { position: absolute; right: 0; top: calc(100% + 8px); min-width: 240px; max-width: 300px; background: #fff;
                 border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .08); padding: 6px; z-index: 50; }
.auth-dropdown .who { padding: 8px 10px 10px; border-bottom: 1px solid var(--hairline); margin-bottom: 4px; min-width: 0; }
.auth-dropdown .who b { display: block; font-size: 14px; font-weight: 600; color: var(--ink); }
.auth-dropdown .who span { display: block; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.auth-dropdown a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; color: inherit; text-decoration: none; }
.auth-dropdown a i { width: 14px; color: var(--muted); text-align: center; }
.auth-dropdown a:hover { background: var(--mist); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; box-sizing: border-box;
       padding: 10px 16px; border-radius: 10px; border: 1px solid var(--brand); background: var(--brand); color: #fff;
       font: inherit; font-size: 14px; font-weight: 700; line-height: 1.2; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--brand-deep); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn-quiet { background: #fff; color: var(--brand); }
.btn-quiet:hover { background: var(--brand-soft); }
.btn-danger { background: #fff; color: var(--danger); border-color: #e6c3bf; }
.btn-danger:hover { background: var(--danger-soft); }
.btn.loading { opacity: .7; cursor: progress; }
.btn[disabled]:not(.loading) { background: transparent; border-color: var(--line); color: var(--muted); cursor: default; }

/* ---------- Notices and inline errors ---------- */
.note { padding: 12px 16px; border-radius: 10px; font-size: 14px; margin: 0 0 18px; }
.note-info { background: var(--brand-soft); color: var(--brand-deep); }
.note-err { background: var(--danger-soft); color: var(--danger); }
.err { color: var(--danger); font-size: 13px; }
.err:empty { display: none; }

/* ---------- Dialogs ---------- */
dialog.dialog { border: 0; border-radius: 16px; padding: 26px; max-width: 460px; width: calc(100% - 32px); color: var(--ink);
                box-shadow: 0 24px 64px rgba(var(--shade), .28); }
dialog.dialog::backdrop { background: rgba(var(--shade), .5); }
.dialog h3 { margin: 0 0 10px; font-size: 19px; }
.dialog p { margin: 0 0 16px; line-height: 1.6; color: var(--ink-2); }
.dialog label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.dialog .ctl { margin-bottom: 12px; }
.dialog .err { margin-bottom: 12px; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 6px; }

/* ---------- Form controls (one height, border and focus style) ---------- */
.ctl { display: block; width: 100%; height: 38px; margin: 0; padding: 0 12px; box-sizing: border-box;
       font: inherit; font-size: 14px; color: var(--ink); background: #fff;
       border: 1px solid var(--ctl-line); border-radius: 8px; box-shadow: none; transition: border-color .15s, box-shadow .15s; }
textarea.ctl { height: auto; min-height: 80px; padding: 9px 12px; line-height: 1.5; resize: vertical; }
.ctl::placeholder { color: var(--faint); }
.ctl:hover { border-color: var(--line-strong); }
.ctl:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.ctl-wrap { position: relative; }
.ctl-wrap .ctl { padding-right: 38px; }
.ctl-icon { position: absolute; right: 13px; top: 50%; transform: translateY(-50%); font-size: 12px; color: var(--muted); pointer-events: none; }
select.ctl { -webkit-appearance: none; -moz-appearance: none; appearance: none; cursor: pointer; }
.ctl[type="date"]::-webkit-calendar-picker-indicator { position: absolute; right: 0; top: 0; width: 40px; height: 100%; opacity: 0; cursor: pointer; }

/* Toggle chips (multi-select) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; display: inline-flex; cursor: pointer; margin: 0; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.chip span { display: inline-flex; align-items: center; gap: 7px; min-height: 32px; padding: 0 12px; border-radius: 999px;
             border: 1px solid var(--ctl-line); background: #fff; font-size: 13px; color: var(--ink-2); line-height: 1.2;
             transition: background-color .15s, border-color .15s, color .15s; user-select: none; }
.chip span i { display: none; font-size: 11px; }
.chip:hover span { border-color: var(--line-strong); }
.chip input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip input:checked + span i { display: inline-block; }
.chip input:focus-visible + span { box-shadow: var(--ring); }

/* Switch with on/off labels:
   <label class="switch"><input type="checkbox"><span class="sw"></span><span class="sw-off">…</span><span class="sw-on">…</span></label> */
.switch { display: inline-flex; align-items: center; gap: 9px; font-size: 13px; color: var(--muted); cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.switch .sw { position: relative; flex: none; width: 30px; height: 18px; border-radius: 999px; background: var(--ctl-line); transition: background-color .15s; }
.switch .sw::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff;
                     box-shadow: 0 1px 2px rgba(0, 0, 0, .2); transition: transform .15s; }
.switch input:checked ~ .sw { background: #b8433a; }
.switch input:checked ~ .sw::after { transform: translateX(12px); }
.switch input:focus-visible ~ .sw { box-shadow: var(--ring); }
.switch .sw-on { display: none; color: var(--danger); font-weight: 600; }
.switch input:checked ~ .sw-off { display: none; }
.switch input:checked ~ .sw-on { display: inline; }

@media (prefers-reduced-motion: reduce) {
  .ctl, .chip span, .switch .sw, .switch .sw::after { transition: none; }
}