/* ==========================================================================\n+   TudorLexicon base.css - structural system\n+   Layout, accessibility and components only. Colour and type live in\n+   tudor.css; dark overrides live in tudor_dark.css.\n+   Version 4.0.0 - 2026-08-02\n+   ========================================================================== */

/* ========== RESET AND ACCESSIBILITY ========== */

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { margin: 0; min-height: 100%; }
body { line-height: 1.6; text-rendering: optimizeLegibility; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:disabled, select:disabled { cursor: not-allowed; }
a { text-underline-offset: 0.18em; }
img, svg { display: block; max-width: 100%; }

.skip {
    position: fixed;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 100;
    padding: 0.6rem 0.85rem;
    transform: translateY(-160%);
}

.skip:focus { transform: translateY(0); }

/* ========== SITE CHROME ========== */

.site-header,
header.site {
    width: min(100% - 2rem, 1440px);
    margin: 0 auto;
}

.site-header {
    min-height: 4.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 0.75rem 0;
}

.brand-lockup,
.wordmark {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    text-decoration: none;
}

.brand-mark { width: 2rem; height: 2rem; flex: 0 0 auto; }
.brand-copy { display: grid; line-height: 1; }
.brand-copy small { margin-top: 0.3rem; }

.site-header nav {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.2rem;
}

.site-header nav a,
.theme-toggle {
    padding: 0.42rem 0.62rem;
    border: 0;
    background: transparent;
    text-decoration: none;
}

.site-rule { width: 100%; height: 1px; }

/* ========== HOME PAGE FRAME ========== */

main.tool-page {
    width: min(100% - 2rem, 1440px);
    margin: 0 auto;
    padding: 1.15rem 0 4rem;
}

.hero-strip {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 2rem;
    margin-bottom: 1rem;
}

.hero-strip h1 {
    margin: 0;
    font-size: clamp(2rem, 4vw, 4.7rem);
    line-height: 0.92;
    font-weight: 500;
    letter-spacing: -0.025em;
}

.hero-strip .mission {
    max-width: 42rem;
    margin: 0.55rem 0 0;
    font-size: clamp(1rem, 1.4vw, 1.24rem);
}

.folio-meta {
    text-align: right;
    white-space: nowrap;
    padding-bottom: 0.25rem;
}

.eyebrow,
.folio-meta,
.brand-copy small,
.panel-kicker,
.tool-pane > label,
.sync-control,
.library-heading p:first-child,
.corpus-fieldset legend,
.corpus-fieldset label,
.reading .byline {
    font-size: 0.69rem;
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

/* ========== CORPUS LIBRARY ========== */

.corpus-library {
    position: relative;
    margin: 0 0 0.85rem;
    padding: 0.8rem 0.9rem;
    border: 1px solid;
}

.library-topline {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
}

.library-heading h2 { margin: 0; font-size: 1.22rem; font-weight: 500; }
.library-heading p { margin: 0; }
.library-help { max-width: 62ch; text-align: right; font-size: 0.78rem; }

.corpus-grid {
    display: grid;
    grid-template-columns: minmax(15rem, 0.65fr) minmax(32rem, 1.35fr);
    gap: 0.75rem;
    margin-top: 0.6rem;
}

.corpus-fieldset {
    min-width: 0;
    margin: 0;
    padding: 0.52rem 0.65rem 0.65rem;
    border: 1px solid;
}

.corpus-fieldset legend { padding: 0 0.35rem; }
.corpus-fieldset label { display: grid; gap: 0.2rem; min-width: 0; }
.corpus-fieldset select {
    width: 100%;
    min-width: 0;
    padding: 0.44rem 0.55rem;
    border: 1px solid;
    border-radius: 0;
}

.play-selectors {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.45rem;
}

.selector-action {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.45rem;
}

.selector-action > select { flex: 1; }
.selector-action button,
.share-btn {
    flex: 0 0 auto;
    min-height: 2.25rem;
    padding: 0.38rem 0.72rem;
    border: 1px solid;
}

.selector-note { font-size: 0.72rem; line-height: 1.3; }
.corpus-status { margin: 0.55rem 0 0; font-size: 0.76rem; }

.work-progress {
    display: grid;
    grid-template-columns: auto minmax(8rem, 1fr) auto;
    align-items: center;
    gap: 0.65rem;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid;
}

.work-progress[hidden] { display: none; }
.progress-track { height: 0.28rem; overflow: hidden; }
.progress-bar { height: 100%; width: 8%; transition: width 220ms ease; }
.progress-spin { width: 0.9rem; height: 0.9rem; border: 1px solid; border-right-color: transparent; border-radius: 50%; animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ========== RHYME SUMMARY ========== */

.groups {
    min-height: 5.2rem;
    margin: 0 0 0.85rem;
    padding: 0.58rem 0.7rem 0.7rem;
    border: 1px solid;
}

.groups .rg-head {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.45rem;
    font-size: 0.76rem;
}

.groups .restored-badge { min-width: 1.45rem; padding: 0 0.35rem; text-align: center; }
.rg-list { display: flex; gap: 0.45rem; overflow-x: auto; padding-bottom: 0.16rem; scrollbar-width: thin; }
.rg {
    flex: 0 0 auto;
    min-width: 10.5rem;
    max-width: 15rem;
    padding: 0.45rem 0.55rem;
    border: 1px solid;
}

.rg.is-restored { border-left-width: 3px; }
.rg header { display: flex; justify-content: space-between; gap: 0.6rem; font-size: 0.68rem; }
.rg ul { display: flex; flex-wrap: wrap; gap: 0.18rem 0.55rem; margin: 0.35rem 0 0; padding: 0; list-style: none; }
.rg li { font-size: 0.82rem; }
.rg li .lnref { font-size: 0.62rem; }
.rg li .src { display: none; }
.rg .rg-key { font-family: var(--mono); }
.rg-restored, .rg-persist, .rg-broad-badge { text-transform: uppercase; letter-spacing: 0.08em; }
.groups .empty { margin: 1rem 0; text-align: center; font-style: italic; font-size: 0.84rem; }

/* ========== THREE-COLUMN WORKSPACE ========== */

.workspace-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.38rem;
}

.workspace-heading h2 { margin: 0; font-size: 1rem; font-weight: 500; }
.sync-control { display: inline-flex; align-items: center; gap: 0.45rem; cursor: pointer; }
.sync-control input { accent-color: currentColor; }

.tool {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: start;
    gap: 0.58rem;
}

.tool-pane { min-width: 0; }
.tool-pane > label { display: flex; justify-content: space-between; gap: 0.5rem; margin: 0 0 0.28rem; }
.tool-pane > label small { font: inherit; letter-spacing: 0.05em; opacity: 0.7; }

textarea[data-role="input"],
[data-role="modern-pane"],
[data-role="ipa-pane"] {
    width: 100%;
    height: 24rem;
    min-height: 24rem;
    margin: 0;
    padding: 0.78rem 0.82rem;
    overflow: auto;
    border: 1px solid;
    border-radius: 0;
    font-size: 0.96rem;
    line-height: 1.65;
    scrollbar-width: thin;
}

textarea[data-role="input"] { resize: vertical; white-space: pre; }
[data-role="ipa-pane"] .ipa { font-family: 'Charis SIL IPA', var(--mono); font-size: 0.92em; }
.ln { display: block; position: relative; min-height: 1.65em; padding-left: 2.15rem; white-space: pre-wrap; }
.ln-no { position: absolute; left: 0; top: 0.14em; font-family: var(--mono); font-size: 0.65em; user-select: none; }
.w { padding: 0 0.03em; border-bottom: 1px dotted transparent; }
.w.term { padding: 0 0.12em; border-bottom-color: currentColor; }

.share-row { display: flex; align-items: center; gap: 0.65rem; margin-top: 0.45rem; }
.share-hint { font-size: 0.72rem; }

/* ========== READING PAGES ========== */

main.reading {
    width: min(100% - 2rem, 74rem);
    margin: 2.4rem auto 4rem;
    padding: clamp(1.5rem, 4vw, 4rem);
    border: 1px solid;
}

.reading h1 { max-width: 18ch; margin: 0.35rem 0 1rem; font-size: clamp(2.2rem, 5vw, 4.8rem); line-height: 0.98; font-weight: 500; }
.reading .lede { max-width: 58ch; font-size: 1.3rem; line-height: 1.55; }
.reading section { max-width: 70ch; margin-top: 3rem; }
.reading h2 { margin: 0 0 0.8rem; padding-bottom: 0.35rem; border-bottom: 1px solid; font-size: 1.7rem; font-weight: 500; }
.reading p, .reading li { font-size: 1.04rem; }
.reading .related { padding: 1rem; border-left: 3px solid; }

footer,
footer.site-footer {
    width: min(100% - 2rem, 1440px);
    margin: 0 auto;
    padding: 1.5rem 0 2.5rem;
    border-top: 1px solid;
    font-size: 0.78rem;
}

.meta { margin-top: 1.5rem; font-size: 0.72rem; }
.meta p { margin: 0.4rem 0; }

/* ========== RESPONSIVE AND PRINT ========== */

@media (max-width: 1050px) {
    .corpus-grid { grid-template-columns: 1fr; }
    .tool { grid-template-columns: 1fr 1fr; }
    .tool-pane:first-child { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
    .site-header { align-items: flex-start; flex-direction: column; gap: 0.4rem; }
    .site-header nav { justify-content: flex-start; }
    .hero-strip { grid-template-columns: 1fr; gap: 0.3rem; }
    .folio-meta { display: none; }
    .library-topline { display: block; }
    .library-help { margin-top: 0.35rem; text-align: left; }
    .play-selectors { grid-template-columns: 1fr 1fr; }
    .tool { grid-template-columns: 1fr; }
    .tool-pane:first-child { grid-column: auto; }
    textarea[data-role="input"], [data-role="modern-pane"], [data-role="ipa-pane"] { height: 16rem; min-height: 16rem; }
}

@media (max-width: 460px) {
    .play-selectors { grid-template-columns: 1fr; }
    .selector-action { align-items: stretch; flex-direction: column; }
    .selector-action button { width: 100%; }
}

@media print {
    .no-print, .site-header, .corpus-library, .workspace-heading, .share-row { display: none !important; }
    body { background: #fff !important; color: #000 !important; }
    main.tool-page, main.reading { width: 100%; margin: 0; padding: 0; border: 0; }
    .tool { grid-template-columns: 1fr; }
    textarea[data-role="input"] { display: none; }
    [data-role="modern-pane"], [data-role="ipa-pane"] { height: auto; overflow: visible; }
}
