/* =========================================================================
   Waupaca County Register of Deeds — Grantor/Grantee & Corporate Indexes
   Styling is built around WCAG 2.1 AA: AA contrast, visible focus, reflow
   to 320px, usable at 200% zoom, reduced-motion support, adequate targets.
   ========================================================================= */

:root {
    --navy: #14284b;          /* header/footer — white text = ~14:1 */
    --navy-deep: #0e1d38;
    --ink: #1a1a1a;           /* body text on white = ~15:1 */
    --muted: #495468;         /* secondary text on white = ~7:1 */
    --link: #12457e;          /* links on white = ~7.4:1 */
    --link-hover: #0a2f59;
    --link-light: #cdddf2;    /* links on navy = high contrast */
    --border: #b7c0cc;
    --surface: #ffffff;
    --surface-alt: #eef2f7;
    --danger: #b32020;        /* white text = ~6:1 */
    --danger-hover: #8c1717;
    --focus: #1a5fb4;
    --focus-on-dark: #ffd54a; /* amber on navy = high contrast */
    --radius: 6px;
    --maxw: 1120px;
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
    font-size: 1.0625rem;
    line-height: 1.6;
    color: var(--ink);
    background: var(--surface);
}

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 1rem; }

/* ---- Focus (WCAG 2.4.7 / 2.4.11) ------------------------------------- */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.site-header a:focus-visible,
.site-header button:focus-visible { outline-color: var(--focus-on-dark); }

/* ---- Skip link (WCAG 2.4.1) ------------------------------------------ */
.skip-link {
    position: absolute; left: 0; top: -60px;
    background: var(--navy); color: #fff; padding: .75rem 1rem;
    z-index: 1000; border-radius: 0 0 var(--radius) 0; text-decoration: none;
    transition: top .15s ease;
}
.skip-link:focus { top: 0; }

/* ---- Utilities ------------------------------------------------------- */
.visually-hidden, .sr-status, .sr-only {
    position: absolute !important; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0);
    white-space: nowrap; border: 0;
}

/* ---- Layout skeleton ------------------------------------------------- */
.page { display: flex; flex-direction: column; min-height: 100vh; }
.main-content { flex: 1 0 auto; padding: 2rem 1rem 3rem; }
.main-content:focus { outline: none; }

