/* ========================================
   PUBLIC CONTENT PAGES - ROYAL HERITAGE
   contact, support, legal, error (404/500), claim, onboarding.
   Load after base.css / home.css. Tokens only (--bl-*).
   ======================================== */

:root {
    --pg-input-border: var(--bl-text-muted); /* >= 3:1 against white */
}

/* ---------- Shared page shell ---------- */
.pg-page {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    padding: var(--bl-space-6) var(--bl-space-4);
    min-height: 70vh;
}

.pg-header {
    text-align: center;
    margin-bottom: var(--bl-space-6);
}

.pg-header h1 {
    font-family: var(--bl-font-display);
    font-size: clamp(2rem, 4.5vw, 2.75rem);
    font-weight: 700;
    color: var(--bl-primary);
    margin-bottom: var(--bl-space-3);
}

.pg-header p {
    color: var(--bl-text-secondary);
    font-size: var(--bl-text-lg);
    max-width: 36rem;
    margin: 0 auto;
    line-height: 1.65;
}

.pg-card {
    background: var(--bl-surface);
    border: 1px solid var(--bl-border);
    border-radius: var(--bl-radius-lg);
    box-shadow: var(--bl-shadow-md);
}

/* Generic labelled form controls used on these pages */
.pg-field {
    margin-bottom: var(--bl-space-4);
}

.pg-field label {
    display: block;
    margin-bottom: var(--bl-space-1);
    font-size: var(--bl-text-sm);
    font-weight: 600;
    color: var(--bl-text-secondary);
    text-transform: none;
    letter-spacing: 0;
}

.pg-field input,
.pg-field select,
.pg-field textarea {
    display: block;
    width: 100%;
    min-height: 48px;
    padding: var(--bl-space-3) var(--bl-space-4);
    background: var(--bl-surface);
    border: 1px solid var(--pg-input-border);
    border-radius: var(--bl-radius-md);
    color: var(--bl-text-primary);
    font-size: var(--bl-text-md); /* 16px: no iOS zoom */
    font-family: var(--bl-font-body);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.pg-field textarea {
    resize: vertical;
    min-height: 120px;
}

.pg-field input::placeholder,
.pg-field textarea::placeholder {
    color: var(--bl-text-muted);
}

.pg-field input:focus-visible,
.pg-field select:focus-visible,
.pg-field textarea:focus-visible {
    outline: none;
    border-color: var(--bl-secondary);
    box-shadow: var(--bl-focus-ring);
}

.pg-field .field-hint {
    color: var(--bl-text-muted);
    font-size: var(--bl-text-xs);
    margin-top: var(--bl-space-1);
}

.pg-alert {
    display: none;
    background: var(--bl-danger-soft);
    color: var(--bl-danger);
    border: 1px solid var(--bl-danger);
    border-radius: var(--bl-radius-md);
    padding: var(--bl-space-3) var(--bl-space-4);
    margin-bottom: var(--bl-space-4);
    font-size: var(--bl-text-sm);
    font-weight: 600;
}

.pg-success {
    display: none;
    text-align: center;
    padding: var(--bl-space-6) var(--bl-space-4);
}

.pg-success.is-shown {
    display: block;
}

.pg-success-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto var(--bl-space-4);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bl-success-soft);
    border: 2px solid var(--bl-success);
    color: var(--bl-success);
}

.pg-success-icon svg {
    width: 36px;
    height: 36px;
}

.pg-success h2,
.pg-success h3 {
    font-family: var(--bl-font-display);
    font-size: var(--bl-text-2xl);
    color: var(--bl-primary);
    margin-bottom: var(--bl-space-2);
}

.pg-success p {
    color: var(--bl-text-secondary);
    line-height: 1.6;
}

/* ========================================
   CONTACT
   ======================================== */
.contact-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr);
    gap: var(--bl-space-6);
    align-items: start;
}

