/* ============================================================
   psurvey — main brand CSS
   Tokens and base styles. Keyed off Prototypes/04-experience-sketch-v4.html.
   Page-specific styles live in assets/css/<page>.css.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cabin+Condensed:wght@500;700&family=Roboto:wght@300;400;500;700&display=swap');

:root {
    /* Style-axis colors */
    --yellow-main:  #efc234;
    --yellow-light: #f5d667;
    --yellow-pale:  #f9e9ab;
    --yellow-faint: #fdf7e0;
    --yellow-tint:  #fefcf3;

    --blue-main:  #3d8cc7;
    --blue-light: #6aaad6;
    --blue-pale:  #b8d5ea;
    --blue-faint: #e5effa;
    --blue-tint:  #f4f8fc;

    --green-main:  #66a12f;
    --green-dark:  #548624;
    --green-light: #8abb5b;
    --green-pale:  #c6dfa8;
    --green-faint: #e7f1d8;

    /* Five-zone dial palette */
    --acc-heavy:  #efc234;
    --acc-light:  #f5d667;
    --bal:        #66a12f;
    --asrt-light: #6aaad6;
    --asrt-heavy: #3d8cc7;

    /* Neutrals */
    --ink:       #1a1a1a;
    --ink-mid:   #4b4b4b;
    --ink-soft:  #707070;
    --ink-light: #9a9a9a;
    --line:      #e6e6e6;
    --line-soft: #f0f0f0;
    --bg:        #ffffff;
    --bg-alt:    #fafafa;

    /* Type */
    --title: 'Cabin Condensed', system-ui, sans-serif;
    --body:  'Roboto', system-ui, sans-serif;

    /* Layout — pages can override for tighter content edges */
    --shell-pad-x: 24px;
}

/* Survey-tunnel pages (question, midjourney) drop the shell to 18px so the
   pole cards / pause body sit closer to the screen edge per the prototype. */
.page-question,
.page-midjourney { --shell-pad-x: 18px; }

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
img, svg { display: block; max-width: 100%; }
button { font: inherit; }
a { color: inherit; }

html, body {
    font-family: var(--body);
    color: var(--ink);
    background: var(--bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
body { min-height: 100vh; }

/* App shell — single column, max 480px on desktop, full-bleed on phone */
.app-shell {
    width: 100%;
    max-width: 480px;
    min-height: 100vh;
    margin: 0 auto;
    padding: 0 var(--shell-pad-x);
    display: flex;
    flex-direction: column;
}

/* Tier-2 header — used on question and midjourney pages. Bleeds to the
   shell edges via negative margin equal to the shell padding. */
.t2-header {
    margin: 8px calc(-1 * var(--shell-pad-x)) 0;
    border-bottom: 1px solid var(--line-soft);
}
.t2-progress {
    height: 3px;
    background: var(--line-soft);
}
.t2-progress-fill {
    height: 100%;
    background: var(--green-main);
    transition: width 0.25s ease;
}
.t2-row {
    height: 44px;
    padding: 0 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.t2-back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--ink-mid);
    text-decoration: none;
    background: none;
    border: 0;
    padding: 6px 8px;
    margin-left: -8px;
    cursor: pointer;
}
.t2-back:hover,
.t2-back:focus { color: var(--green-main); outline: none; }
.t2-back svg { width: 14px; height: 14px; }
.t2-counter {
    font-family: var(--body);
    font-weight: 500;
    letter-spacing: 0.05em;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--ink-soft);
}

/* Tier-3 header — home-base / detail pages with brand mark + title.
   Stretches to the shell edges via the negative-margin trick, and stays
   pinned to the top of the viewport while the body scrolls beneath it
   (per the v4 prototype's home-base behavior). */
.t3-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg);
    margin: 0 calc(-1 * var(--shell-pad-x)) 0;
    padding: 14px var(--shell-pad-x) 14px;
    border-bottom: 1px solid var(--line-soft);
}
.t3-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.t3-bar .left {
    display: flex;
    align-items: center;
    gap: 6px;
}
.t3-back-arrow {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-mid);
    cursor: pointer;
    border-radius: 6px;
    text-decoration: none;
}
.t3-back-arrow:hover,
.t3-back-arrow:focus { color: var(--green-main); outline: none; background: var(--bg-alt); }
.t3-back-arrow svg { width: 18px; height: 18px; flex: 0 0 auto; }