/* ---- Header ---------------------------------------------------------- */
.site-header { background: var(--navy); color: #fff; border-bottom: 4px solid #c9a227; }
.header-inner {
    display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 1.5rem;
    padding-top: .75rem; padding-bottom: .75rem;
}
.brand { display: flex; flex-direction: column; text-decoration: none; color: #fff; line-height: 1.2; }
.brand:hover .brand-office { text-decoration: underline; }
.brand-county { font-size: .8rem; letter-spacing: .04em; text-transform: uppercase; color: #dbe4f0; }
.brand-office { font-size: 1.25rem; font-weight: 700; }

.site-nav { margin-left: auto; }
.site-nav ul { list-style: none; display: flex; flex-wrap: wrap; gap: .25rem; margin: 0; padding: 0; }
.nav-item {
    display: inline-block; color: #fff; text-decoration: none;
    padding: .55rem .8rem; border-radius: var(--radius); font-weight: 600;
    min-height: 44px; line-height: 1.9;
}
.nav-item:hover { background: rgba(255,255,255,.14); text-decoration: underline; }
.nav-item.active { background: #fff; color: var(--navy); }

.account-area { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.staff-link, .admin-link { border: 1px solid rgba(255,255,255,.5); }
.logout-form { margin: 0; }
.btn-link {
    background: none; border: 1px solid rgba(255,255,255,.5); color: #fff;
    font: inherit; font-weight: 600; cursor: pointer;
    padding: .55rem .8rem; border-radius: var(--radius); min-height: 44px;
}
.btn-link:hover { background: rgba(255,255,255,.14); text-decoration: underline; }

/* ---- Links & typography ---------------------------------------------- */
a { color: var(--link); }
a:hover { color: var(--link-hover); }
h1 { font-size: 2rem; line-height: 1.2; margin: 0 0 .75rem; }
h2 { font-size: 1.4rem; line-height: 1.25; margin: 1.75rem 0 .5rem; }
.lead { font-size: 1.15rem; color: var(--ink); max-width: 65ch; }
.prose { max-width: 72ch; }
.prose h2 { margin-top: 2rem; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li { margin: .35rem 0; }
kbd {
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    background: var(--surface-alt); border: 1px solid var(--border);
    border-radius: 4px; padding: 0 .35em;
}

/* ---- Home ------------------------------------------------------------ */
.hero { max-width: 72ch; margin-bottom: 1.5rem; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.25rem; margin: 1.5rem 0 2.5rem; }
.index-card {
    background: var(--navy); color: #fff; border-radius: var(--radius);
    padding: 1.5rem; display: flex; flex-direction: column;
}
.index-card h2 { margin-top: 0; color: #fff; }
.index-card p { color: #e7edf6; }
.index-card strong { color: #fff; }
.card-action {
    margin-top: auto; display: inline-block; align-self: flex-start;
    background: #fff; color: var(--navy); font-weight: 700; text-decoration: none;
    padding: .65rem 1rem; border-radius: var(--radius); min-height: 44px; line-height: 1.9;
}
.card-action:hover { background: var(--link-light); color: var(--navy-deep); text-decoration: underline; }
.help-block { background: var(--surface-alt); border-radius: var(--radius); padding: 1.25rem 1.5rem; max-width: 72ch; }
.help-block h2 { margin-top: 0; }

/* ---- Index browse ---------------------------------------------------- */
.index-intro { max-width: 72ch; }
.index-search { background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; margin: 1.25rem 0; max-width: 640px; }
.index-search label { font-weight: 600; display: block; margin-bottom: .35rem; }
.search-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.index-search input[type="search"] { flex: 1 1 220px; }
.field-help { color: var(--muted); font-size: .95rem; margin: .5rem 0 0; }

.text-input, input[type="search"], input[type="text"], input[type="password"], select {
    font: inherit; padding: .6rem .7rem; border: 1px solid #6b7688;
    border-radius: var(--radius); background: #fff; color: var(--ink);
    min-height: 44px; width: 100%;
}
.text-input:focus, input:focus, select:focus { border-color: var(--focus); }

.result-summary { font-weight: 600; margin: 1rem 0 .5rem; }
.no-results { background: #fff4e5; border: 1px solid #d9a441; padding: 1rem; border-radius: var(--radius); }

/* Corporate index "check both volumes" note. Navy rule + tinted surface;
   body text stays --ink on --surface-alt (~13:1). */
.index-callout {
    background: var(--surface-alt); border-left: 5px solid var(--navy);
    border-radius: var(--radius); padding: .9rem 1.25rem; margin: 1rem 0; max-width: 72ch;
}
.index-callout p { margin: .25rem 0 0; }
.callout-title { font-size: 1.1rem; margin: 0; }

.alpha-nav { margin: .5rem 0 1.5rem; }
.alpha-nav ul { list-style: none; display: flex; flex-wrap: wrap; gap: .35rem; margin: 0; padding: 0; }
.alpha-nav a {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 44px; min-height: 44px; padding: 0 .5rem;
    border: 1px solid var(--border); border-radius: var(--radius);
    text-decoration: none; font-weight: 700; background: #fff;
}
.alpha-nav a:hover { background: var(--navy); color: #fff; }

.letter-section { border-top: 2px solid var(--border); padding-top: .5rem; margin-top: 1.5rem; }
.letter-heading { position: relative; display: flex; align-items: baseline; gap: .5rem; }
.anchor-target { position: absolute; top: -90px; }
.letter-count { font-size: 1rem; font-weight: 400; color: var(--muted); }

.doc-list { list-style: none; margin: .5rem 0 0; padding: 0;
    display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: .5rem; }
.doc-item { display: flex; align-items: stretch; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.doc-link {
    display: flex; align-items: center; gap: .6rem; flex: 1;
    padding: .65rem .75rem; text-decoration: none; color: var(--link);
    min-height: 44px; background: #fff;
}
.doc-link:hover { background: var(--surface-alt); text-decoration: underline; }
.doc-icon {
    font-size: .7rem; font-weight: 700; letter-spacing: .03em;
    background: var(--danger); color: #fff; border-radius: 3px;
    padding: .15rem .3rem; flex-shrink: 0;
}
.doc-label { font-weight: 600; color: var(--ink); }
.doc-link:hover .doc-label { color: var(--link-hover); }
.doc-note { font-size: .85rem; color: var(--muted); font-style: italic; }
.doc-download {
    display: flex; align-items: center; padding: 0 .75rem;
    border-left: 1px solid var(--border); background: var(--surface-alt);
    text-decoration: none; font-size: .85rem; font-weight: 600; color: var(--link);
    min-width: 44px; justify-content: center;
}
.doc-download:hover { background: var(--navy); color: #fff; }
.back-to-top { margin: .75rem 0 0; }

/* ---- Forms / login --------------------------------------------------- */
.form-field { margin-bottom: 1.1rem; max-width: 420px; }
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form-row .form-field { flex: 1 1 140px; }
.form-field label, .form-check label { font-weight: 600; }
.form-field > label { display: block; margin-bottom: .35rem; }
.form-check { display: flex; align-items: center; gap: .5rem; margin: 1rem 0; }
.form-check input { width: 22px; height: 22px; }
.form-actions, .confirm-actions { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: 1.25rem; }
.validation-message, .field-validation-error { color: var(--danger); font-weight: 600; display: block; margin-top: .3rem; }

.btn-primary, .btn-secondary, .btn-danger {
    font: inherit; font-weight: 700; cursor: pointer; text-decoration: none;
    padding: .65rem 1.1rem; border-radius: var(--radius); border: 2px solid transparent;
    min-height: 44px; display: inline-flex; align-items: center; justify-content: center;
}
.btn-primary { background: var(--link); color: #fff; }
.btn-primary:hover { background: var(--link-hover); color: #fff; }
.btn-secondary { background: #fff; color: var(--link); border-color: var(--link); }
.btn-secondary:hover { background: var(--surface-alt); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-block { width: 100%; }

.login-wrap { display: flex; justify-content: center; padding-top: 1rem; }
.login-card { width: 100%; max-width: 440px; border: 1px solid var(--border); border-radius: var(--radius); padding: 1.75rem; background: #fff; }
.login-intro { color: var(--muted); }

.error-summary { border: 2px solid var(--danger); background: #fdecec; border-radius: var(--radius); padding: 1rem 1.25rem; margin: 1rem 0; }
.error-summary-title { font-weight: 700; color: var(--danger); margin: 0 0 .25rem; }

/* ---- Admin ----------------------------------------------------------- */
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.admin-intro { color: var(--muted); max-width: 72ch; }
.admin-toolbar { margin: 1rem 0; max-width: 420px; }
.admin-toolbar label { font-weight: 600; display: block; margin-bottom: .35rem; }

.grid-wrap { overflow-x: auto; }
.admin-grid { width: 100%; border-collapse: collapse; }
.admin-grid th, .admin-grid td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--border); }
.admin-grid th { background: var(--surface-alt); }
.grid-action { display: inline-block; padding: .35rem .5rem; min-height: 36px; margin-right: .35rem; }
.grid-action-danger { background: none; border: 1px solid var(--danger); color: var(--danger); border-radius: var(--radius); cursor: pointer; font: inherit; font-weight: 600; }
.grid-action-danger:hover { background: var(--danger); color: #fff; }
.paginator { margin-top: 1rem; }

/* ---- QuickGrid sort indicator ---------------------------------------- */
/* QuickGrid's built-in sort arrow is a fixed-black SVG shown at opacity .5,
   which reads as a washed-out grey triangle against --surface-alt headers.
   Recolor it via mask so it takes currentColor at full strength: crisp and
   clearly directional, and still visible in forced-colors mode (currentColor
   maps to CanvasText). QuickGrid toggles .col-sort-asc / .col-sort-desc on the
   sorted <th>; the scaleY(-1) flip it applies for ascending order is inherited
   untouched. Selector is pinned to .quickgrid[theme=default] specificity so it
   beats both the theme's opacity rule and the scoped background-image rule
   regardless of stylesheet load order. */
.quickgrid[theme=default] .col-sort-asc .sort-indicator,
.quickgrid[theme=default] .col-sort-desc .sort-indicator {
    opacity: 1;
    background-image: none;
    background-color: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M2,3.25L12,20.75L22,3.25L12,10z'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M2,3.25L12,20.75L22,3.25L12,10z'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* ---- QuickGrid paginator navigation arrows --------------------------- */
/* Same situation as the sort indicator above: the scoped QuickGrid bundle
   that normally draws the paginator's first/prev/next/last glyphs isn't
   loaded (App.razor links only app.css), so the four nav <button>s render as
   empty boxes and stack vertically without the bundle's layout rules. Draw
   the arrows here with the same masked-SVG + currentColor technique: the
   glyph takes each button's text color at full strength and still shows in
   forced-colors mode (currentColor -> ButtonText). Buttons keep 44x44
   targets, a visible border, hover, and a clear disabled state; the global
   :focus-visible rule already covers keyboard focus. Selectors are pinned
   under .paginator so they outrank QuickGrid's own ::deep rules if the
   scoped bundle is ever linked later. */
.paginator { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.paginator-nav { display: inline-flex; gap: .35rem; }

.paginator .go-first,
.paginator .go-previous,
.paginator .go-next,
.paginator .go-last {
    width: 44px; height: 44px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    background: #fff; color: var(--link);
    border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer;
}
.paginator .go-first:hover:not(:disabled),
.paginator .go-previous:hover:not(:disabled),
.paginator .go-next:hover:not(:disabled),
.paginator .go-last:hover:not(:disabled) {
    background: var(--navy); color: #fff;
}
.paginator .go-first:disabled,
.paginator .go-previous:disabled,
.paginator .go-next:disabled,
.paginator .go-last:disabled {
    color: var(--muted); opacity: .55; cursor: not-allowed;
}

/* Directional glyph: a masked SVG tinted with the button's currentColor. */
.paginator .go-first::after,
.paginator .go-previous::after,
.paginator .go-next::after,
.paginator .go-last::after {
    content: ""; width: 22px; height: 22px;
    background-color: currentColor;
    -webkit-mask: var(--pg-arrow) center / contain no-repeat;
    mask: var(--pg-arrow) center / contain no-repeat;
}
.paginator .go-first::after {
    --pg-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M18.41 16.59L13.82 12l4.59-4.59L17 6l-6 6 6 6zM6 6h2v12H6z'/%3E%3C/svg%3E");
}
.paginator .go-previous::after {
    --pg-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z'/%3E%3C/svg%3E");
}
.paginator .go-next::after {
    --pg-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M8.59 16.59L13.17 12 8.59 7.41 10 6l6 6-6 6z'/%3E%3C/svg%3E");
}
.paginator .go-last::after {
    --pg-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5.59 7.41L10.18 12l-4.59 4.59L7 18l6-6-6-6zM16 6h2v12h-2z'/%3E%3C/svg%3E");
}

.confirm-panel { border: 3px solid var(--danger); background: #fff; border-radius: var(--radius); padding: 1.25rem 1.5rem; margin: 1rem 0; max-width: 640px; }
.confirm-panel h2 { margin-top: 0; }

.breadcrumb { margin: 0 0 .5rem; }

/* ---- Admin: staff accounts ------------------------------------------- */
.status-message { border: 2px solid #2e7d32; background: #edf7ee; border-radius: var(--radius);
    padding: .75rem 1rem; margin: 1rem 0; max-width: 72ch; }
.status-message p { margin: 0; }
.admin-panel { border: 1px solid var(--border); border-radius: var(--radius); background: #fff;
    padding: 1.25rem 1.5rem; margin: 1rem 0 1.5rem; max-width: 640px; }
.admin-panel h2 { margin-top: 0; }
.badge { display: inline-block; font-size: .8rem; font-weight: 700; padding: .1rem .45rem;
    border-radius: 999px; border: 1px solid var(--border); background: var(--surface-alt);
    color: var(--ink); margin-left: .35rem; white-space: nowrap; }
.badge-warning { background: #fff4e5; border-color: #b36b00; color: #6b3f00; }
.grid-action-button { background: none; border: 1px solid var(--link); color: var(--link);
    border-radius: var(--radius); cursor: pointer; font: inherit; font-weight: 600; }
.grid-action-button:hover { background: var(--link); color: #fff; }
.grid-action:disabled, .grid-action-button:disabled { opacity: .5; cursor: not-allowed; }

/* ---- Footer ---------------------------------------------------------- */
.site-footer { background: var(--navy); color: #e7edf6; margin-top: 2rem; }
.footer-inner { padding: 1.5rem 1rem 2rem; }
.site-footer a { color: var(--link-light); }
.site-footer a:hover { color: #fff; }
.footer-links { list-style: none; display: flex; gap: 1.25rem; padding: 0; margin: .5rem 0; }
.footer-office { font-weight: 600; margin: 0 0 .25rem; }
.footer-note { color: #c3cede; max-width: 72ch; margin: .5rem 0 0; }

/* ---- Responsive / reflow (WCAG 1.4.10) ------------------------------- */
@media (max-width: 720px) {
    .site-nav { margin-left: 0; width: 100%; }
    .site-nav ul { justify-content: flex-start; }
    .account-area { width: 100%; }
    h1 { font-size: 1.6rem; }
}

/* ---- Reduced motion (WCAG 2.3.3) ------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    * { animation-duration: .001ms !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
    .skip-link { transition: none; }
}

/* ---- Forced colors / high contrast ----------------------------------- */
@media (forced-colors: active) {
    .doc-item, .index-card, .login-card, .confirm-panel, .admin-panel, .index-callout, .badge { border: 1px solid; }
    .btn-primary, .btn-secondary, .btn-danger, .card-action { border: 1px solid; }
}
