/* =========================================================================
   MAESTROX — Unified Page Header
   One pattern that handles every page in the portal.

   Anatomy (all parts optional except title):
     ┌─ Breadcrumb ─────────────────────────────────────────────────┐
     │ [Tile]  Title                                      [Actions] │
     │         Meta / role / stats line                             │
     │         Description                                          │
     └──────────────────────────────────────────────────────────────┘
     [Sub-row: tabs · filters · search · view toggle] (attached if present)

   Designed against the gold canvas. Content sits directly on canvas —
   no card chrome — but the optional sub-row uses a working-surface band
   that visually anchors the page below.
   ========================================================================= */

/* Tokens (--font-body, --font-display, --gold, etc.) are already loaded
 * globally by the mx2 + client layouts (maestrox-tokens.css + tokens.css
 * earlier in the cascade). Skip the @import per the brief's note. */

.ph {
  padding: 32px 32px 0;
  position: relative;
  z-index: 1;
}

/* =========================================================================
   BREADCRUMB
   ========================================================================= */

.ph-crumb {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-body);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: rgba(40, 28, 12, 0.55);
  margin-bottom: 20px;
}
.ph-crumb a {
  color: inherit;
  text-decoration: none;
  transition: color 120ms ease;
}
.ph-crumb a:hover { color: rgba(40, 28, 12, 0.85); }
.ph-crumb .sep {
  color: rgba(40, 28, 12, 0.3);
  font-weight: 400;
  font-size: 12px;
}
.ph-crumb .current {
  color: rgba(20, 14, 6, 0.9);
  font-weight: 700;
}

/* =========================================================================
   MAIN ROW — tile · titlestack · actions
   ========================================================================= */

.ph-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 22px;
  align-items: center;
  margin-bottom: 24px;
}
.ph-row.no-tile {
  grid-template-columns: 1fr auto;
}

/* Identity tile (left column) */
.ph-tile {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, #5a4f3a 0%, #3a3225 100%);
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow:
    0 6px 20px rgba(40, 28, 12, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  position: relative;
  overflow: hidden;
}
.ph-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.ph-tile .glyph {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: 36px;
  color: var(--gold);
  letter-spacing: -0.02em;
  line-height: 1;
}

/* Section icon variant — when there's no client, show a thin gold icon */
.ph-tile.section {
  background: rgba(255, 252, 244, 0.9);
  border: 1px solid rgba(200, 169, 94, 0.3);
  box-shadow: 0 4px 14px rgba(40, 28, 12, 0.1);
}
.ph-tile.section .glyph { color: var(--gold); font-size: 28px; }
.ph-tile.section svg { width: 28px; height: 28px; color: var(--gold); }

/* Title stack (middle column) */
.ph-titlestack { min-width: 0; }

.ph-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 36px;
  line-height: 1;
  letter-spacing: -0.01em;
  color: rgba(20, 14, 6, 0.95);
  margin: 0;
}
.ph-title em {
  font-style: italic;
  color: rgba(40, 28, 12, 0.65);
  font-weight: 300;
}

