/* lazysite "theme-navy" for the default layout.
 *
 * Navy header/footer with a blue accent and a light reading area.
 * Adapted from the Sovereign Computing Initiative draft so it targets
 * the default layout's actual markup (.site-header, .site-nav,
 * .page-body, .site-footer, ...) rather than the draft's standalone
 * class names.
 *
 * Colours and fonts are driven by CSS custom properties emitted by the
 * processor from theme.json's config section. Edit theme.json to
 * recolour without touching this file.
 *
 * Naming convention: --theme-GROUP-KEY matches config.GROUP.KEY.
 */

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

body {
    font-family: var(--theme-fonts-body);
    font-size: 17px;
    line-height: 1.75;
    color: var(--theme-colours-text);
    background-color: var(--theme-colours-background);
    margin: 0;
    padding: 0;
    -webkit-text-size-adjust: 100%;
}

.wrapper {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 24px;
}

/* --- Header (navy bar, blue underline) --- */

.site-header {
    background-color: var(--theme-colours-heading);
    border-bottom: 3px solid var(--theme-colours-primary);
    padding: 18px 0 16px;
}

.site-header .wrapper {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 24px;
}

.site-name {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin: 0;
}

.site-name a {
    color: #FFFFFF;
    text-decoration: none;
}

.site-name a:hover {
    color: var(--theme-colours-primary);
}

/* --- Navigation (light uppercase links on navy) --- */

.site-nav { font-size: 0.75rem; }
.site-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 0;
}
.site-nav li { position: relative; }
.site-nav a {
    display: block;
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 6px 12px;
    border-radius: 3px;
    transition: background-color 0.15s, color 0.15s;
}
.site-nav a:hover {
    color: #FFFFFF;
    background-color: rgba(255, 255, 255, 0.08);
}
.site-nav a.active {
    color: #FFFFFF;
    font-weight: 700;
    border-bottom: 2px solid var(--theme-colours-primary);
    border-radius: 0;
    background-color: transparent;
}
.site-nav .nav-group-label {
    display: block;
    color: rgba(255, 255, 255, 0.45);
    padding: 6px 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    cursor: default;
}

/* Dropdown (navy-mid panel, light links) */
.site-nav .nav-children {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    flex-direction: column;
    gap: 0;
    background: #162032;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    min-width: 180px;
    z-index: 100;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}
.site-nav .nav-group:hover .nav-children,
.site-nav .nav-group:focus-within .nav-children { display: flex; }
.site-nav .nav-children li { width: 100%; }
.site-nav .nav-children a {
    padding: 8px 14px;
    font-size: 0.72rem;
    border-radius: 0;
    white-space: nowrap;
}
.site-nav .nav-children a:hover { background-color: rgba(255, 255, 255, 0.06); }

/* --- Main content --- */

.site-content {
    padding: 48px 0;
    min-height: 60vh;
}

.page-header {
    margin-bottom: 32px;
}

.page-title {
    font-size: clamp(1.6rem, 5vw, 2.4rem);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.02em;
    margin: 0 0 8px;
    color: var(--theme-colours-heading);
}

.page-subtitle {
    font-size: 1.15rem;
    font-weight: 400;
    color: var(--theme-colours-text-muted);
    margin: 0;
    line-height: 1.5;
}

/* --- Typography --- */

.page-body h1 { font-size: 1.85rem; font-weight: 700; line-height: 1.2; letter-spacing: -0.01em; margin: 40px 0 16px; color: var(--theme-colours-heading); }

/* Section headings: small, blue, uppercase, ruled - the draft's signature h2 */
.page-body h2 {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--theme-colours-primary);
    margin: 40px 0 14px;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--theme-colours-border);
}

.page-body h3 { font-size: 1.05rem; font-weight: 600; margin: 28px 0 10px; color: var(--theme-colours-heading); }
.page-body h4 { font-size: 1rem; font-weight: 600; margin: 24px 0 10px; color: var(--theme-colours-heading); }
.page-body h5 { font-size: 0.9rem; font-weight: 600; margin: 20px 0 8px; color: var(--theme-colours-text); }
.page-body h6 { font-size: 0.85rem; font-weight: 600; margin: 20px 0 8px; color: var(--theme-colours-text-muted); }

.page-body p { margin: 0 0 1.1rem; }

.page-body a {
    color: var(--theme-colours-primary);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

.page-body a:hover {
    color: var(--theme-colours-primary-hover);
    text-decoration-thickness: 2px;
}

.page-body ul, .page-body ol {
    margin: 0 0 1.1rem;
    padding-left: 1.5rem;
}

.page-body li { margin-bottom: 0.3rem; }

.page-body li > ul, .page-body li > ol {
    margin-top: 0.3rem;
    margin-bottom: 0.3rem;
}

.page-body dl { margin: 0 0 1.1rem; }
.page-body dt { font-weight: 600; color: var(--theme-colours-heading); margin-top: 0.75rem; }
.page-body dd { margin-left: 1.5rem; color: var(--theme-colours-text); }

.page-body img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

.page-body hr {
    border: none;
    border-top: 1px solid var(--theme-colours-border);
    margin: 32px 0;
}

.page-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 0 0 1.5rem;
    font-size: 0.95rem;
}