.contact-info {
    display: flex;
    flex-direction: column;
    gap: var(--bl-space-4);
}

.contact-card {
    display: flex;
    align-items: flex-start;
    gap: var(--bl-space-4);
    padding: var(--bl-space-4) var(--bl-space-5);
    background: var(--bl-surface);
    border: 1px solid var(--bl-border);
    border-radius: var(--bl-radius-lg);
    box-shadow: var(--bl-shadow-sm);
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.contact-card:hover {
    transform: translateY(-2px);
    border-color: var(--bl-secondary);
    box-shadow: var(--bl-shadow-md);
}

.contact-icon {
    flex: none;
    width: 44px;
    height: 44px;
    border-radius: var(--bl-radius-md);
    background: var(--bl-parchment);
    border: 1px solid var(--bl-parchment-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: var(--bl-primary);
}

.contact-card h2 {
    font-family: var(--bl-font-body);
    font-size: var(--bl-text-sm);
    font-weight: 700;
    color: var(--bl-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: var(--bl-space-1);
}

.contact-card p {
    font-size: var(--bl-text-md);
    color: var(--bl-text-primary);
    line-height: 1.55;
}

.contact-card a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    color: var(--bl-primary);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.contact-badges {
    display: flex;
    flex-wrap: wrap;
    gap: var(--bl-space-2);
}

.contact-badge {
    padding: var(--bl-space-1) var(--bl-space-3);
    border-radius: var(--bl-radius-pill);
    font-size: var(--bl-text-sm);
    font-weight: 600;
    background: var(--bl-surface-subtle);
    border: 1px solid var(--bl-accent);
    color: var(--bl-primary);
}

.contact-form-wrap {
    padding: var(--bl-space-6);
}

.contact-form-wrap h2 {
    font-family: var(--bl-font-display);
    font-size: var(--bl-text-2xl);
    color: var(--bl-primary);
    margin-bottom: var(--bl-space-5);
}

.contact-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--bl-space-4);
}

.contact-submit {
    width: 100%;
    margin-top: var(--bl-space-2);
}

@media (max-width: 768px) {
    .contact-grid {
        grid-template-columns: 1fr;
    }

    .contact-form-wrap {
        padding: var(--bl-space-5) var(--bl-space-4);
    }
}

@media (max-width: 480px) {
    .contact-row {
        grid-template-columns: 1fr;
        gap: 0;
    }
}

/* ========================================
   SUPPORT
   ======================================== */
.support-container {
    padding: var(--bl-space-6);
    display: flex;
    flex-direction: column;
    gap: var(--bl-space-6);
}

.support-top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: var(--bl-space-6);
    align-items: flex-start;
}

.support-vision {
    display: flex;
    flex-direction: column;
    gap: var(--bl-space-4);
}

.support-banner {
    width: 100%;
    border-radius: var(--bl-radius-md);
    overflow: hidden;
    border: 1px solid var(--bl-border);
    aspect-ratio: 16 / 7;
    background: var(--bl-surface-subtle);
}

.support-banner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.support-vision h1 {
    font-family: var(--bl-font-display);
    font-size: clamp(1.7rem, 3.2vw, 2.3rem);
    font-weight: 700;
    line-height: 1.25;
    color: var(--bl-primary);
}

.support-vision p {
    color: var(--bl-text-secondary);
    line-height: 1.65;
}

.upi-section {
    padding: var(--bl-space-5);
    background: var(--bl-parchment);
    border: 1px solid var(--bl-parchment-dark);
    border-radius: var(--bl-radius-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--bl-space-3);
    text-align: center;
}

.upi-title {
    font-weight: 700;
    color: var(--bl-bark-dark);
}

.qr-placeholder {
    width: 176px;
    height: 176px;
    max-width: 100%;
    background: var(--bl-surface);
    border-radius: var(--bl-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--bl-space-2);
    border: 1px solid var(--bl-parchment-dark);
}