/* Hamburger menu placeholder. Right side of t3-bar. Non-interactive
   for now — Phase 21+ will wire up an actual menu (sign out, history). */
.t3-menu {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    padding: 0 4px;
    background: none;
    border: 0;
    color: inherit;
    cursor: default;
}
.t3-menu span {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--ink-mid);
    border-radius: 2px;
    flex-shrink: 0;
}

.t3-title {
    font-family: var(--title);
    font-weight: 700;
    font-size: 15px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ink);
    margin: 0;
}

/* ============================================================
   Admin zone-selector bar (v3)
   Used in admin/content/attributes.php and admin/content/overall.php.
   Layout: 5 equal-width segments matching the user-facing attribute bar
   palette. The selected segment elevates slightly and shows a checkmark.
   Output produced by renderZoneSelectorBar() in lib/render.php.
   ============================================================ */
.zone-selector-bar {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    width: var(--zsb-width, 280px);
    max-width: 100%;
    border-radius: 8px;
    overflow: visible;
    margin: 8px 0;
}
.zsb-segment {
    height: 44px;
    border: 0;
    color: #fff;
    cursor: pointer;
    padding: 0;
    font-family: var(--body);
    font-weight: 500;
    transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.zsb-segment:first-child { border-top-left-radius: 8px; border-bottom-left-radius: 8px; }
.zsb-segment:last-child  { border-top-right-radius: 8px; border-bottom-right-radius: 8px; }
.zsb-segment:not(.is-selected):hover { filter: brightness(1.05); }
.zsb-segment:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 161, 47, 0.4);
    z-index: 2;
}
.zsb-segment.is-selected {
    transform: scale(1.06);
    z-index: 1;
    box-shadow: 0 4px 12px rgba(20, 24, 40, 0.22);
    border-radius: 8px;
}
.zsb-check {
    width: 18px;
    height: 18px;
    display: block;
}
/* Dark text on the lighter (yellow) segments for contrast */
.zsb-zone-1, .zsb-zone-2 { color: var(--ink); }

/* Brand header (top mark) */
.brand-header {
    padding: 32px 0 8px;
    display: flex;
    justify-content: center;
}
.brand-header a { display: inline-flex; }

.diamonds {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}
.diamonds .d {
    width: 10px; height: 10px;
    transform: rotate(45deg);
    background: var(--ink-light);
    border-radius: 1.5px;
}
.diamonds.large .d { width: 18px; height: 18px; }
.diamonds.brand .d:nth-child(1) { background: var(--yellow-main); }
.diamonds.brand .d:nth-child(2) { background: var(--green-main); }
.diamonds.brand .d:nth-child(3) { background: var(--blue-main); }

/* Footer (copyright) */
.app-foot {
    margin-top: auto;
    padding: 24px 0 16px;
    text-align: center;
    font-size: 11px;
    color: var(--ink-light);
}

/* ===== Typography ===== */
h1, h2, h3, .title-lg, .title-md, .title-sm {
    font-family: var(--title);
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.04em;
    line-height: 1.15;
    color: var(--ink);
}

.title-lg { font-size: 22px; margin-bottom: 12px; }
.title-md { font-size: 18px; margin-bottom: 10px; }
.title-sm { font-size: 14px; margin-bottom: 8px; }

.section-label {
    font-family: var(--title);
    text-transform: uppercase;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.1em;
    color: var(--green-main);
}

.intro {
    font-size: 14px;
    color: var(--ink-soft);
    margin-bottom: 24px;
}

.meta {
    font-size: 13px;
    color: var(--ink-soft);
    margin-top: 16px;
}

/* ===== Buttons ===== */
.btn-primary {
    background: var(--green-main);
    color: #fff;
    font-family: var(--body);
    font-weight: 500;
    font-size: 12px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 11px 22px;
    border-radius: 24px;
    border: 0;
    cursor: pointer;
    transition: background 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}
