/* ==========================================================================
   The Creative Vault — shared chrome
   One masthead and one footer for all 55 pages. Before this file the site
   shipped three different headers (.masthead, .seo-header, .drip-header)
   with three navs and three brand treatments; a visitor moving from the
   homepage to a category page changed sites.

   Depends on css/tokens.css. Loaded second, before any page stylesheet.
   ========================================================================== */

/* --- Skip link: the first thing a keyboard reaches on every page --------- */
.skip-link {
  position: absolute;
  left: 50%;
  top: 0;
  z-index: 200;
  transform: translate(-50%, -140%);
  padding: 11px 18px;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  background: var(--ink);
  color: var(--bg);
  font: 600 14px/1 Archivo, system-ui, sans-serif;
  text-decoration: none;
  transition: transform var(--fast) var(--ease);
}
.skip-link:focus-visible { transform: translate(-50%, 0); }

.chrome-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ==========================================================================
   Masthead
   ========================================================================== */
.masthead {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--chrome-bg);
  border-bottom: 1px solid var(--chrome-line);
  /* Chrome is the one place backdrop-filter earns its cost: content really
     does pass underneath it. Cards get the frosted look from a gradient. */
  backdrop-filter: blur(22px) saturate(1.22);
  -webkit-backdrop-filter: blur(22px) saturate(1.22);
  transition: box-shadow var(--mid) var(--ease), border-color var(--mid) var(--ease);
}
.masthead[data-stuck="true"] {
  border-bottom-color: var(--line);
  box-shadow: var(--lift-1);
}

/* min-height is a LITERAL on purpose. app.js measures the rendered masthead
   and publishes it back into --masthead-h for the sticky toolbar and anchor
   offsets, so reading that same token here closes a feedback loop: every
   ResizeObserver pass added the row's own padding and the header grew ~19px
   a tick, forever. --masthead-h is an output, never an input. */
.masthead-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 46px;
  padding-block: 9px;
}

/* --- Brand -------------------------------------------------------------- */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: none;
  color: var(--ink);
  text-decoration: none;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  padding: 4px;
  border: 1px solid var(--glass-line);
  border-radius: 10px;
  background: linear-gradient(145deg, var(--glass-a), var(--glass-b));
  box-shadow: inset 0 1px 0 var(--glass-line-hi);
  transition: transform var(--fast) var(--ease);
}
.brand:hover .brand-mark { transform: translateY(-1px); }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; filter: var(--logo-tint); }
.brand-name {
  font-family: "Bricolage Grotesque", Archivo, system-ui, sans-serif;
  font-weight: 750;
  font-size: 18px;
  letter-spacing: -0.035em;
  white-space: nowrap;
}
.brand-name em { font-style: normal; color: var(--accent-ink); }

/* --- Navigation --------------------------------------------------------
   Three destinations, not seven. The homepage's section anchors were
   never destinations — they are reachable by scrolling the page they
   live on, and putting them here made every other page advertise links
   that jumped somewhere else entirely. */
.mast-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
}
.mast-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 11px;
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 560;
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--fast) var(--ease), background-color var(--fast) var(--ease);
}
.mast-nav a:hover { color: var(--ink); background: var(--surface-sunk); }
.mast-nav a[aria-current="page"] {
  color: var(--accent-ink);
  background: var(--accent-wash);
  font-weight: 640;
}

.mast-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex: none;
}

/* --- Search ------------------------------------------------------------
   One component everywhere. On the homepage app.js filters live as you
   type and suppresses the submit; on every other page it is a real form
   that lands on / with ?q=, which app.js reads on load. */
.mast-search {
  display: flex;
  align-items: center;
  gap: 7px;
  width: clamp(160px, 22vw, 250px);
  height: 34px;
  padding: 0 9px 0 11px;
  border: 1px solid var(--glass-line);
  border-radius: var(--radius-pill);
  background: linear-gradient(145deg, var(--glass-a), var(--glass-b));
  box-shadow: inset 0 1px 0 var(--glass-line-hi);
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.mast-search .icon { width: 15px; height: 15px; flex: none; color: var(--ink-3); }
.mast-search input {
  width: 100%;
  min-width: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: 400 13.5px/1 Archivo, system-ui, sans-serif;
}
.mast-search input::placeholder { color: var(--ink-3); }
.mast-search input:focus { outline: none; }
.mast-search input::-webkit-search-cancel-button { display: none; }
.mast-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}
.mast-search:focus-within .icon { color: var(--accent-ink); }
.mast-search:focus-within .key { opacity: 0; }

.key {
  display: inline-grid;
  place-items: center;
  min-width: 19px;
  height: 19px;
  flex: none;
  padding: 0 5px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink-3);
  font: 600 11px/1 Archivo, system-ui, sans-serif;
  transition: opacity var(--fast) var(--ease);
}

/* --- Theme switch ------------------------------------------------------
   Three real options rather than a two-state toggle, because "medium" is
   not a half-measure between the other two: it is the warm paper with the
   glare removed, which is what most of a long browsing session wants. */