/* Meta line — under title, above description. For role, stats, status */
.ph-meta {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
  font-family: var(--font-body);
  font-size: 11.5px;
  font-weight: 600;
  color: rgba(40, 28, 12, 0.65);
}
.ph-meta .gold { color: var(--gold); font-weight: 700; }
.ph-meta strong { color: rgba(20, 14, 6, 0.9); font-weight: 700; }
.ph-meta .dot {
  color: rgba(40, 28, 12, 0.3);
  font-weight: 400;
}
.ph-meta .pill {
  display: inline-flex;
  padding: 2px 9px;
  background: rgba(200, 169, 94, 0.18);
  color: rgba(40, 28, 12, 0.85);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

/* Description — supportive prose, on its own line */
.ph-desc {
  margin-top: 8px;
  font-size: 13.5px;
  line-height: 1.5;
  color: rgba(40, 28, 12, 0.7);
  max-width: 64ch;
}
.ph-desc strong { color: rgba(20, 14, 6, 0.9); font-weight: 700; }

/* Info chip — used when a long description is moved to a modal so
   the header doesn't carry it inline. Sits in .ph-desc's slot,
   reads as "click for more". Drew, 2026-05-29. */
.ph-info-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: transparent;
  border: 1px solid rgba(40, 28, 12, 0.18);
  border-radius: 999px;
  font-family: inherit;
  font-size: 12.5px;
  color: rgba(40, 28, 12, 0.7);
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.ph-info-btn:hover {
  background: rgba(40, 28, 12, 0.04);
  border-color: rgba(40, 28, 12, 0.32);
  color: rgba(20, 14, 6, 0.9);
}

/* Actions (right column) */
.ph-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* =========================================================================
   SUB-ROW — attaches below the title block when the page has tabs,
   filters, search, or a view toggle. Sits on a thin working surface
   so the working content below it feels grounded.
   ========================================================================= */

.ph-subrow {
  margin: 0 -32px;
  padding: 12px 32px;
  /* Perf pass D (2026-05-27): dropped backdrop-filter. .ph-subrow is
     sticky (always visible) AND contains hoverable buttons/tabs/chips
     whose hover state changes background — that combination forces
     the browser to re-rasterize the blurred backdrop region on every
     hover. Bumped background alpha 0.6 → 0.92 to compensate for the
     missing blur frost. Reads nearly identical against the cream
     canvas; the children's contrast does the heavy lifting. */
  background: rgba(255, 252, 244, 0.92);
  border-top: 1px solid rgba(200, 169, 94, 0.18);
  border-bottom: 1px solid rgba(200, 169, 94, 0.18);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

/* =========================================================================
   BUTTONS — header-grade
   ========================================================================= */

.ph-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: 4px;
  border: 0;
  font-family: var(--font-body);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.ph-btn:active { transform: translateY(1px); }
.ph-btn svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 1.8; fill: none; }

.ph-btn.primary {
  background: linear-gradient(180deg, #c47b3a 0%, #a8642a 100%);
  color: #fff8e8;
  box-shadow:
    0 4px 14px rgba(168, 100, 42, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.ph-btn.primary:hover { box-shadow: 0 6px 18px rgba(168, 100, 42, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.22); }

.ph-btn.ghost {
  /* Drew, 2026-05-27 perf pass C: dropped backdrop-filter on the
     ghost buttons. The blur was paired with a :hover that changes the
     button's own background alpha, forcing the browser to re-rasterize
     the blurred backdrop region on every hover state change — a major
     contributor to the "delayed hover" feel. Bumping the background
     alpha (0.7 → 0.92) keeps the cream-paper look almost identical
     against the canvas behind. Same treatment for .ph-toggle below. */
  background: rgba(255, 252, 244, 0.92);
  color: rgba(20, 14, 6, 0.9);
  border: 1px solid rgba(200, 169, 94, 0.3);
}
.ph-btn.ghost:hover { background: rgba(255, 252, 244, 1); border-color: var(--gold); }

/* Toggle group — Calendar/List or List/Grid */
.ph-toggle {
  display: inline-flex;
  background: rgba(255, 252, 244, 0.92);
  border: 1px solid rgba(200, 169, 94, 0.3);
  border-radius: 999px;
  padding: 3px;
}
.ph-toggle button,
.ph-toggle a {
  padding: 7px 18px;
  border: 0;
  background: transparent;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(40, 28, 12, 0.7);
  cursor: pointer;
  text-decoration: none;
  /* Perf pass D: `transition: all` animates every property change,
     including no-ops (typography, layout). Narrow to the props that
     actually change on hover/active state. */
  transition: background 120ms ease, color 120ms ease, box-shadow 120ms ease;
  display: inline-flex;
  align-items: center;
}
.ph-toggle button.is-active,
.ph-toggle a.is-active {
  background: linear-gradient(180deg, #c47b3a 0%, #a8642a 100%);
  color: #fff8e8;
  box-shadow: 0 2px 6px rgba(168, 100, 42, 0.3);
}

/* Tabs that live in the sub-row */
.ph-tabs {
  display: flex;
  gap: 2px;
  align-items: center;
}
.ph-tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px;
  background: transparent;
  border: 0;
  font-family: var(--font-body);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: rgba(40, 28, 12, 0.6);
  cursor: pointer;
  border-radius: 4px;
  transition: background 120ms ease, color 120ms ease;
  position: relative;
}
.ph-tab:hover { color: rgba(20, 14, 6, 0.9); background: rgba(200, 169, 94, 0.08); }
.ph-tab.is-active {
  color: rgba(20, 14, 6, 0.95);
  font-weight: 700;
}
.ph-tab.is-active::after {
  content: "";
  position: absolute;
  left: 16px; right: 16px;
  bottom: -13px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
.ph-tab .count {
  display: inline-flex;
  align-items: center; justify-content: center;
  min-width: 18px; height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(200, 169, 94, 0.25);
  color: rgba(40, 28, 12, 0.85);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
}

/* Search input in sub-row */
.ph-search {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(255, 252, 244, 0.75);
  border: 1px solid rgba(200, 169, 94, 0.22);
  border-radius: 4px;
  max-width: 480px;
  transition: border-color 120ms ease;
}
.ph-search:focus-within {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(200, 169, 94, 0.18);
}
.ph-search svg { width: 14px; height: 14px; color: rgba(40, 28, 12, 0.55); stroke: currentColor; stroke-width: 1.8; fill: none; flex-shrink: 0; }
.ph-search input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: none;
  font-family: var(--font-body);
  font-size: 13px;
  color: rgba(20, 14, 6, 0.95);
}
.ph-search input::placeholder { color: rgba(40, 28, 12, 0.45); }

/* Spacer for sub-row pushes content right */
.ph-spacer { flex: 1; }

/* Radio chip group (Search in: All / Visual / Spoken) */
.ph-chip-row {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-body);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(40, 28, 12, 0.65);
}
.ph-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px;
  background: rgba(255, 252, 244, 0.65);
  border: 1px solid rgba(200, 169, 94, 0.22);
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(40, 28, 12, 0.7);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.ph-chip:hover { border-color: var(--gold); }
.ph-chip.is-active {
  background: rgba(200, 169, 94, 0.22);
  border-color: var(--gold);
  color: rgba(20, 14, 6, 0.95);
}

/* =========================================================================
   FOLDER TABS — physical file-folder treatment
   Use .ph-tabs.folder on the .ph-tabs container.
   Tabs visually "rise" from the page below, with a gold top-cap on active.
   Sits flush to the bottom of the .ph-subrow, no under-rule.
   Use whenever tabs filter views of the same dataset (Drafts/Approvals/
   Calendar views, client detail sections, etc.). Brought in from DS v7
   2026-05-23. The .ph-subrow needs the matching .folder-host modifier
   so the band underneath doesn't compete visually with the tab tops.
   ========================================================================= */

.ph-tabs.folder {
  gap: 0;
  margin-bottom: -13px;     /* eats into the subrow's bottom padding */
  align-items: flex-end;
  position: relative;
  z-index: 2;
}

.ph-tabs.folder .ph-tab {
  position: relative;
  padding: 11px 22px 13px;
  background: rgba(255, 252, 244, 0.55);
  border: 1px solid rgba(200, 169, 94, 0.25);
  border-bottom: 0;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
  margin-right: -1px;       /* tabs share an edge */
  font-weight: 600;
  color: rgba(40, 28, 12, 0.6);
  transition: background 120ms ease, color 120ms ease, transform 120ms ease;
}

.ph-tabs.folder .ph-tab:hover {
  background: rgba(255, 252, 244, 0.78);
  color: rgba(20, 14, 6, 0.9);
}

.ph-tabs.folder .ph-tab.is-active {
  background: rgba(255, 252, 244, 0.96);
  color: rgba(20, 14, 6, 0.95);
  font-weight: 700;
  z-index: 3;
  /* Pull active tab up so it sits "in front" */
  transform: translateY(-2px);
  padding-bottom: 15px;
  border-color: rgba(200, 169, 94, 0.45);
  box-shadow:
    0 -3px 10px rgba(40, 28, 12, 0.06),
    -4px -2px 8px rgba(40, 28, 12, 0.04),
    4px -2px 8px rgba(40, 28, 12, 0.04);
}

/* Kill the under-rule from default tabs — folder uses background instead */
.ph-tabs.folder .ph-tab.is-active::after { display: none; }

/* Gold top-cap on the active tab — the brand thread */
.ph-tabs.folder .ph-tab.is-active::before {
  content: "";
  position: absolute;
  top: -1px; left: -1px; right: -1px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  border-radius: 8px 8px 0 0;
}

/* Count chip inside a folder tab — tighter color to fit the warmer panel */
.ph-tabs.folder .ph-tab .count {
  background: rgba(200, 169, 94, 0.3);
}
.ph-tabs.folder .ph-tab.is-active .count {
  background: var(--gold);
  color: #fff8e8;
}

/* When folder tabs are used, the subrow loses its bottom border (the tab takes over) */
.ph-subrow.folder-host {
  border-bottom: 0;
  padding-bottom: 0;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* =========================================================================
   RESPONSIVE
   ========================================================================= */

@media (max-width: 768px) {
  .ph { padding: 20px 20px 0; }
  .ph-subrow { margin: 0 -20px; padding: 10px 20px; }
  .ph-row { grid-template-columns: 1fr; gap: 14px; }
  .ph-tile { width: 48px; height: 48px; }
  .ph-tile .glyph { font-size: 26px; }
  .ph-title { font-size: 28px; }
  .ph-actions { width: 100%; flex-wrap: wrap; }
  /* Breadcrumb: the 0.32em tracking + uppercase made a 3-4 level chain
     run off the right edge (clipped by the page's overflow-x:clip). Let
     it wrap and tighten the tracking so the whole trail stays visible on
     a phone instead of getting cut off. Drew 2026-06-17. */
  .ph-crumb {
    flex-wrap: wrap;
    row-gap: 3px;
    letter-spacing: 0.1em;
    font-size: 10px;
    margin-bottom: 14px;
    min-width: 0;
  }
  .ph-crumb a, .ph-crumb .current {
    overflow-wrap: anywhere;
  }
}