.qr-placeholder img {
    max-width: 100%;
    max-height: 100%;
    border-radius: var(--bl-radius-sm);
}

.upi-id {
    background: var(--bl-surface);
    padding: var(--bl-space-1) var(--bl-space-3);
    border-radius: var(--bl-radius-sm);
    color: var(--bl-primary);
    font-size: var(--bl-text-sm);
    font-weight: 700;
    border: 1px solid var(--bl-parchment-dark);
}

.support-form-card {
    background: var(--bl-surface-subtle);
    border: 1px solid var(--bl-border);
    border-radius: var(--bl-radius-lg);
    padding: var(--bl-space-5);
}

.support-form-card h2 {
    font-family: var(--bl-font-display);
    font-size: var(--bl-text-xl);
    color: var(--bl-primary);
}

.support-form-card .form-sub {
    color: var(--bl-text-secondary);
    font-size: var(--bl-text-sm);
    margin: var(--bl-space-1) 0 var(--bl-space-4);
}

.support-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: var(--bl-space-4);
}

.support-form-grid .full-width {
    grid-column: 1 / -1;
}

.support-submit {
    width: 100%;
    margin-top: var(--bl-space-2);
    letter-spacing: 0.04em;
}

.support-thanks h3 {
    font-family: var(--bl-font-display);
    font-size: var(--bl-text-2xl);
    color: var(--bl-primary);
    margin-bottom: var(--bl-space-2);
}

.support-thanks p {
    color: var(--bl-text-secondary);
    line-height: 1.6;
    margin-bottom: var(--bl-space-4);
}