.theme-switch {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: none;
  padding: 3px;
  border: 1px solid var(--glass-line);
  border-radius: var(--radius-pill);
  background: var(--surface-sunk);
}
.theme-btn {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--ink-3);
  cursor: pointer;
  transition: color var(--fast) var(--ease), background-color var(--fast) var(--ease);
}
.theme-btn .icon { width: 15px; height: 15px; }
.theme-btn:hover { color: var(--ink); }
.theme-btn[aria-checked="true"] {
  background: var(--surface);
  color: var(--accent-ink);
  box-shadow: var(--lift-1);
}

/* --- My Vault ----------------------------------------------------------- */
.mast-vault {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  flex: none;
  padding: 0 12px;
  border: 1px solid var(--glass-line);
  border-radius: var(--radius-pill);
  background: linear-gradient(145deg, var(--glass-a), var(--glass-b));
  box-shadow: inset 0 1px 0 var(--glass-line-hi);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color var(--fast) var(--ease), color var(--fast) var(--ease);
}
.mast-vault:hover { border-color: var(--accent); color: var(--accent-ink); }
.mast-vault .icon { width: 15px; height: 15px; flex: none; }
.mast-vault[aria-current="page"] { border-color: var(--accent); color: var(--accent-ink); }
.vault-count {
  display: inline-grid;
  place-items: center;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
:root[data-theme="dark"] .vault-count { color: var(--on-accent); }
.vault-count[hidden] { display: none; }

/* --- Layout of the bar --------------------------------------------------
   The panel holds the nav, theme switch and "Suggest a tool". On wide
   screens it dissolves (display: contents) so those sit in the bar itself;
   below 900px it is the menu the button opens. One copy of every link, so
   the two layouts can never disagree. */
.mast-panel { display: contents; }
.mast-nav { order: 1; }
.mast-tools { order: 2; }
.mast-panel-tools { order: 3; display: flex; align-items: center; gap: 8px; flex: none; }
.mast-nav-vault { display: none !important; }

.mast-submit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px 0 11px;
  border-radius: var(--radius-pill);
  background: var(--ink);
  color: var(--bg);
  font-size: 13.5px;
  font-weight: 620;
  text-decoration: none;
  white-space: nowrap;
  transition: transform var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.mast-submit .icon { width: 15px; height: 15px; }
.mast-submit:hover { transform: translateY(-1px); box-shadow: var(--lift-2); }

.mast-menu {
  display: none;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border: 1px solid var(--glass-line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.mast-menu .icon { width: 19px; height: 19px; }
.mast-menu[aria-expanded="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

@media (max-width: 1180px) {
  .mast-search { width: 200px; }
  .mast-search .key { display: none; }
  .mast-submit span { display: none; }
  .mast-submit { width: 34px; padding: 0; justify-content: center; }
}

/* --- Phone and small tablet: one row, and a real menu ------------------ */
@media (max-width: 900px) {
  .masthead-inner { position: relative; gap: 8px; min-height: 44px; padding-block: 8px; }
  .mast-tools { margin-left: auto; gap: 6px; }
  .mast-menu { display: grid; }
  .mast-vault { width: 40px; height: 40px; padding: 0; justify-content: center; position: relative; }
  .mast-vault-label { display: none; }
  .mast-vault .vault-count { position: absolute; top: -4px; right: -4px; }
  .mast-search { width: clamp(140px, 34vw, 240px); height: 40px; }

  .mast-panel {
    position: absolute;
    top: calc(100% + 1px);
    left: 0;
    right: 0;
    display: none;
    flex-direction: column;
    gap: 14px;
    padding: 14px var(--gutter) 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--lift-3);
  }
  .masthead[data-menu="open"] .mast-panel { display: flex; }
  @media (prefers-reduced-motion: no-preference) {
    .masthead[data-menu="open"] .mast-panel { animation: panel-in 220ms var(--ease) both; }
    @keyframes panel-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
  }
  .mast-nav { flex-direction: column; align-items: stretch; gap: 2px; }
  .mast-nav a, .mast-nav-vault { display: flex !important; min-height: 48px; padding: 0 12px; font-size: 16px; }
  .mast-panel-tools { justify-content: space-between; padding-top: 12px; border-top: 1px solid var(--line); }
  .mast-panel-tools .theme-btn { width: 40px; height: 40px; }
  .mast-submit, .mast-submit span { display: inline-flex; }
  .mast-submit { width: auto; height: 44px; padding: 0 18px 0 14px; }
}
@media (max-width: 560px) {
  .brand-name { font-size: 16.5px; }
  /* Off the homepage the bar keeps its search as a round button that
     still submits; typing happens on the results page. */
  .mast-search { width: 40px; padding: 0; justify-content: center; border-radius: 50%; }
  .mast-search input, .mast-search .key { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
  .mast-search:focus-within { width: 100%; position: absolute; left: var(--gutter); right: var(--gutter); top: 8px; z-index: 3;
    padding: 0 12px; justify-content: flex-start; border-radius: var(--radius-pill); background: var(--surface); }
  .mast-search:focus-within input { position: static; width: 100%; height: auto; opacity: 1; pointer-events: auto; }
}
@media (max-width: 380px) {
  .brand-name { display: none; }
}

/* ==========================================================================
   Footer — one for every page
   ========================================================================== */
.site-footer {
  margin-top: clamp(56px, 8vw, 104px);
  border-top: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
}
.footer-about {
  padding-block: clamp(30px, 4vw, 44px) 0;
}
.footer-about p {
  margin: 0;
  max-width: 88ch;
  padding-bottom: clamp(26px, 3vw, 36px);
  border-bottom: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.7;
}
.footer-about strong { color: var(--ink); font-weight: 620; }
.footer-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) repeat(3, minmax(0, 1fr));
  gap: clamp(28px, 4vw, 56px);
  padding-block: clamp(36px, 5vw, 56px);
}
.footer-brand { display: grid; gap: 16px; align-content: start; justify-items: start; }
.footer-brand p { margin: 0; max-width: 38ch; font-size: 14px; line-height: 1.65; color: var(--ink-2); }
.footer-col { display: grid; gap: 10px; align-content: start; }
.footer-col h2 {
  margin: 0 0 4px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.footer-col a {
  width: fit-content;
  color: var(--ink-2);
  font-size: 14px;
  text-decoration: none;
  transition: color var(--fast) var(--ease);
}
.footer-col a:hover { color: var(--accent-ink); }
.footer-col a[aria-current="page"] { color: var(--ink); font-weight: 600; }
.footer-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px 24px;
  flex-wrap: wrap;
  padding-block: 18px 28px;
  /* The rule spans the content box, not the gutters, so it lines up with
     the columns above it. */
  background: linear-gradient(var(--line), var(--line)) no-repeat var(--gutter) 0 / calc(100% - 2 * var(--gutter)) 1px;
  color: var(--ink-3);
  font-size: 13px;
}
.footer-line p { margin: 0; }
.footer-line-links { display: flex; flex-wrap: wrap; gap: 6px 20px; }
.footer-line-links a { display: inline-flex; align-items: center; min-height: 32px; color: var(--ink-2); font-weight: 560; text-decoration: none; }
.footer-line-links a:hover { color: var(--accent-ink); text-decoration: underline; }
.ellis-footer-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: var(--bg);
  color: var(--ink);
  font-weight: 620;
  font-size: 13px;
  text-decoration: none;
  transition: border-color var(--fast) var(--ease), color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.ellis-footer-button .icon { width: 14px; height: 14px; }
.ellis-footer-button:hover { border-color: var(--accent); color: var(--accent-ink); transform: translateY(-1px); }
@media (max-width: 900px) {
  .footer-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .footer-brand { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 32px; }
  .footer-col a { min-height: 32px; display: inline-flex; align-items: center; }
}



/* Shared shell so every page agrees on its measure and gutters. Values match
   the homepage's original .shell exactly, so removing the duplicate from
   style.css cannot shift a single existing layout. */
.shell {
  width: 100%;
  max-width: var(--shell);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

@media (prefers-reduced-transparency: reduce) {
  .masthead { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--bg); }
  .mast-search, .mast-vault, .brand-mark { background: var(--surface); }
}
@media (prefers-reduced-motion: reduce) {
  .brand:hover .brand-mark,
  .ellis-footer-button:hover { transform: none; }
}

/* ==========================================================================
   Primitives the chrome needs on every page
   style.css defines these for the homepage; the other 54 pages never had them.
   ========================================================================== */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Sized in em so an icon tracks the text it sits beside. Matches style.css's
   existing .icon exactly; every chrome component sets its own explicit size. */
.icon {
  width: 1em;
  height: 1em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* On the homepage the hero carries its own large search field, so the
   masthead copy stays out of the way until that one scrolls off. app.js
   sets data-compact there and nowhere else, which is why this hides only
   on an explicit "false" rather than on a missing attribute. */
.masthead[data-compact="false"] .mast-search {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-2px);
}
.mast-search {
  opacity: 1;
  transform: none;
  transition:
    opacity var(--mid) var(--ease),
    transform var(--mid) var(--ease),
    border-color var(--fast) var(--ease),
    box-shadow var(--fast) var(--ease);
}
@media (prefers-reduced-motion: reduce) {
  .mast-search { transition: none; transform: none; }
}

/* --- Brand mark on a dark ground ----------------------------------------
   cv-secondary-logo.png is a two-tone mark drawn for paper: its dark half
   simply disappears on a dark surface. There is no light variant of the
   asset, so the chip keeps the ground the mark was drawn for. */
:root[data-theme="dark"] .brand-mark {
  background: #f2efe9;
  border-color: rgba(255, 255, 255, 0.16);
}
:root[data-theme="dark"] .brand-mark img { filter: none; }