.btn-primary:hover,
.btn-primary:focus { background: var(--green-dark); outline: none; }
.btn-primary:focus-visible { box-shadow: 0 0 0 3px var(--green-pale); }
.btn-primary.lg { font-size: 13px; padding: 13px 30px; }
.btn-primary .arrow { display: inline-block; font-size: 14px; line-height: 1; }

.btn-row {
    display: flex;
    justify-content: flex-end;
    margin-top: 18px;
}

/* Inline link-style button */
.link {
    background: none;
    border: 0;
    color: var(--green-main);
    font-family: var(--body);
    font-size: 13px;
    cursor: pointer;
    padding: 4px 8px;
    text-decoration: none;
}
.link:hover,
.link:focus { color: var(--green-dark); text-decoration: underline; outline: none; }

/* ===== Landing page ===== */
.landing {
    flex: 1;
    display: flex;
    flex-direction: column;
}
.landing .hero-wrap { margin-top: 22%; }

.hero {
    font-family: var(--title);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-size: 28px;
    line-height: 1.15;
    color: var(--ink);
    margin-bottom: 16px;
}
.hero-sub {
    font-size: 15px;
    color: var(--ink-soft);
    margin-bottom: 0;
}

.landing-foot {
    text-align: center;
    font-size: 11px;
    color: var(--ink-light);
    padding: 32px 0 8px;
    margin-top: 24px;
}

.landing-returning {
    text-align: center;
    font-size: 12px;
    color: var(--ink-soft);
    padding: 0 0 16px;
}
.landing-returning a {
    color: var(--green-main);
    text-decoration: none;
    font-weight: 500;
}
.landing-returning a:hover,
.landing-returning a:focus {
    color: var(--green-dark);
    text-decoration: underline;
    outline: none;
}

/* ===== Home page (post-login placeholder) ===== */
.page-body {
    flex: 1;
    padding-top: 40px;
}

/* ===== Error pages (403, future 404, etc.) ===== */
.error-body {
    text-align: center;
    padding: 48px 8px 24px;
}
.error-body .title-lg { margin-top: 8px; }
.error-body .intro    { margin: 12px auto 28px; max-width: 360px; }
.error-code {
    font-family: var(--title);
    font-weight: 700;
    font-size: 64px;
    line-height: 1;
    color: var(--ink-light);
    letter-spacing: 0.05em;
}
.error-actions {
    display: flex;
    justify-content: center;
    margin-top: 16px;
}

/* Mobile tweaks (≤ 380px wide) */
@media (max-width: 380px) {
    .app-shell { padding: 0 18px; }
    .hero { font-size: 24px; }
}

/* ============================================================
   User menu dropdown (v5)
   Lives inside .t3-header. Hamburger toggles open/close; an overlay
   dims the page beneath while the menu is open. Behavior wired in
   /assets/js/menu.js. Markup produced by renderUserMenu() in lib/render.php.
   ============================================================ */

button.t3-menu {
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}
button.t3-menu:hover span,
button.t3-menu:focus span { background: var(--ink); }
button.t3-menu[aria-expanded="true"] span { background: var(--green-main); }
button.t3-menu:focus { outline: none; }
button.t3-menu:focus-visible {
    outline: 2px solid var(--green-main);
    outline-offset: 2px;
    border-radius: 4px;
}

.menu-overlay-dim {
    position: fixed;
    inset: 0;
    background: rgba(20, 24, 40, 0.18);
    z-index: 40;
}

