/* ============================================================
   Waupaca County Directory of Public Officials
   Design system: professional civic reference.
   All foreground/background pairings meet WCAG 2.1 AA (>= 4.5:1
   for body text, >= 3:1 for large text and UI components).
   ============================================================ */

:root {
    /* Civic palette ------------------------------------------------ */
    --ink:            #1a1d1a;   /* near-black body text on white: 16.9:1 */
    --ink-soft:       #40453f;   /* secondary text on white: 9.3:1 */
    --paper:          #ffffff;
    --surface:        #f4f6f3;   /* subtle green-gray panel */
    --surface-2:      #e9ede8;
    --line:           #c7cec4;   /* borders */
    --line-strong:    #9aa697;

    /* Waupaca County green, darkened to pass AA on white ----------- */
    --forest:         #1f5130;   /* primary; on white 8.6:1 */
    --forest-dark:    #163a23;
    --forest-darker:  #0f2917;
    --forest-tint:    #e6efe8;   /* header/label backgrounds */
    --gold:           #8a6d00;   /* accent for the "updated" flag; on white 5.1:1 */
    --gold-tint:      #fbf3d8;

    --link:           #0b4f8a;   /* on white 6.7:1 */
    --link-visited:   #5a3a86;   /* on white 6.4:1 */
    --focus:          #b8460e;   /* high-visibility focus ring, 4.6:1 on white */

    --danger:         #9a1c1c;   /* on white 7.0:1 */
    --danger-tint:    #fbeaea;
    --ok:             #1f5130;

    /* Type --------------------------------------------------------- */
    --font-body: "Source Sans 3", "Segoe UI", Tahoma, Geneva, Verdana, system-ui, sans-serif;
    --font-head: "Merriweather", Georgia, "Times New Roman", serif;

    /* Base font a touch larger than default: this is a reference doc
       used by residents of all ages. */
    --fs-base: 1.125rem;   /* 18px */

    --radius: 8px;
    --radius-sm: 5px;
    --shadow: 0 1px 3px rgba(20, 30, 20, .10), 0 4px 12px rgba(20, 30, 20, .06);
    --shadow-lg: 0 6px 24px rgba(20, 30, 20, .14);

    --maxw: 1120px;
}

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

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

body {
    margin: 0;
    font-family: var(--font-body);
    font-size: var(--fs-base);
    line-height: 1.6;
    color: var(--ink);
    background: var(--surface);
}

h1, h2, h3, h4 {
    font-family: var(--font-head);
    line-height: 1.25;
    color: var(--forest-dark);
    margin: 0 0 .5em;
}

a { color: var(--link); }
a:visited { color: var(--link-visited); }
a:hover { text-decoration-thickness: 2px; }

/* ---- Global focus visibility (WCAG 2.4.7) ---------------------- */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* Skip link (WCAG 2.4.1) */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--forest-dark);
    color: #fff;
    padding: .75rem 1.25rem;
    z-index: 1000;
    border-radius: 0 0 var(--radius) 0;
    font-weight: 600;
}
.skip-link:focus {
    left: 0;
}

/* ---- Layout ---------------------------------------------------- */
.container { width: min(100% - 2rem, var(--maxw)); margin-inline: auto; }