.page-body th {
    text-align: left;
    padding: 8px 12px;
    border-bottom: 2px solid var(--theme-colours-heading);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--theme-colours-text-muted);
}

.page-body td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--theme-colours-border);
    vertical-align: top;
}

.page-body tr:nth-child(even) td { background-color: var(--theme-colours-background-alt); }

/* --- Code (navy block, light-blue text) --- */

.page-body code {
    font-family: var(--theme-fonts-code);
    font-size: 0.85em;
    background-color: var(--theme-colours-background-alt);
    color: var(--theme-colours-heading);
    padding: 0.15em 0.4em;
    border-radius: 2px;
    border: 1px solid var(--theme-colours-border);
}

.page-body pre {
    background-color: var(--theme-colours-heading);
    color: #7DD3FC;
    border: none;
    border-radius: 3px;
    padding: 1.25rem 1.5rem;
    overflow-x: auto;
    margin: 0 0 1.5rem;
    font-size: 0.875rem;
    line-height: 1.6;
}

.page-body pre code {
    background: none;
    color: inherit;
    padding: 0;
    border: none;
    border-radius: 0;
    font-size: inherit;
}

/* --- Blockquote --- */

.page-body blockquote {
    margin: 0 0 1.1rem;
    padding: 0.25rem 0 0.25rem 1.25rem;
    border-left: 3px solid var(--theme-colours-primary);
    background: none;
    color: var(--theme-colours-text-muted);
    font-style: italic;
}

.page-body blockquote p:last-child { margin-bottom: 0; }

/* --- Fenced divs --- */

.widebox {
    background: var(--theme-colours-background-alt);
    border-left: 3px solid var(--theme-colours-primary);
    padding: 1.1rem 1.5rem;
    margin: 1.75rem 0;
    border-radius: 0 6px 6px 0;
}
.textbox {
    background: var(--theme-colours-background-alt);
    border-left: 3px solid var(--theme-colours-primary);
    padding: 1rem 1.25rem;
    margin: 1.5rem 0;
    max-width: 60%;
    border-radius: 0 6px 6px 0;
}
.marginbox {
    float: right;
    width: 14rem;
    margin: 0 0 1.5rem 2rem;
    padding-top: 0.75rem;
    border-top: 2px solid var(--theme-colours-primary);
    font-size: 0.875rem;
    font-style: italic;
    color: var(--theme-colours-text-muted);
}
.examplebox {
    background: var(--theme-colours-background-alt);
    border: 1px solid var(--theme-colours-border);
    border-top: 2px solid var(--theme-colours-heading);
    padding: 1.1rem 1.5rem;
    margin: 1.5rem 0;
    font-size: 0.95rem;
}

/* --- oEmbed --- */

.oembed { margin: 16px 0; }
.oembed iframe { max-width: 100%; }
.oembed--failed {
    display: inline-block;
    padding: 0.4rem 0.75rem;
    background: var(--theme-colours-background-alt);
    border: 1px solid var(--theme-colours-border);
    border-radius: 4px;
    font-size: 0.875rem;
    color: var(--theme-colours-text-muted);
    text-decoration: none;
}
.oembed--failed::before { content: "\25B6 "; }

/* --- Include errors (hidden by default) --- */
.include-error { display: none; }

/* --- Subtitle helper (auth pages etc.) --- */
.subtitle {
    color: var(--theme-colours-text-muted);
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
}

/* --- Footer (navy, blue top border) --- */

.site-footer {
    background-color: var(--theme-colours-heading);
    border-top: 3px solid var(--theme-colours-primary);
    padding: 1.5rem 0;
    font-size: 0.75rem;
    letter-spacing: 0.02em;
    color: rgba(255, 255, 255, 0.4);
}

.site-footer .wrapper {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 8px 24px;
}

.site-footer a {
    color: rgba(255, 255, 255, 0.4);
    text-decoration: none;
}

.site-footer a:hover { color: var(--theme-colours-primary); }

.page-modified {
    color: rgba(255, 255, 255, 0.3);
    font-size: 13px;
}

/* --- Site tools (auth indicator in header) --- */

