/* ══════════════════════════════════════════════════════════════════
   Xerion shared shell - header, footer, buttons, badges, tool cards,
   form basics and accessibility helpers used by BOTH the marketing
   pages (public.css) and, for signed-out visitors, the app pages
   (app.css). Loaded after tokens.css.
   ══════════════════════════════════════════════════════════════════ */

/* ── Accessibility helpers ── */
[hidden] { display: none !important; }
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
    position: absolute; left: 12px; top: -60px; z-index: 2000;
    background: var(--blue); color: #fff; padding: 10px 14px;
    border-radius: var(--radius-sm); font-weight: 600; text-decoration: none;
    transition: top var(--ease);
}
.skip-link:focus { top: 12px; outline: none; box-shadow: var(--focus); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 2px solid var(--blue); outline-offset: 2px;
}

/* ── Header ── */
.site-header {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 1000;
}
.site-header.scrolled { box-shadow: var(--shadow-sm); }
.site-header .nav {
    display: flex; align-items: center; justify-content: space-between;
    min-height: var(--header-h); gap: 20px;
}
.site-header .brand { display: inline-flex; align-items: center; flex-shrink: 0; }
.site-header .brand img { height: 36px; width: auto; }

.nav-links {
    display: flex; align-items: center; gap: 2px;
    font-size: 0.9rem; font-weight: 500; color: var(--ink-mid);
}
.nav-links > a, .nav-drop > button {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 8px 11px; border-radius: var(--radius-sm); white-space: nowrap;
    color: inherit; text-decoration: none; font: inherit; background: none; border: 0; cursor: pointer;
    transition: color var(--ease), background var(--ease);
}
.nav-links > a:hover, .nav-drop > button:hover { color: var(--ink); background: var(--surface); }
.nav-links > a.current, .nav-drop > button.current { color: var(--ink); font-weight: 600; box-shadow: inset 0 -2px 0 var(--blue); border-radius: 0; }

.nav-drop { position: relative; }
.nav-drop > button svg { transition: transform var(--ease); }
.nav-drop-menu {
    position: absolute; top: calc(100% + 6px); left: 0; min-width: 190px;
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-md); padding: 6px; display: flex; flex-direction: column;
    opacity: 0; visibility: hidden; transform: translateY(-4px);
    transition: opacity 0.12s ease 0.18s, transform 0.12s ease 0.18s, visibility 0s linear 0.3s;
}
.nav-drop-menu::before { content: ''; position: absolute; top: -8px; left: 0; right: 0; height: 8px; }
.nav-drop:hover .nav-drop-menu, .nav-drop:focus-within .nav-drop-menu, .nav-drop.open .nav-drop-menu {
    opacity: 1; visibility: visible; transform: none; transition-delay: 0s;
}
.nav-drop:hover > button svg, .nav-drop.open > button svg { transform: rotate(180deg); }
.nav-drop-menu a { padding: 8px 12px; border-radius: var(--radius-sm); color: var(--ink-mid); text-decoration: none; }
.nav-drop-menu a:hover { background: var(--surface); color: var(--ink); }

.nav-actions { display: flex; align-items: center; gap: 8px; margin-left: 10px; }
.nav-login { padding: 8px 10px; color: var(--ink-mid); text-decoration: none; border-radius: var(--radius-sm); }
.nav-login:hover { color: var(--ink); background: var(--surface); }
.icon-btn {
    background: none; border: 1px solid var(--border); border-radius: var(--radius-sm);
    cursor: pointer; padding: 6px 8px; color: var(--ink-mid);
    display: inline-flex; align-items: center; justify-content: center; min-width: 34px; min-height: 34px;
    font: inherit; line-height: 1;
}
.icon-btn:hover { border-color: var(--blue); color: var(--blue); }

.nav-toggle {
    display: none; background: none; border: 1px solid var(--border); border-radius: var(--radius-sm);
    cursor: pointer; padding: 6px; color: var(--ink); margin-left: auto; min-width: 40px; min-height: 40px;
    align-items: center; justify-content: center;
}

