/*
  YawbleLabel base styles. Mobile first: works from 360 px wide with no sideways scroll,
  16 px body text and 44 px tap targets. Colours: docs/decisions.md ("Brand colour and contrast");
  keep them in step with YawbleLabel.Core/Branding/BrandColours.cs.
*/
:root {
    --yl-primary: #E83B00;            /* the mark's orange: accents, focus, borders, never body-size text */
    --yl-primary-text: #C43200;       /* text in orange, and the background behind white button text (5.5:1 on white) */
    --yl-primary-text-hover: #A82B00;
    --yl-primary-tint: #FDEBE4;
    --yl-text: #1A1A1A;
    --yl-text-muted: #555555;         /* 7.5:1 on white */
    --yl-bg: #FFFFFF;
    --yl-surface: #F7F7F7;
    --yl-border: #D0D0D0;
    --yl-danger: #B00020;
    --yl-radius: 8px;
    --yl-tap: 44px;
    --yl-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--yl-font);
    font-size: 16px;
    line-height: 1.5;
    color: var(--yl-text);
    background: var(--yl-bg);
    accent-color: var(--yl-primary);
    overflow-wrap: anywhere;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main { flex: 1; padding-block: 1.5rem 2.5rem; }

img, svg, video, canvas { max-width: 100%; height: auto; }

::selection { background: var(--yl-primary-text); color: #FFFFFF; }

.container { width: 100%; max-width: 1100px; margin-inline: auto; padding-inline: 1rem; }

h1, h2, h3 { line-height: 1.2; margin: 0 0 0.75rem; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.375rem; }
p { margin: 0 0 1rem; }
.lead { font-size: 1.125rem; }
.small { font-size: 0.875rem; color: var(--yl-text-muted); }

a { color: var(--yl-primary-text); text-underline-offset: 0.15em; }
a:hover { color: var(--yl-primary-text-hover); }
/* A link standing on its own (not inside a sentence) gets a full-size tap target. */
.tap-link { display: inline-flex; align-items: center; min-height: var(--yl-tap); }

:focus-visible { outline: 3px solid var(--yl-primary); outline-offset: 2px; }

.skip-link { position: absolute; left: -9999px; display: inline-flex; align-items: center; min-height: var(--yl-tap); }
.skip-link:focus { left: 1rem; top: 0.5rem; z-index: 100; background: var(--yl-bg); padding: 0.5rem 1rem; }

/* Header and brand component */
.site-header { border-bottom: 3px solid var(--yl-primary); background: var(--yl-bg); }
.site-header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 60px; }

.brand {
    display: inline-flex;
    align-items: center;
    min-height: var(--yl-tap);
    min-width: 0;
    text-decoration: none;
}
/* The wordmark is sized by width so height: auto (the global img rule) keeps its 1200 x 308 proportions:
   187 px wide is 48 px tall, and max-width lets it shrink with the header rather than overflow. */
.brand-logo { display: block; width: 187px; max-width: 100%; height: auto; }
@media (max-width: 480px) {
    .brand-logo { width: 156px; } /* 40 px tall, leaving room for the Menu button at 360 px */
}

/* Footer */
.site-footer { border-top: 1px solid var(--yl-border); background: var(--yl-surface); padding-block: 1.25rem; }
.site-footer p:last-child { margin-bottom: 0; }

/* Controls: every tap target is at least 44 x 44 px. */
button, .button, input, select, textarea { font: inherit; font-size: 1rem; }

button, .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--yl-tap);
    min-width: var(--yl-tap);
    padding: 0.5rem 1.1rem;
    border: 1px solid var(--yl-border);
    border-radius: var(--yl-radius);
    background: var(--yl-bg);
    color: var(--yl-text);
    text-decoration: none;
    cursor: pointer;
    font-weight: 600;
}
button:hover, .button:hover { background: var(--yl-surface); color: var(--yl-text); }