.menu-dropdown {
    position: absolute;
    top: calc(100% - 4px);
    right: var(--shell-pad-x, 16px);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(20, 24, 40, 0.18);
    min-width: 180px;
    z-index: 50;
    overflow: visible;
}
.menu-dropdown::before {
    content: '';
    position: absolute;
    top: -7px;
    right: 14px;
    width: 12px;
    height: 12px;
    background: #fff;
    border-top: 1px solid var(--line);
    border-left: 1px solid var(--line);
    transform: rotate(45deg);
}
.menu-item {
    width: 100%;
    padding: 11px 14px;
    font-family: var(--body);
    font-size: 13px;
    color: var(--ink);
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--line-soft);
    background: #fff;
    border-left: 0;
    border-right: 0;
    border-top: 0;
    text-decoration: none;
    position: relative;
    z-index: 1;
}
.menu-item:first-child { border-top-left-radius: 10px; border-top-right-radius: 10px; }
.menu-item:last-child  { border-bottom: 0; border-bottom-left-radius: 10px; border-bottom-right-radius: 10px; }
.menu-item:hover,
.menu-item:focus { background: var(--bg-alt); outline: none; }
.menu-item .ico {
    width: 16px;
    height: 16px;
    color: var(--ink-soft);
    flex-shrink: 0;
}
.menu-item.signout { color: var(--blue-main); font-weight: 500; }
.menu-item.signout .ico { color: var(--blue-main); }

/* ============================================================
   Account page (v5)
   ============================================================ */

.account-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px 0 32px;
}
.account-section {
    background: var(--bg-alt);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 16px 16px 14px;
    margin-bottom: 14px;
}
.account-section-title {
    font-family: var(--title);
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--green-main);
    font-weight: 700;
    margin-bottom: 8px;
}
.account-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--line-soft);
    font-size: 13px;
    gap: 12px;
}
.account-row:last-child { border-bottom: 0; }
.account-row .lbl {
    font-family: var(--title);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-light);
    font-weight: 700;
    flex-shrink: 0;
}
.account-row .val {
    color: var(--ink);
    font-weight: 500;
    text-align: right;
    word-break: break-word;
}
.account-coming {
    background: #fff;
    border: 1px dashed var(--line);
    border-radius: 10px;
    padding: 14px;
    font-size: 12.5px;
    color: var(--ink-soft);
    line-height: 1.5;
    margin-bottom: 18px;
}
.account-coming strong { color: var(--ink); font-weight: 500; }
.account-coming ul { padding-left: 16px; margin: 6px 0 0; }
.account-coming li { margin: 3px 0; }
.account-actions {
    display: flex;
    justify-content: center;
    margin-top: 12px;
}
.account-actions form { margin: 0; }

/* Edit affordance + edit-mode inputs */
.account-section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.account-section-head .account-section-title { margin-bottom: 0; }
.account-edit-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: var(--body);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--green-main);
    text-decoration: none;
    font-weight: 500;
}
.account-edit-link:hover { color: var(--green-dark); }
.account-edit-link svg { color: currentColor; }

.account-row.edit {
    display: grid;
    grid-template-columns: 96px 1fr;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
}
.account-row.edit .lbl { padding-top: 0; }
.account-input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-family: var(--body);
    font-size: 13px;
    color: var(--ink);
    background: #fff;
    outline: none;
}
.account-input:focus { border-color: var(--green-main); }

.account-edit-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 16px;
    margin-top: 10px;
}
.link-cancel {
    background: none;
    border: 0;
    padding: 0;
    font-family: var(--body);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-soft);
    text-decoration: none;
    cursor: pointer;
}
.link-cancel:hover { color: var(--ink); }

/* Inline flash banner above the details card */
.account-flash {
    background: var(--green-faint);
    border: 1px solid var(--green-pale);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    color: var(--ink-mid);
    margin-bottom: 14px;
}

/* Pending email-change notice (when a verify is in flight) */
.account-pending {
    background: #fff8e6;
    border: 1px solid #f4dca0;
    border-left: 3px solid #d6a72b;
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 14px;
}
.account-pending .lbl {
    font-family: var(--title);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #a07c0e;
    font-weight: 700;
    margin-bottom: 4px;
}
.account-pending .msg {
    font-size: 13px;
    color: var(--ink-mid);
    line-height: 1.5;
    margin-bottom: 10px;
}
.account-pending .row {
    display: flex;
    gap: 10px;
}
.btn-primary.sm {
    font-size: 11px;
    padding: 8px 16px;
}

/* Verify-page cancel-change link sits below the form */
.verify-cancel-form {
    margin-top: 18px;
    text-align: center;
}