/* ── Buttons: one hierarchy, every state ── */
.btn-primary, .btn-secondary, .btn-ghost {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 11px 20px; border-radius: var(--radius-sm);
    font-family: inherit; font-weight: 600; font-size: 0.94rem; line-height: 1.2;
    text-decoration: none; cursor: pointer; border: 1px solid transparent;
    transition: background var(--ease), border-color var(--ease), color var(--ease), box-shadow var(--ease);
    -webkit-tap-highlight-color: transparent;
}
.btn-primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn-primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); color: #fff; }
.btn-primary:active { transform: translateY(1px); }
.btn-secondary { background: var(--card); color: var(--ink); border-color: var(--border-strong); }
.btn-secondary:hover { border-color: var(--blue); color: var(--blue); }
.btn-ghost { background: transparent; color: var(--blue); border-color: transparent; padding-left: 10px; padding-right: 10px; }
.btn-ghost:hover { background: var(--blue-faint); }
.btn-primary:focus-visible, .btn-secondary:focus-visible, .btn-ghost:focus-visible { outline: none; box-shadow: var(--focus); }
.btn-primary[disabled], .btn-secondary[disabled], .btn-ghost[disabled],
.btn-primary[aria-disabled="true"], .btn-secondary[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; pointer-events: none; }
.btn-sm { padding: 8px 14px; font-size: 0.86rem; min-height: 36px; }
.btn-lg { padding: 14px 26px; font-size: 1rem; }
.btn-full { width: 100%; }
.btn-primary.is-loading, .btn-secondary.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn-primary.is-loading::after, .btn-secondary.is-loading::after {
    content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%;
    border: 2px solid currentColor; border-right-color: transparent; color: #fff;
    animation: xspin 0.7s linear infinite;
}
.btn-secondary.is-loading::after { color: var(--blue); }
@keyframes xspin { to { transform: rotate(360deg); } }

/* Secondary buttons on dark bands (hero, CTA) */
.on-dark .btn-secondary, .hero .btn-secondary, .cta-band .btn-secondary, .pricing-band .btn-secondary {
    background: transparent; color: #dbe5f2; border-color: rgba(255,255,255,0.32);
}
.on-dark .btn-secondary:hover, .hero .btn-secondary:hover, .cta-band .btn-secondary:hover, .pricing-band .btn-secondary:hover {
    border-color: rgba(255,255,255,0.7); color: #fff;
}

/* Text links inside prose */
.link { color: var(--blue); font-weight: 600; text-decoration: none; }
.link:hover { text-decoration: underline; }

/* ── Badges (access labels) ── */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 0.7rem; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase;
    padding: 3px 8px; border-radius: var(--radius-pill); border: 1px solid var(--border);
    color: var(--ink-mid); background: var(--card); white-space: nowrap; line-height: 1.4;
}
.badge-free { color: var(--green); border-color: color-mix(in srgb, var(--green) 45%, transparent); background: var(--green-faint); }
.badge-core { color: var(--blue); border-color: color-mix(in srgb, var(--blue) 40%, transparent); background: var(--blue-faint); }
.badge-personal, .badge-business { color: var(--ink-mid); background: var(--surface); }
.badge-locked { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 45%, transparent); background: var(--amber-faint); }

/* ── Tool card: icon, title, purpose, access, action ── */
.tcard {
    display: flex; flex-direction: column; gap: 10px;
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 18px; min-width: 0; position: relative;
    transition: border-color var(--ease), box-shadow var(--ease);
}
.tcard:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.tcard:focus-within { border-color: var(--blue); }
.tcard-head { display: flex; align-items: flex-start; gap: 10px; }
.tcard-icon {
    flex-shrink: 0; width: 36px; height: 36px; border-radius: var(--radius-sm);
    background: var(--blue-faint); color: var(--blue); display: inline-flex; align-items: center; justify-content: center;
}
.tcard-title { font-family: var(--font-head); font-size: 0.98rem; font-weight: 600; color: var(--ink); margin: 0; line-height: 1.3; }
.tcard-title a { color: inherit; text-decoration: none; }
.tcard-title a:hover { color: var(--blue); }
.tcard-desc {
    color: var(--ink-light); font-size: 0.86rem; line-height: 1.55; margin: 0;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.tcard-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 4px; }
.tcard-cat { font-size: 0.74rem; color: var(--ink-light); }
.tcard-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tcard-actions .btn-sm { padding: 7px 12px; font-size: 0.82rem; }
.tcard-more { font-size: 0.82rem; color: var(--blue); font-weight: 600; text-decoration: none; }
.tcard-more:hover { text-decoration: underline; }
.tcard.is-locked .tcard-icon { background: var(--surface); color: var(--ink-light); }