.button-primary, button.button-primary {
    background: var(--yl-primary-text);
    border-color: var(--yl-primary-text);
    color: #FFFFFF;
}
.button-primary:hover, button.button-primary:hover { background: var(--yl-primary-text-hover); border-color: var(--yl-primary-text-hover); color: #FFFFFF; }

.button-danger, button.button-danger { background: var(--yl-danger); border-color: var(--yl-danger); color: #FFFFFF; }

input:not([type="checkbox"]):not([type="radio"]), select, textarea {
    min-height: var(--yl-tap);
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--yl-border);
    border-radius: var(--yl-radius);
    background: var(--yl-bg);
    color: var(--yl-text);
}

table { border-collapse: collapse; width: 100%; }
.table-scroll { overflow-x: auto; }

/* Pages */
.coming-soon, .hero { max-width: 40rem; margin: 2rem auto; text-align: center; }

/* Header navigation (Pages/Shared/_SignedInNav.cshtml, _PublicNav.cshtml) */
.site-nav { position: relative; }
.nav-links { display: flex; flex-wrap: wrap; align-items: center; gap: 0.1rem 0.25rem; list-style: none; margin: 0; padding: 0; }
.nav-links a, .nav-link-button {
    display: inline-flex; align-items: center; min-height: var(--yl-tap); padding: 0.25rem 0.6rem;
    border-radius: var(--yl-radius); color: var(--yl-text); text-decoration: none; font-weight: 600;
}
.nav-links a:hover, .nav-link-button:hover { background: var(--yl-primary-tint); color: var(--yl-text); }
.nav-links a[aria-current="page"] { color: var(--yl-primary-text); box-shadow: inset 0 -3px 0 var(--yl-primary); }
.nav-links a.nav-cta { color: #FFFFFF; margin-left: 0.25rem; }
.nav-links a.nav-cta:hover { color: #FFFFFF; background: var(--yl-primary-text-hover); }
.nav-signout { margin: 0; }
.nav-link-button { border: 0; background: none; font-size: 1rem; cursor: pointer; min-width: 0; justify-content: flex-start; }
.nav-account { position: relative; }
.nav-account-toggle { gap: 0.4rem; max-width: 16rem; -webkit-tap-highlight-color: transparent; }
.nav-account-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.nav-account-caret { flex: none; width: 0; height: 0; border-inline: 5px solid transparent; border-top: 6px solid currentColor; }
.nav-account-toggle[aria-expanded="true"] { background: var(--yl-primary-tint); }
.nav-account-toggle[aria-expanded="true"] .nav-account-caret { transform: rotate(180deg); }
.nav-account-menu { list-style: none; margin: 0; padding: 0; }
.nav-account-menu a, .nav-account-menu .nav-link-button { width: 100%; white-space: nowrap; }
.nav-account.account-ready:not(.account-open) .nav-account-menu { display: none; }
.nav-account.account-ready .nav-account-menu {
    position: absolute; right: 0; top: calc(100% + 0.25rem); z-index: 55; min-width: 12rem; padding: 0.35rem;
    background: var(--yl-bg); border: 1px solid var(--yl-border); border-radius: var(--yl-radius); box-shadow: 0 10px 30px rgb(0 0 0 / 0.18);
}
.nav-toggle { display: none; gap: 0.5rem; -webkit-tap-highlight-color: transparent; }
.nav-toggle[aria-expanded="true"] { background: var(--yl-primary-tint); border-color: var(--yl-primary); }
.nav-toggle-bars, .nav-toggle-bars::before, .nav-toggle-bars::after {
    display: block; width: 18px; height: 2px; background: currentColor; border-radius: 1px; position: relative;
}
.nav-toggle-bars::before, .nav-toggle-bars::after { content: ""; position: absolute; left: 0; }
.nav-toggle-bars::before { top: -6px; }
.nav-toggle-bars::after { top: 6px; }

@media (max-width: 700px) {
    .site-header-inner { flex-wrap: wrap; }
    .site-nav.nav-ready .nav-toggle { display: inline-flex; }
    .site-nav.nav-ready:not(.nav-open) .nav-links { display: none; }
    .site-nav.nav-ready .nav-links {
        position: absolute; right: 0; top: calc(100% + 0.5rem); z-index: 50;
        flex-direction: column; align-items: stretch; width: min(18rem, calc(100vw - 2rem));
        padding: 0.5rem; background: var(--yl-bg); border: 1px solid var(--yl-border);
        border-top: 3px solid var(--yl-primary); border-radius: var(--yl-radius); box-shadow: 0 10px 30px rgb(0 0 0 / 0.18);
    }
    .site-nav.nav-ready .nav-links a, .site-nav.nav-ready .nav-link-button { width: 100%; }
    .nav-links a.nav-cta { margin-left: 0; justify-content: center; }
    .site-nav.nav-ready .nav-account-toggle { max-width: none; justify-content: space-between; }
    .site-nav.nav-ready .nav-account.account-ready .nav-account-menu {
        position: static; min-width: 0; padding: 0 0 0 1rem; border: 0; box-shadow: none; background: none;
    }
}

/* Administrator Mode banner (Pages/Shared/_ImpersonationBanner.cshtml) */
.impersonation-banner { position: sticky; top: 0; z-index: 60; background: #1A1A1A; color: #FFFFFF; border-bottom: 3px solid var(--yl-primary); }
.impersonation-banner-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; padding-block: 0.5rem; }
.impersonation-banner p { margin: 0; }
.impersonation-banner form { margin: 0; }
.impersonation-banner button { background: #FFFFFF; color: #1A1A1A; border-color: #FFFFFF; }

/* Footer links */
.footer-links { display: flex; flex-wrap: wrap; gap: 0 1.25rem; margin-bottom: 0.5rem; }

/* Notices in a page (never a browser alert) */
.notice { border: 1px solid var(--yl-border); border-left: 5px solid var(--yl-primary); border-radius: var(--yl-radius); background: var(--yl-surface); padding: 0.75rem 1rem; margin: 0 0 1.25rem; }
.notice p:last-child, .notice form:last-child { margin-bottom: 0; }
.notice-success { border-left-color: #1E7B34; }
.notice-error { border-left-color: var(--yl-danger); }
.notice-warning { border-left-color: #B86E00; }
.notice form { margin-top: 0.5rem; }

/* Forms */
.form-narrow { max-width: 28rem; }
.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
.field .hint { font-size: 0.875rem; color: var(--yl-text-muted); margin: 0.25rem 0 0; }
.field-error { color: var(--yl-danger); font-size: 0.9375rem; margin: 0.25rem 0 0; }
.check { display: flex; align-items: flex-start; gap: 0.6rem; min-height: var(--yl-tap); margin-bottom: 0.75rem; }
.check input { width: 1.375rem; height: 1.375rem; margin-top: 0.1rem; flex: none; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin-top: 1.25rem; }
.validation-summary-errors ul { margin: 0; padding-left: 1.25rem; }
.inline-form { display: inline; margin: 0; }
.section-box { border: 1px solid var(--yl-border); border-radius: var(--yl-radius); padding: 1rem; margin-bottom: 1.25rem; }
.status-mark { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.875rem; font-weight: 600; background: var(--yl-surface); border: 1px solid var(--yl-border); }
.status-mark-ok { color: #1E7B34; border-color: #1E7B34; }
.status-mark-warn { color: #8A5200; border-color: #B86E00; }
.status-mark-bad { color: var(--yl-danger); border-color: var(--yl-danger); }

/* Dashboard (Pages/Dashboard/Index.cshtml) */
.dashboard-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1rem; margin-bottom: 1.5rem; }
.dashboard-balance { font-size: 1.125rem; margin-bottom: 0.75rem; }
.dashboard-sections { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); gap: 1rem; }
.dashboard-section { border: 1px solid var(--yl-border); border-radius: var(--yl-radius); padding: 1rem; min-width: 0; }
.dashboard-section-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.5rem; }
.dashboard-section-head h2 { margin: 0; font-size: 1.125rem; }

/* Tables that become one card per row on a phone */
.data-table th, .data-table td { text-align: left; padding: 0.5rem; border-bottom: 1px solid var(--yl-border); vertical-align: top; }
.data-table th { font-size: 0.875rem; color: var(--yl-text-muted); }
@media (max-width: 700px) {
    .data-table thead { display: none; }
    .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
    .data-table tr { border: 1px solid var(--yl-border); border-radius: var(--yl-radius); margin-bottom: 0.75rem; padding: 0.25rem 0.5rem; }
    .data-table td { border-bottom: 0; padding: 0.3rem 0; }
    .data-table td[data-label]::before { content: attr(data-label) ": "; font-weight: 600; color: var(--yl-text-muted); }
}

/* Policy pages */
.policy { max-width: 46rem; }
.policy h2 { margin-top: 2rem; }
.policy h3 { margin-top: 1.25rem; font-size: 1.125rem; }
.price-figure { font-size: 2rem; font-weight: 700; margin: 0 0 0.25rem; }

/* App dialog (wwwroot/js/app-dialog.js) */
.app-dialog {
    width: min(32rem, calc(100vw - 2rem));
    max-height: calc(100dvh - 2rem);
    padding: 0;
    border: 1px solid var(--yl-border);
    border-top: 4px solid var(--yl-primary);
    border-radius: var(--yl-radius);
    color: var(--yl-text);
    background: var(--yl-bg);
    box-shadow: 0 10px 30px rgb(0 0 0 / 0.25);
}
.app-dialog::backdrop { background: rgb(0 0 0 / 0.45); }
.app-dialog-body { padding: 1.25rem; overflow-y: auto; }
.app-dialog-title { font-size: 1.25rem; margin: 0 0 0.75rem; }
.app-dialog-message p:last-child { margin-bottom: 0; }
.app-dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.5rem; padding: 0 1.25rem 1.25rem; }

@media (max-width: 480px) {
    h1 { font-size: 1.5rem; }
    .app-dialog { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: var(--yl-radius) var(--yl-radius) 0 0; }
    .app-dialog-actions { flex-direction: column-reverse; }
    .app-dialog-actions button { width: 100%; }
}

/* Small helpers used by the accounts pages */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.steps { text-align: left; display: inline-block; margin: 0 auto 1rem; padding-left: 1.5rem; }
.steps li { margin-bottom: 0.5rem; }
