/*
 * Shared styles for company and case-study pages:
 * dark / light theme colours, the reading column, wide media and the
 * floating dock. Link it after the page's own <style> so it wins where they
 * overlap. The home page (index.html) carries its own copy of the dock.
 */

:root {
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --page-bg: #fff;
  --safe-inline: max(env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
  --wide-gutter: max(16px, var(--safe-inline));
}

/* ----- dark theme (set on <html> by the inline script in <head>) ----- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --page-bg: #0c0b0a;
  --ink: #f3efe9;
  --ink-70: rgba(243, 239, 233, 0.74);
  --ink-60: rgba(243, 239, 233, 0.66);
  --ink-50: rgba(243, 239, 233, 0.56);
  --ink-40: rgba(243, 239, 233, 0.46);
  --ink-30: rgba(243, 239, 233, 0.32);
  --ink-20: rgba(243, 239, 233, 0.2);
  --ink-10: rgba(243, 239, 233, 0.1);
}
:root[data-theme="dark"],
:root[data-theme="dark"] body { background: var(--page-bg); }
:root[data-theme="dark"] :is(.company-cases, .notice, .walkthrough-cta, .modal__right, .ba__label) {
  background-color: #151412;
}
:root[data-theme="dark"] :is(.password-gate, .password-gate__input, .modal) { background-color: #1d1b19; }
:root[data-theme="dark"] :is(.password-gate__icon, .walkthrough-cta__icon, .modal__confirm-icon) {
  background-color: rgba(255, 255, 255, 0.08);
}
:root[data-theme="dark"] .case-card__image { background-color: #1a1816; }
:root[data-theme="dark"] :is(.password-gate__btn, .password-gate__submit, .notice__cta, .walkthrough-cta__btn, .cta-btn, .modal__btn):not(.password-gate__btn--secondary, .walkthrough-cta__btn--outline) {
  color: var(--page-bg);
}

/* a short cross-fade while the theme switches */
html.theme-switching,
html.theme-switching * {
  transition: background-color 0.35s ease, color 0.35s ease, border-color 0.35s ease, box-shadow 0.35s ease !important;
}

/* ----- reading column: text at 600px, media can run wider ----- */
body[data-compact-reading] > .wrap { max-width: 600px; }
.wide {
  --wide-width: min(var(--wide-max, 900px), calc(100vw - 2 * var(--wide-gutter)));
  width: var(--wide-width);
  max-width: none;
  margin-left: calc((100% - var(--wide-width)) / 2);
}

/* small labels in mono, as on the home page */
.kicker,
.meta dt {
  font-family: var(--mono);
  letter-spacing: 0.08em;
}

/* ----- floating dock: Home, page tools, copyright, theme ----- */
body {
  padding-inline: var(--safe-inline);
  padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
}
body:has(> .dock) > .nav[data-dock-home-fallback],
body:has(> .dock) > .nav .nav__links a[data-dock-home-fallback] { display: none; }
.dock {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom, 0px));
  z-index: 50;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 2 * var(--wide-gutter));
}
.dock__home,
.dock__copy,
.dock__theme,
.dock .overview-toggle {
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 0 0 1px var(--ink-10, rgba(0, 0, 0, 0.08)), 0 10px 30px rgba(0, 0, 0, 0.1);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
          backdrop-filter: blur(16px) saturate(1.4);
}
.dock__home,
.dock__copy,
.dock .overview-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 16px;
  border: 0;
  border-radius: 100px;
  color: var(--ink-70, rgba(0, 0, 0, 0.7));
  font: 12px/1 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}
.dock__home { color: var(--ink); transition: color 0.2s; }
.dock__home svg { width: 14px; height: 14px; }
.dock__home:hover { text-decoration: none; }
.dock__nav { display: contents; }
.dock .overview-toggle { cursor: pointer; }
.dock .overview-toggle:hover { color: var(--ink); }
.dock .overview-toggle[aria-pressed="true"] { background: var(--ink); color: #fff; }
.dock .overview-toggle__dot { background: currentColor; opacity: 0.4; box-shadow: none; }
.dock .overview-toggle[aria-pressed="true"] .overview-toggle__dot { background: currentColor; opacity: 1; box-shadow: none; }
.dock__theme {
  display: grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--ink);
  cursor: pointer;
}
.dock__theme svg { width: 16px; height: 16px; }
.dock__home:focus-visible,
.dock__theme:focus-visible,
.dock .overview-toggle:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

/* the button shows where you would go: a moon in light mode, a sun in dark mode */
:root[data-theme="dark"] .dock__icon-moon,
:root:not([data-theme="dark"]) .dock__icon-sun { display: none; }

/* The solid edge reaches Safari's toolbar, with the fade sitting above it. */
.dock-fade {
  position: fixed;
  inset: auto 0 0;
  z-index: 49;
  height: max(32px, env(safe-area-inset-bottom, 0px));
  pointer-events: none;
  background-color: var(--page-bg);
}
.dock-fade::before {
  content: "";
  position: absolute;
  inset: auto 0 100%;
  height: 78px;
  background: linear-gradient(to bottom, transparent, var(--page-bg));
}

:root[data-theme="dark"] .dock__home,
:root[data-theme="dark"] .dock__copy,
:root[data-theme="dark"] .dock__theme,
:root[data-theme="dark"] .dock .overview-toggle {
  background: rgba(30, 28, 26, 0.94);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12), 0 10px 30px rgba(0, 0, 0, 0.5);
}
:root[data-theme="dark"] .dock .overview-toggle[aria-pressed="true"] { background: var(--ink); color: #0c0b0a; }

@media (max-width: 600px) {
  .dock__copy { display: none; }
}

img.wide { display: block; }