@media (max-width: 768px) {
    .support-container {
        padding: var(--bl-space-4);
    }

    .support-top {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .support-form-grid {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   LEGAL (privacy + terms)
   ======================================== */
.legal-container {
    max-width: 900px;
    margin: 0 auto;
    padding: var(--bl-space-6);
    color: var(--bl-text-secondary);
}

.legal-nav {
    position: sticky;
    top: calc(var(--bl-nav-height) + env(safe-area-inset-top, 0px));
    z-index: 5;
    display: flex;
    gap: var(--bl-space-5);
    padding: 0;
    margin: 0 0 var(--bl-space-5);
    background: var(--bl-surface);
    border-bottom: 2px solid var(--bl-border);
}

.legal-nav a {
    display: inline-flex;
    align-items: center;
    min-height: 48px;
    color: var(--bl-text-secondary);
    text-decoration: none;
    font-weight: 700;
    font-size: var(--bl-text-md);
    margin-bottom: -2px;
    border-bottom: 3px solid transparent;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.legal-nav a:hover,
.legal-nav a.active {
    color: var(--bl-primary);
    border-bottom-color: var(--bl-primary);
}

.legal-section {
    margin-bottom: var(--bl-space-6);
    scroll-margin-top: calc(var(--bl-nav-height) + 72px);
}

.legal-section h1 {
    font-family: var(--bl-font-display);
    font-size: clamp(1.8rem, 4vw, 2.2rem);
    font-weight: 700;
    margin-bottom: var(--bl-space-2);
    color: var(--bl-primary);
}

.legal-updated {
    color: var(--bl-text-muted);
    font-size: var(--bl-text-sm);
    margin-bottom: var(--bl-space-4);
}

.legal-section h2 {
    font-size: var(--bl-text-xl);
    font-weight: 700;
    margin-top: var(--bl-space-5);
    margin-bottom: var(--bl-space-2);
    color: var(--bl-text-primary);
}

.legal-section p {
    margin-bottom: var(--bl-space-3);
    line-height: 1.7;
    color: var(--bl-text-secondary);
}

.legal-section ul {
    margin-bottom: var(--bl-space-4);
    padding-left: var(--bl-space-5);
    color: var(--bl-text-secondary);
    line-height: 1.7;
}

.legal-section li {
    margin-bottom: var(--bl-space-2);
}

.legal-section strong {
    color: var(--bl-text-primary);
}

@media (max-width: 640px) {
    .legal-container {
        padding: var(--bl-space-4);
    }
}

/* ========================================
   ERROR PAGES (404 / 500)
   ======================================== */
.error-page {
    flex: 1;
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    padding: var(--bl-space-6) var(--bl-space-4);
    min-height: 70vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.error-art {
    width: min(100%, 240px);
    margin-bottom: var(--bl-space-4);
}

.error-art svg {
    display: block;
    width: 100%;
    height: auto;
}

.error-art .tree-bg {
    fill: var(--bl-parchment);
    stroke: var(--bl-parchment-dark);
    stroke-width: 2;
}

.error-art .tree-branch {
    stroke: var(--bl-bark);
}

.error-art .tree-node {
    fill: var(--bl-leaf);
    stroke: var(--bl-parchment);
    stroke-width: 3;
}

.error-art .tree-node--missing {
    fill: none;
    stroke: var(--bl-accent-hover);
    stroke-width: 3;
    stroke-dasharray: 5 5;
}

.error-code {
    font-family: var(--bl-font-display);
    font-size: clamp(3.5rem, 12vw, 5rem);
    font-weight: 800;
    line-height: 1;
    color: var(--bl-accent-hover);
    margin-bottom: var(--bl-space-2);
}

.error-page h1 {
    font-family: var(--bl-font-display);
    font-size: clamp(1.6rem, 5vw, 2.1rem);
    color: var(--bl-primary);
    margin-bottom: var(--bl-space-3);
}

.error-text {
    color: var(--bl-text-secondary);
    max-width: 28rem;
    line-height: 1.65;
    margin-bottom: var(--bl-space-5);
}

.error-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--bl-space-3);
}

/* ========================================
   CLAIM PROFILE + ONBOARDING
   ======================================== */
.claim-stage {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--bl-space-6) var(--bl-space-4);
    min-height: 70vh;
}

.claim-card {
    width: 100%;
    max-width: 500px;
    padding: var(--bl-space-6) var(--bl-space-5);
    text-align: center;
    border-top: 4px solid var(--bl-accent);
}

.claim-card h1 {
    font-family: var(--bl-font-display);
    font-size: var(--bl-text-2xl);
    color: var(--bl-primary);
    margin-bottom: var(--bl-space-3);
}

.claim-card > p,
.claim-note {
    color: var(--bl-text-secondary);
    line-height: 1.6;
    margin-bottom: var(--bl-space-5);
}

.claim-note {
    font-size: var(--bl-text-sm);
    margin: var(--bl-space-4) 0 0;
    color: var(--bl-text-muted);
}

.claim-avatar {
    width: 110px;
    height: 110px;
    margin: 0 auto var(--bl-space-4);
    border-radius: 50%;
    padding: 3px;
    border: 2px solid var(--bl-accent);
    background: var(--bl-surface-subtle);
}

.claim-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.claim-panel {
    background: var(--bl-surface-subtle);
    border: 1px solid var(--bl-border);
    border-radius: var(--bl-radius-md);
    padding: var(--bl-space-5);
    margin-bottom: var(--bl-space-4);
}

.claim-panel p {
    color: var(--bl-primary);
    font-weight: 600;
    margin-bottom: var(--bl-space-4);
    overflow-wrap: anywhere;
}

.claim-actions {
    display: flex;
    flex-direction: column;
    gap: var(--bl-space-3);
}

.claim-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto var(--bl-space-4);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bl-warning-soft);
    border: 2px solid var(--bl-warning);
    color: var(--bl-warning);
}

.claim-icon svg {
    width: 36px;
    height: 36px;
}

.claim-status {
    min-height: 1.5em;
    margin-top: var(--bl-space-3);
    font-size: var(--bl-text-sm);
    font-weight: 600;
    color: var(--bl-text-secondary);
}