.site-header {
    background: var(--forest-dark);
    color: #fff;
    border-bottom: 5px solid var(--gold);
}
.site-header a { color: #fff; }
.site-header__inner {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .9rem 0;
    flex-wrap: wrap;
}
.site-header__seal {
    height: 56px; width: auto;
    background: #fff; border-radius: 50%; padding: 3px;
    flex: 0 0 auto;
}
.site-header__titles { line-height: 1.2; }
.site-header__eyebrow {
    font-size: .8rem; letter-spacing: .12em; text-transform: uppercase;
    color: #d6e4d8; font-weight: 600; margin: 0;
}
.site-header__title {
    font-family: var(--font-head);
    font-size: 1.4rem; margin: 0; color: #fff;
}
.site-header__spacer { flex: 1 1 auto; }
.site-header__nav { display: flex; gap: .25rem; align-items: center; flex-wrap: wrap; }
.site-header__nav a, .site-header__nav .navlink {
    color: #fff; text-decoration: none; font-weight: 600;
    padding: .5rem .8rem; border-radius: var(--radius-sm);
}
.site-header__nav a:hover, .site-header__nav .navlink:hover {
    background: rgba(255,255,255,.15); text-decoration: underline;
}

.updated-flag {
    background: var(--gold-tint);
    border-bottom: 1px solid var(--line);
    color: var(--ink);
}
.updated-flag .container {
    display: flex; justify-content: flex-end; gap: .5rem;
    padding: .4rem 0; font-size: .95rem;
}
.updated-flag strong { color: var(--gold); }

main { display: block; padding: 2rem 0 4rem; }

.page-hero { text-align: center; padding: 1.5rem 0 .5rem; }
.page-hero h1 {
    font-size: clamp(1.9rem, 4vw, 2.8rem);
    color: var(--forest-dark);
    margin-bottom: .1em;
}
.page-hero .year {
    font-size: clamp(1.3rem, 3vw, 1.8rem);
    color: var(--forest);
    font-family: var(--font-head);
    font-weight: 700;
}
.page-hero .compiled {
    color: var(--ink-soft); margin-top: .5rem; font-style: italic;
}
.hero-actions { margin-top: 1rem; }
.btn-download {
    display: inline-block;
    padding: .55rem 1.1rem;
    background: var(--forest);
    color: #fff;
    font-weight: 600;
    border-radius: 6px;
    text-decoration: none;
    transition: background .15s ease;
}
.btn-download:hover, .btn-download:focus {
    background: var(--forest-dark);
    color: #fff;
}
.btn-download:focus-visible {
    outline: 3px solid var(--forest-tint);
    outline-offset: 2px;
}
/* This is an <a> styled as a button. Without this, the global a:visited rule
   repaints the label purple after the file downloads — unreadable on green. */
.btn-download:visited { color: #fff; }
@media print {
    .hero-actions, .search, .back-to-top { display: none; }
}

/* ---- Search --------------------------------------------------- */
.search {
    max-width: 640px; margin: 1.5rem auto 0;
    position: relative;
}
.search label {
    display: block; font-weight: 600; margin-bottom: .35rem; color: var(--forest-dark);
}
.search__row { display: flex; gap: .5rem; }
.search input[type="search"] {
    flex: 1; font-size: 1.1rem; padding: .7rem .9rem;
    border: 2px solid var(--line-strong); border-radius: var(--radius);
    background: #fff; color: var(--ink);
}
.search input[type="search"]::placeholder { color: #5c635a; }
.search__results {
    margin-top: .5rem; background: #fff; border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.search__results a {
    display: block; padding: .7rem 1rem; text-decoration: none;
    color: var(--ink); border-bottom: 1px solid var(--surface-2);
}
.search__results a:last-child { border-bottom: 0; }
.search__results a:hover, .search__results a:focus {
    background: var(--forest-tint);
}
.search__hit-label { font-weight: 600; color: var(--forest-dark); }
.search__hit-sec { font-size: .9rem; color: var(--ink-soft); }
.search__empty { padding: .8rem 1rem; color: var(--ink-soft); }

/* ---- Table of contents ---------------------------------------- */
.toc {
    background: #fff; border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 1.25rem 1.5rem; margin: 2rem 0;
}
.toc h2 {
    font-size: 1.3rem; text-align: center; letter-spacing: .04em;
    text-transform: uppercase; margin-bottom: 1rem;
    padding-bottom: .5rem; border-bottom: 2px solid var(--forest-tint);
}
.toc ol {
    list-style: none; margin: 0; padding: 0;
    display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: .3rem .5rem; counter-reset: toc;
}
.toc li { counter-increment: toc; }
.toc a {
    display: flex; gap: .6rem; align-items: baseline;
    text-decoration: none; color: var(--link);
    padding: .45rem .6rem; border-radius: var(--radius-sm);
}
.toc a::before {
    content: counter(toc);
    font-variant-numeric: tabular-nums;
    font-weight: 700; color: var(--forest);
    background: var(--forest-tint);
    border-radius: var(--radius-sm);
    min-width: 1.9rem; text-align: center; padding: .05rem .3rem;
    flex: 0 0 auto;
}
.toc a:hover { background: var(--surface); text-decoration: underline; }

/* ---- Sections ------------------------------------------------- */
.section { margin: 2.5rem 0; scroll-margin-top: 5rem; }
.section__head {
    background: var(--forest-dark);
    color: #fff;
    padding: .8rem 1.2rem;
    border-radius: var(--radius) var(--radius) 0 0;
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem;
}
.section__head h2 {
    color: #fff; margin: 0; font-size: 1.5rem;
}
.section__head .back-to-top {
    color: #fff; font-size: .9rem; font-weight: 600; white-space: nowrap;
    text-decoration: none; opacity: .95;
}
.section__head .back-to-top:hover { text-decoration: underline; }
.section__body {
    background: #fff; border: 1px solid var(--line); border-top: 0;
    border-radius: 0 0 var(--radius) var(--radius);
    padding: 1.5rem;
}
.section__subtitle { color: var(--ink-soft); margin: 0 0 1rem; }

/* ---- Headings within a section -------------------------------- */
.block-heading-1 {
    font-size: 1.4rem; color: var(--forest-dark);
    text-align: center; margin: 2rem 0 1rem;
    padding-bottom: .4rem; border-bottom: 2px solid var(--forest-tint);
}
.block-heading-1:first-child { margin-top: 0; }
.block-heading-2 {
    font-size: 1.15rem; color: var(--forest); text-align: center;
    margin: 1.5rem 0 .75rem; letter-spacing: .02em;
}

/* ---- Contact cards -------------------------------------------- */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}
.card {
    border: 1px solid var(--line);
    border-left: 5px solid var(--forest);
    border-radius: var(--radius);
    background: var(--surface);
    padding: 1rem 1.1rem;
}
.card__title {
    font-size: .82rem; font-weight: 700; letter-spacing: .06em;
    text-transform: uppercase; color: var(--forest-dark);
    margin: 0 0 .15rem;
}
.card__name {
    font-family: var(--font-head);
    font-size: 1.15rem; font-weight: 700; color: var(--ink);
    margin: 0 0 .4rem;
}
.card__rows { margin: 0; }
.card__row {
    display: flex; gap: .5rem; align-items: baseline;
    padding: .12rem 0;
}
.card__row .lbl {
    flex: 0 0 auto; font-size: .78rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .04em;
    color: var(--ink-soft); min-width: 3.6rem;
}
.card__row .val { color: var(--ink); }
.card__row a { word-break: break-word; }
.card__notes {
    margin-top: .5rem; padding-top: .5rem;
    border-top: 1px dashed var(--line);
    font-size: .92rem; color: var(--ink-soft);
}

/* ---- Two-column list (telephone index) ------------------------ */
.twocol {
    width: 100%; border-collapse: collapse; margin: 1rem 0;
    background: #fff;
}
.twocol caption { caption-side: top; text-align: left; color: var(--ink-soft); padding-bottom: .4rem; }
.twocol th, .twocol td {
    text-align: left; padding: .55rem .8rem; border-bottom: 1px solid var(--surface-2);
}
.twocol tbody tr:nth-child(odd) { background: var(--surface); }
.twocol .label { font-weight: 600; }
.twocol .value { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---- Rich text ------------------------------------------------ */
.richtext { max-width: 72ch; margin-inline: auto; }
.richtext :where(p, ul, ol) { margin: 0 0 1rem; }
.richtext ul, .richtext ol { padding-left: 1.4rem; }
.richtext li { margin-bottom: .35rem; }
.richtext a { word-break: break-word; }
.richtext img { max-width: 100%; height: auto; border-radius: var(--radius); }
.richtext.center { text-align: center; }

/* ---- Images --------------------------------------------------- */
.figure { margin: 1.5rem 0; text-align: center; }
.figure img {
    max-width: 100%; height: auto;
    border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.figure figcaption { color: var(--ink-soft); margin-top: .5rem; font-size: .95rem; }
.figure .missing {
    display: inline-block; padding: 2rem; background: var(--surface-2);
    border: 2px dashed var(--line-strong); border-radius: var(--radius);
    color: var(--ink-soft);
}

/* ---- Footer --------------------------------------------------- */
.site-footer {
    background: var(--forest-darker); color: #dfe7e0;
    padding: 2rem 0; margin-top: 3rem;
    font-size: .95rem;
}
.site-footer a { color: #fff; }
.site-footer .disclaimer {
    max-width: 70ch; margin: 0 auto 1rem; text-align: center;
    font-style: italic; color: #c3d0c6;
}
.site-footer .foot-meta { text-align: center; color: #a9b8ac; }

/* ---- Buttons & forms (shared) --------------------------------- */
.btn {
    display: inline-flex; align-items: center; gap: .4rem;
    font: inherit; font-weight: 600; cursor: pointer;
    padding: .55rem 1rem; border-radius: var(--radius);
    border: 2px solid transparent; text-decoration: none;
    line-height: 1.2;
}
.btn--primary { background: var(--forest); color: #fff; }
.btn--primary:hover { background: var(--forest-dark); }
.btn--secondary { background: #fff; color: var(--forest-dark); border-color: var(--line-strong); }
.btn--secondary:hover { background: var(--surface); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { background: #7d1414; }
.btn--sm { padding: .35rem .6rem; font-size: .9rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
/* Anchors styled as buttons (e.g. the admin "Download (Word)" link) must keep
   their label color after being clicked, not fall back to the a:visited color. */
.btn--primary:visited,
.btn--danger:visited { color: #fff; }
.btn--secondary:visited { color: var(--forest-dark); }

/* ---- Utility -------------------------------------------------- */
.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;
}
.text-center { text-align: center; }
.muted { color: var(--ink-soft); }

/* ---- Responsive ----------------------------------------------- */
@media (max-width: 640px) {
    .site-header__inner { flex-direction: column; align-items: flex-start; }
    .cards { grid-template-columns: 1fr; }
    .section__head { flex-direction: column; align-items: flex-start; gap: .3rem; }
}

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

/* ---- Print (residents print this directory) ------------------- */
@media print {
    .site-header__nav, .search, .updated-flag, .back-to-top,
    .admin-only, .site-footer a { display: none !important; }
    body { background: #fff; font-size: 11pt; }
    .section { break-inside: avoid; }
    .card { break-inside: avoid; border-left-color: #000; }
    a { color: #000; text-decoration: underline; }
}