.site-tools {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.85rem;
}
.auth-indicator { display: flex; align-items: center; gap: 0.5rem; }
.auth-user { color: rgba(255, 255, 255, 0.6); }
.auth-link { text-decoration: none; color: var(--theme-colours-primary); }
.auth-link:hover { text-decoration: underline; }
.auth-logout { color: rgba(255, 255, 255, 0.6); }
.auth-logout:hover { color: #FFFFFF; }

/* --- Forms --- */

.lazysite-form { max-width: 560px; }
.form-field { margin-bottom: 1rem; }
.form-field label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    color: var(--theme-colours-text);
}
.form-field input,
.form-field textarea,
.form-field select {
    width: 100%;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--theme-colours-border);
    border-radius: 4px;
    font-size: 0.875rem;
    font-family: inherit;
    background: var(--theme-colours-background-dropdown);
    color: var(--theme-colours-text);
    box-sizing: border-box;
}
.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
    outline: none;
    border-color: var(--theme-colours-primary);
    box-shadow: 0 0 0 2px var(--theme-colours-background-accent);
}
.form-field textarea { min-height: 120px; resize: vertical; }
.form-field .required { color: var(--theme-colours-primary); }
.form-submit { margin-top: 0.5rem; }
.form-submit button {
    padding: 0.5rem 1.25rem;
    background: var(--theme-colours-primary);
    color: #FFFFFF;
    border: none;
    border-radius: 4px;
    font-size: 0.875rem;
    cursor: pointer;
}
.form-submit button:hover { background: var(--theme-colours-primary-hover); }
.form-submit button:disabled { opacity: 0.5; cursor: not-allowed; }
.form-status {
    font-size: 0.875rem;
    color: var(--theme-colours-text-muted);
    margin-top: 0.5rem;
    min-height: 1.2em;
}
.form-success { color: #198754; }
.auth-error { color: #dc3545; font-size: 0.875rem; margin-bottom: 0.75rem; }
.auth-form { max-width: 360px; }

/* --- Search --- */

#search-form { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
#search-input {
    flex: 1;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--theme-colours-border);
    border-radius: 4px;
    font-size: 1rem;
    background: var(--theme-colours-background-dropdown);
    color: var(--theme-colours-text);
}
#search-status {
    font-size: 0.875rem;
    color: var(--theme-colours-text-muted);
    margin: 0.4rem 0;
    min-height: 1.2em;
}
.search-result {
    border-bottom: 1px solid var(--theme-colours-border);
    padding: 1rem 0;
}
.search-result:last-child { border-bottom: none; }
.search-result h2 { font-size: 1.1rem; margin: 0 0 0.25rem; border: none; padding: 0; text-transform: none; letter-spacing: normal; color: var(--theme-colours-heading); }
.search-result h2 a {
    color: var(--theme-colours-primary);
    text-decoration: none;
}
.search-result h2 a:hover { text-decoration: underline; }
.search-subtitle {
    color: var(--theme-colours-text-muted);
    font-size: 0.9rem;
    margin: 0.15rem 0;
}
.search-excerpt {
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0.3rem 0;
}
.search-excerpt mark {
    background: var(--theme-colours-background-accent);
    color: var(--theme-colours-heading);
    padding: 0.05em 0.1em;
    border-radius: 2px;
}
.search-tags { margin: 0.25rem 0; }
.search-tag {
    display: inline-block;
    background: var(--theme-colours-background-alt);
    border: 1px solid var(--theme-colours-border);
    border-radius: 3px;
    padding: 0.1rem 0.4rem;
    font-size: 0.78rem;
    margin-right: 0.3rem;
    color: var(--theme-colours-text-muted);
}
.search-date { font-size: 0.8rem; color: var(--theme-colours-text-dim); }

/* --- Features index layout --- */

.features-layout { display: flex; gap: 2rem; align-items: flex-start; }
.features-toc {
    position: sticky;
    top: 1rem;
    width: 200px;
    min-width: 200px;
    font-size: 0.8rem;
    line-height: 1.4;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    padding-right: 1rem;
    border-right: 1px solid var(--theme-colours-border);
}
.features-toc h3 {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--theme-colours-text-dim);
    margin: 1rem 0 0.3rem;
    padding: 0;
}
.features-toc ul { list-style: none; padding: 0; margin: 0 0 0.5rem; }
.features-toc li { margin: 0 0 0.35rem; }
.features-toc a {
    text-decoration: none;
    color: var(--theme-colours-primary);
}
.features-toc a:hover { text-decoration: underline; }
.features-toc small {
    color: var(--theme-colours-text-dim);
    font-size: 0.7rem;
}
.features-content { flex: 1; min-width: 0; }
.feature-entry {
    border-bottom: 1px solid var(--theme-colours-border);
    padding-bottom: 1.5rem;
    margin-bottom: 1.5rem;
}
.feature-entry:last-child { border-bottom: none; }

/* --- Responsive --- */

@media (max-width: 700px) {
    .features-layout { flex-direction: column; }
    .features-toc {
        position: static;
        width: 100%;
        min-width: 0;
        max-height: none;
        border-right: none;
        border-bottom: 1px solid var(--theme-colours-border);
        padding: 0 0 1rem;
        margin-bottom: 1rem;
    }
}

@media (max-width: 600px) {
    body { font-size: 16px; }
    .wrapper { padding: 0 16px; }
    .site-header .wrapper {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    .site-nav { gap: 2px 0; }
    .site-nav a { padding: 8px 10px; }
    .page-title { font-size: 1.6rem; }
    .page-subtitle { font-size: 1.05rem; }
    .site-content { padding: 28px 0; }
    .textbox { max-width: 100%; }
    .marginbox { float: none; width: 100%; margin: 1rem 0; }
    .site-footer .wrapper {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
}