.claim-status.is-error {
    color: var(--bl-danger);
}

/* Onboarding */
.onboarding-search-label {
    display: block;
    margin-bottom: var(--bl-space-2);
    font-size: var(--bl-text-sm);
    font-weight: 700;
    color: var(--bl-primary);
    text-align: left;
}

.onboarding-search-input {
    width: 100%;
    min-height: 48px;
    padding: var(--bl-space-3) var(--bl-space-4);
    background: var(--bl-surface);
    border: 1px solid var(--pg-input-border);
    border-radius: var(--bl-radius-md);
    color: var(--bl-text-primary);
    font-size: var(--bl-text-md);
    font-family: var(--bl-font-body);
}

.onboarding-search-input:focus-visible {
    outline: none;
    border-color: var(--bl-secondary);
    box-shadow: var(--bl-focus-ring);
}

.search-results {
    margin-top: var(--bl-space-3);
    max-height: 250px;
    overflow-y: auto;
    border-radius: var(--bl-radius-md);
    background: var(--bl-surface-subtle);
    text-align: left;
}

.search-results:not(:empty) {
    border: 1px solid var(--bl-border);
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: var(--bl-space-3);
    padding: var(--bl-space-3) var(--bl-space-4);
    border-bottom: 1px solid var(--bl-border);
    background: var(--bl-surface);
}

.search-result-item:last-child {
    border-bottom: 0;
}

.search-result-item img {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--bl-border);
    flex: none;
}

.search-result-text {
    flex: 1;
    min-width: 0;
    text-align: left;
}

.search-result-text strong {
    display: block;
    color: var(--bl-text-primary);
    overflow-wrap: anywhere;
}

.search-result-text small {
    color: var(--bl-text-muted);
}

.btn-claim-mini {
    flex: none;
    min-height: 44px;
    padding: 0 var(--bl-space-4);
    background: var(--bl-accent-hover);
    color: var(--bl-surface);
    border: 0;
    border-radius: var(--bl-radius-sm);
    font-size: var(--bl-text-sm);
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.btn-claim-mini:hover {
    background: var(--bl-warning);
}

.onboarding-divider {
    margin: var(--bl-space-5) 0;
    display: flex;
    align-items: center;
    gap: var(--bl-space-4);
    color: var(--bl-text-muted);
    font-weight: 700;
    font-size: var(--bl-text-sm);
    letter-spacing: 0.06em;
}

.onboarding-divider::before,
.onboarding-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--bl-border);
}

.btn-start {
    width: 100%;
    min-height: 52px;
    background: linear-gradient(135deg, var(--bl-primary), var(--bl-secondary));
    color: var(--bl-surface);
    border: 0;
    border-radius: var(--bl-radius-pill);
    font-size: var(--bl-text-lg);
    font-weight: 700;
    cursor: pointer;
    box-shadow: var(--bl-shadow-md);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    font-family: var(--bl-font-body);
}

.btn-start:focus-visible,
.btn-claim-mini:focus-visible {
    outline: none;
    box-shadow: var(--bl-focus-ring);
}

.onboarding-status {
    padding: var(--bl-space-3) var(--bl-space-4);
    background: var(--bl-surface);
    color: var(--bl-text-secondary);
    font-size: var(--bl-text-sm);
}

.onboarding-status.is-error {
    color: var(--bl-danger);
    font-weight: 600;
}

.btn-start:hover {
    transform: translateY(-2px);
    box-shadow: var(--bl-shadow-lg);
}

@media (max-width: 480px) {
    .claim-card {
        padding: var(--bl-space-5) var(--bl-space-4);
    }
}

/* Visually hidden helper */
.pg-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.search-container {
    margin: var(--bl-space-5) 0;
    text-align: left;
}

.field-hint-inline { font-weight: 400; color: var(--bl-text-secondary); font-size: var(--bl-text-sm); }