/* ── Form basics shared by public pages (search, email capture) ── */
.field {
    width: 100%; padding: 11px 13px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    font-family: inherit; font-size: 0.95rem; background: var(--card); color: var(--ink);
}
.field:focus { outline: none; border-color: var(--blue); box-shadow: var(--focus); }
.field::placeholder { color: var(--ink-light); }
.field[aria-invalid="true"] { border-color: var(--red); }
.field-hint { font-size: 0.8rem; color: var(--ink-light); margin-top: 6px; }
.field-error { font-size: 0.82rem; color: var(--red); margin-top: 6px; }

/* ── Notices ── */
.notice { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; font-size: 0.9rem; background: var(--card); color: var(--ink-mid); }
.notice-info { border-color: color-mix(in srgb, var(--blue) 35%, transparent); background: var(--blue-faint); color: var(--ink); }
.notice-success { border-color: color-mix(in srgb, var(--green) 40%, transparent); background: var(--green-faint); color: var(--ink); }
.notice-error { border-color: color-mix(in srgb, var(--red) 40%, transparent); background: var(--red-faint); color: var(--ink); }

/* ── Footer ── */
.site-footer { border-top: 1px solid var(--border); background: var(--card); }
.site-footer .footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 40px; padding: 52px 0 40px; }
.site-footer .footer-brand img { height: 32px; width: auto; margin-bottom: 14px; }
.site-footer .footer-brand p { color: var(--ink-light); font-size: 0.88rem; max-width: 300px; line-height: 1.65; margin: 0 0 12px; }
.site-footer .footer-col h2 {
    font-family: var(--font-head); font-size: 0.76rem; font-weight: 600; letter-spacing: 1.4px;
    text-transform: uppercase; color: var(--ink); margin: 0 0 14px;
}
.site-footer .footer-col a { display: block; color: var(--ink-light); font-size: 0.9rem; padding: 4px 0; text-decoration: none; }
.site-footer .footer-col a:hover { color: var(--blue); }
.site-footer .footer-bottom {
    border-top: 1px solid var(--border); padding: 18px 0;
    display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
    color: var(--ink-light); font-size: 0.84rem;
}
.site-footer .footer-bottom .legal { display: flex; gap: 18px; }
.site-footer .footer-bottom a { color: inherit; text-decoration: none; }
.site-footer .footer-bottom a:hover { color: var(--blue); }

/* Touch: small controls grow to a 40px target on coarse pointers / narrow screens */
@media (max-width: 860px), (pointer: coarse) {
    .btn-sm, .tcard-actions .btn-sm, .tcard-more, .icon-btn { min-height: 40px; }
    .tcard-more { display: inline-flex; align-items: center; }
}

/* ── Responsive nav ── */
@media (max-width: 960px) {
    .site-header .nav { flex-wrap: wrap; padding: 8px 0; min-height: auto; }
    .nav-toggle { display: inline-flex; }
    .nav-links {
        display: none; flex-direction: column; align-items: stretch; gap: 2px;
        width: 100%; padding: 8px 0 14px; font-size: 1rem;
    }
    .nav-links.open { display: flex; }
    .nav-links > a, .nav-drop > button { padding: 12px 8px; border-bottom: 1px solid var(--border); border-radius: 0; width: 100%; justify-content: space-between; }
    .nav-links > a.current { box-shadow: inset 3px 0 0 var(--blue); }
    .nav-drop-menu {
        display: flex; position: static; border: none; box-shadow: none; background: none;
        padding: 0 0 0 16px; min-width: 0; opacity: 1; visibility: visible; transform: none; transition: none;
    }
    .nav-drop-menu::before { display: none; }
    .nav-drop-menu a { padding: 11px 8px; border-bottom: 1px solid var(--border); border-radius: 0; }
    .nav-actions { margin: 10px 0 0; width: 100%; flex-wrap: wrap; }
    .nav-actions .btn-primary, .nav-actions .nav-login { flex: 1; justify-content: center; text-align: center; }
    .site-footer .footer-grid { grid-template-columns: 1fr 1fr; gap: 28px; padding: 40px 0 32px; }
}
@media (max-width: 560px) {
    .site-footer .footer-grid { grid-template-columns: 1fr; }
}

/* ── Reduced motion: no transforms or animated reveals ── */
@media (prefers-reduced-motion: reduce) {
    .btn-primary, .btn-secondary, .btn-ghost, .nav-drop-menu, .tcard, .skip-link { transition: none; }
    .btn-primary:active { transform: none; }
    .btn-primary.is-loading::after, .btn-secondary.is-loading::after { animation: none; }
}
