/* Navigation styles (WFG-143, WFG-144): 5-item responsive nav with phone bottom bar */
/* Architect 11-18: tokens mapped to the real theme set (--ink-*, --surface-*, --accent*, --line); the --color-* names were never defined (v1-22). */

.skip-link {
  position: absolute;
  left: -9999px;
  z-index: 9999;
  padding: 0.5rem 1rem;
  /* Architect 11-18: --color-bg/--color-text are not defined by any theme, so the link fell back to the header's colours
     (1.31:1 in wfg-social-blue, v1-22). Use real theme tokens, and the spans inherit them. */
  background: var(--surface-panel, #fff);
  color: var(--ink-primary, #111);
  border: 2px solid var(--accent, #1d65d9);
}
.skip-link span { color: inherit; }
.skip-link:focus { left: 0; top: 0; }

.sr-only { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* Main nav (desktop/tablet: horizontal, phone: hidden) */
.main-nav {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 0.75rem;
  border: none;
  background: transparent;
  color: var(--ink-primary);
  text-decoration: none;
  font-size: 0.875rem;
  cursor: pointer;
  border-radius: 0.25rem;
  transition: background 120ms, color 120ms;
}

.nav-btn:hover { background: var(--color-bg-hover, rgba(0,0,0,0.05)); }
.nav-btn:focus-visible { outline: 2px solid var(--accent-text, var(--accent)); outline-offset: 2px; }
.nav-btn[aria-current="page"] { background: var(--color-bg-active, rgba(0,0,0,0.1)); font-weight: 600; }

.nav-btn .icon { width: 20px; height: 20px; }

/* Sub-nav (desktop/tablet only) */
.sub-nav {
  display: flex;
  gap: 1.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line, #e0e0e0);
  margin-bottom: 1rem;
  /* Architect 11-18: the sub-nav sits on the coloured header in some themes (blue on blue, 1.31:1, v1-22); give it the
     panel surface its ink/accent tokens are designed for. */
  background: var(--surface-panel, #fff);
  border-radius: var(--radius-sm, 6px);
}

.sub-link {
  position: relative;
  padding: 0.5rem 0;
  color: var(--ink-primary);
  text-decoration: none;
  font-size: 0.9375rem;
  transition: color 120ms;
}

.sub-link:hover { color: var(--accent-text, var(--accent)); }
.sub-link:focus-visible { outline: 2px solid var(--accent-text, var(--accent)); outline-offset: 4px; }
.sub-link[aria-current="page"] {
  font-weight: 600;
  color: var(--accent-text, var(--accent));
  border-bottom: 2px solid var(--accent-text, var(--accent));
}

/* Phone bottom bar (<=820px) */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: none;
  grid-template-columns: repeat(5, minmax(0, 1fr));   /* Architect 11-18 (T-PHONE): 1fr let long labels widen the bar past 390px */
  background: var(--surface-panel);
  border-top: 1px solid var(--line, #e0e0e0);
  padding-bottom: env(safe-area-inset-bottom, 0);
  z-index: 100;
}

.bottom-nav .nav-btn {
  flex-direction: column;
  padding: 0.5rem 0.25rem;
  font-size: 0.75rem;
  min-height: 56px;
  min-width: 0;
  white-space: normal;
}

.bottom-nav .nav-label {
  max-width: 100%;
  text-align: center;
  overflow-wrap: break-word;
  hyphens: auto;
  line-height: 1.2;
}

@media (max-width: 820px) {
  /* Architect 11-18 (T-PHONE): polish.css sets .app-header .main-nav { display: flex } with higher specificity, so the header
     bar stayed (and scrolled sideways) on phones. Match its specificity here. */
  .main-nav, .app-header .main-nav { display: none; }
  .bottom-nav, .bottom-nav[hidden] { display: grid; }
  .main-content { padding-bottom: calc(56px + env(safe-area-inset-bottom, 0)); }
  .sub-nav { margin-left: 1rem; margin-right: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  .nav-btn, .sub-link { transition: none; }
}

/* Favourites screen styles */
.fav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.fav-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1.5rem 1rem;
  background: var(--surface-panel, #fff);
  border: 1px solid var(--line, #e0e0e0);
  border-radius: 0.5rem;
  min-height: 100px;
  text-align: center;
}

.fav-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  color: inherit;
  text-decoration: none;
}

.fav-link:hover { color: var(--accent-text, var(--accent)); }
.fav-link .icon { width: 32px; height: 32px; }

.fav-controls-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.fav-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 1rem;
}

.fav-empty p { margin-bottom: 1rem; }

.fav-open-on {
  margin-top: 1.5rem;
}

@media (max-width: 820px) {
  .fav-grid { grid-template-columns: repeat(2, 1fr); }
  .fav-tile { min-height: 88px; }
}

/* Architect 11-18 (spec 12, T-MOTION): with reduced motion the nav indicator changes instantly: no transition at all,
   not the global 0.01ms reset. */
@media (prefers-reduced-motion: reduce) {
  .nav-btn, .nav-btn::after, .nav-indicator, .sub-link, .sub-link::after { transition: none !important; animation: none !important; }
}

/* Architect 11-18 (T-FAV-OPENON): the brand is a link to the advisor's "Open on" screen; it keeps the header's look. */
.app-header .brand-link { display: flex; align-items: center; gap: inherit; min-width: 0; color: inherit; text-decoration: none; border-radius: 8px; }
.app-header .brand-link:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }
/* T-FAV-PHONE (spec 13.2): edit buttons at least 44px everywhere, so phones meet it too. */
.fav-controls .btn-icon-sm, .fav-add-btn, .fav-controls-top button { min-height: 44px; min-width: 44px; }

/* Architect 11-18 (Tas probe): .sub-nav { display: flex } beat the [hidden] attribute, so an empty or stale sub-row showed. */
.sub-nav[hidden] { display: none !important; }
/* T-PHONE (spec 8): the phone bar steps aside while a text field has focus, so it never covers the keyboard area. */
@media (max-width: 820px) {
  body:has(input:not([type="checkbox"]):not([type="radio"]):not([type="button"]):not([type="submit"]):focus, textarea:focus, select:focus, [contenteditable="true"]:focus) .bottom-nav { display: none !important; }
}

.app-header .brand { cursor: pointer; }

/* Architect 11-18 (render check): the new nav marks the current item with aria-current="page" (not .active), so it had
   no visible highlight. Give it the same treatment polish.css gives .active, in every theme. */
html[data-theme] .main-nav .nav-btn[aria-current="page"] { color: var(--band-ink); background: var(--band-active); font-weight: 600; border-bottom-color: var(--band-ink); }
.bottom-nav .nav-btn[aria-current="page"] { color: var(--accent-text, var(--accent)); font-weight: 600; box-shadow: inset 0 3px 0 var(--accent-text, var(--accent)); }
/* Phone header: the brand name ran under the header icons at 390px. Let it shrink and end with an ellipsis. */
@media (max-width: 480px) {
  .app-header .brand, .app-header .brand-link, .app-header .brand-text { min-width: 0; overflow: hidden; }
  .app-header .brand-name { overflow: hidden; text-overflow: ellipsis; font-size: 1rem; }
  .app-header .brand-desc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* ===== Lustre 2026-11-18 (step 4): finish for the 5-item nav and the Favourites screen. Tokens from themes.css / polish.css only. ===== */

/* Main nav on the band: icon beside the label (nav.css stacked them), one even row that starts on the brand mark's left edge. */
html[data-theme] .main-nav .nav-btn { flex-direction: row; gap: 8px; line-height: 1; }
html[data-theme] .main-nav .nav-btn .icon { width: 18px; height: 18px; opacity: .85; }
html[data-theme] .main-nav .nav-btn[aria-current="page"] .icon { opacity: 1; }

/* Sub-nav: a second tier of the header band, not a white box. Same band tokens as the main nav, so contrast follows every theme. */
.app-header .header-content { grid-template-areas: "brand actions" "nav nav" "sub sub"; }
html[data-theme] .app-header .sub-nav {
  grid-area: sub; margin: 0 -32px; padding: 0 32px; gap: 4px; align-items: stretch;
  background: transparent; border: 0; border-top: 1px solid var(--band-line); border-radius: 0;
}
html[data-theme] .app-header .sub-link {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border: 0; border-radius: 8px;
  color: var(--band-ink-2); font-size: .875rem; font-weight: 500;
}
html[data-theme] .app-header .sub-link::after { content: ""; position: absolute; left: 14px; right: 14px; bottom: 6px; height: 2px; border-radius: 2px; background: currentColor; opacity: 0; }
html[data-theme] .app-header .sub-link:hover { color: var(--band-ink); background: var(--band-hover); }
html[data-theme] .app-header .sub-link:hover::after { opacity: .45; }
html[data-theme] .app-header .sub-link[aria-current="page"] { color: var(--band-ink); font-weight: 600; border: 0; }
html[data-theme] .app-header .sub-link[aria-current="page"]::after { opacity: 1; }
html[data-theme] .app-header .sub-link:focus-visible { outline: 2px solid var(--band-ink); outline-offset: -3px; }
@media (max-width: 820px) { html[data-theme] .app-header .sub-nav { margin: 0 -16px; padding: 0 16px; overflow-x: auto; scrollbar-width: none; } }

/* Favourites: heading row, Edit button, "Open on" select */
.fav-controls-top { gap: 12px; }
html[data-theme] .fav-controls-top button, html[data-theme] .fav-empty button:not(.btn-primary) {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 20px; border-radius: var(--radius-sm, 8px);
  border: 1px solid var(--line); background: var(--surface-panel); color: var(--ink-primary); font: inherit; font-size: .9375rem; font-weight: 600; cursor: pointer; box-shadow: var(--elev-1);
}
html[data-theme] .fav-controls-top button:hover, html[data-theme] .fav-empty button:not(.btn-primary):hover { border-color: var(--accent-text, var(--accent)); color: var(--accent-text, var(--accent)); box-shadow: var(--elev-2); }
html[data-theme] .fav-controls-top button:active, html[data-theme] .fav-empty button:not(.btn-primary):active { box-shadow: none; }
html[data-theme] .fav-empty button { min-height: 44px; margin: 0 6px 8px; }
.fav-open-on { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; padding: 12px 16px; max-width: max-content; border: 1px solid var(--line); border-radius: var(--radius-card, 8px); background: var(--surface-panel); color: var(--ink-primary); }
.fav-open-on label { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; font-weight: 500; }
html[data-theme] .fav-open-on select {
  -webkit-appearance: none; appearance: none; min-height: 44px; padding: 0 40px 0 14px; border: 1px solid var(--line); border-radius: var(--radius-sm, 8px);
  background-color: var(--surface-canvas); color: var(--ink-primary); font: inherit; font-size: .9375rem; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-secondary) 50%), linear-gradient(135deg, var(--ink-secondary) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px, 6px 6px; background-repeat: no-repeat;
}
html[data-theme] .fav-open-on select:hover { border-color: var(--accent-text, var(--accent)); }

/* Tiles: raised card, accent icon disc, whole tile is the tap target */
html[data-theme] .fav-grid { gap: 16px; }
html[data-theme] .fav-tile { position: relative; border-radius: var(--radius-card, 12px); box-shadow: var(--elev-1); min-height: 120px; justify-content: center; }
html[data-theme] .fav-tile:has(> .fav-link) { padding: 0; }
html[data-theme] .fav-link { flex: 1; justify-content: center; padding: 20px 12px; border-radius: inherit; color: var(--ink-primary); font-weight: 600; font-size: .9375rem; }
html[data-theme] .fav-link .icon { box-sizing: content-box; width: 26px; height: 26px; padding: 11px; border-radius: 50%; background: var(--accent-wash); color: var(--accent-text, var(--accent)); }
html[data-theme] .fav-link:hover { color: var(--ink-primary); }
html[data-theme] .fav-link:focus-visible { outline: 2px solid var(--accent-text, var(--accent)); outline-offset: -4px; }
html[data-theme] .fav-tile:has(> .fav-link:hover) { border-color: var(--accent-text, var(--accent)); box-shadow: var(--elev-3); }
html[data-theme] .fav-tile .fav-label { overflow-wrap: anywhere; }
html[data-theme] .fav-tile .fav-controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
html[data-theme] .fav-tile .btn-icon-sm {
  padding: 0 10px; border: 1px solid var(--line); border-radius: var(--radius-sm, 8px); background: var(--surface-canvas); color: var(--ink-primary); font: inherit; font-size: .8125rem; cursor: pointer;
}
html[data-theme] .fav-tile .btn-icon-sm:hover:not(:disabled) { border-color: var(--accent-text, var(--accent)); color: var(--accent-text, var(--accent)); }
html[data-theme] .fav-tile .btn-icon-sm:disabled { opacity: .45; cursor: not-allowed; }
html[data-theme] .fav-add-tile { border-style: dashed; box-shadow: none; background: transparent; }
html[data-theme] .fav-add-btn { border: 0; background: transparent; color: var(--accent-text, var(--accent)); font: inherit; font-weight: 600; cursor: pointer; width: 100%; height: 100%; }

/* Movement: only with motion allowed; rest state is fully visible and unmoved. */
@media (prefers-reduced-motion: no-preference) {
  html[data-theme] .fav-tile { transition: transform var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out), border-color var(--dur-fast) var(--ease-std); }
  html[data-theme] .fav-link .icon { transition: transform var(--dur-base) var(--ease-pop), background-color var(--dur-fast) var(--ease-std); }
  html[data-theme] .app-header .sub-link::after { transition: opacity var(--dur-fast) var(--ease-std); }
  @media (hover: hover) {
    html[data-theme] .fav-tile:has(> .fav-link:hover) { transform: translateY(-3px); }
    html[data-theme] .fav-link:hover .icon { transform: scale(1.08); }
  }
  html[data-theme] .fav-tile:has(> .fav-link:active) { transform: translateY(0) scale(.98); box-shadow: var(--elev-1); transition-duration: var(--dur-instant); }
}

/* Phone: the full brand name in a two-line lockup (the descriptor steps aside) instead of "McGreens Fi..." */
@media (max-width: 480px) {
  html[data-theme] .app-header .brand-desc { display: none; }
  html[data-theme] .app-header .brand-name { white-space: normal; overflow: visible; text-overflow: clip; font-size: 1rem; line-height: 1.15; }
  html[data-theme] .app-header .brand-mark { width: 34px; height: 34px; }
  .fav-open-on { max-width: none; }
}
