/* Newberry Bible: the site's pages and the reader */

:root {
    --paper: #fbf8f1;
    --page: #ffffff;
    --ink: #1d1a16;
    --ink-soft: #5b544a;
    --rule: #e2dccf;
    --accent: #7a2e1f;          /* a deep red, as Bible edges and ribbons */
    --accent-soft: #f3e4dd;
    --focus: #2b5fae;
    --serif: "EB Garamond", Georgia, "Times New Roman", serif;
    --sans: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; }

body {
    background: var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.55;
}

a { color: var(--accent); }

.inline { display: inline; margin: 0; }

/* header */

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 24px;
    border-bottom: 1px solid var(--rule);
    background: var(--page);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--ink);
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
    font-family: var(--serif);
    font-size: 20px;
    font-weight: 600;
}

.brand-name { font-family: var(--serif); font-size: 21px; font-weight: 600; }

.site-nav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }

.site-nav a { color: var(--ink-soft); text-decoration: none; font-weight: 500; }

.site-nav a.active, .site-nav a:hover { color: var(--ink); }

.link-button {
    border: 0;
    background: none;
    padding: 0;
    color: var(--ink-soft);
    font: inherit;
    font-weight: 500;
    cursor: pointer;
}

.button {
    display: inline-block;
    padding: 10px 18px;
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: #fff !important;
    font: 600 15px var(--sans);
    text-decoration: none;
    cursor: pointer;
}

.button.small { padding: 6px 12px; font-size: 14px; }

.button.ghost { background: transparent; color: var(--accent) !important; border: 1px solid var(--accent); }

/* home and plain pages */

.hero {
    max-width: 960px;
    margin: 0 auto;
    padding: 72px 24px 48px;
    text-align: center;
}

.hero h1 {
    font-family: var(--serif);
    font-size: clamp(36px, 6vw, 60px);
    font-weight: 600;
    line-height: 1.1;
    margin: 0 0 16px;
}

.hero p.lead { font-size: 19px; color: var(--ink-soft); max-width: 640px; margin: 0 auto 28px; }

.hero .actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.features {
    max-width: 960px;
    margin: 0 auto;
    padding: 24px 24px 64px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
}

.feature {
    background: var(--page);
    border: 1px solid var(--rule);
    border-radius: 10px;
    padding: 20px;
}

.feature h3 { font-family: var(--serif); font-size: 21px; margin: 0 0 6px; }

.feature p { margin: 0; color: var(--ink-soft); }

.prose {
    max-width: 720px;
    margin: 0 auto;
    padding: 48px 24px 64px;
}

.prose h1 { font-family: var(--serif); font-size: 40px; margin: 0 0 12px; }

.prose h2 { font-family: var(--serif); font-size: 26px; margin: 32px 0 8px; }

.site-footer {
    border-top: 1px solid var(--rule);
    padding: 24px;
    text-align: center;
    color: var(--ink-soft);
    font-size: 14px;
}

.site-footer p { margin: 4px 0; }

/* forms */

.card {
    max-width: 420px;
    margin: 56px auto;
    padding: 28px;
    background: var(--page);
    border: 1px solid var(--rule);
    border-radius: 12px;
}

.card h1 { font-family: var(--serif); font-size: 30px; margin: 0 0 18px; }

.field { margin-bottom: 14px; }

.field label { display: block; font-weight: 500; margin-bottom: 4px; }

.field input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--rule);
    border-radius: 8px;
    font: 16px var(--sans);
    background: #fff;
}

.field input:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: transparent; }

.check { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }

.error { color: #a1260f; font-size: 14px; margin-top: 4px; }

.status { background: #e9f3e6; color: #2c5a22; padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; }

.card .alt { margin-top: 16px; font-size: 14px; color: var(--ink-soft); }

/* the reader */

@font-face {
    font-family: Schola;                       /* the printed page's own typeface (TeX Gyre Schola) */
    src: url("../fonts/texgyreschola-regular.otf") format("opentype");
    font-style: normal;
}

@font-face {
    font-family: Schola;
    src: url("../fonts/texgyreschola-italic.otf") format("opentype");
    font-style: italic;
}

.sheet canvas.marks { position: absolute; display: block; pointer-events: none; }

/* Newberry's notes in the right margin: laid out in the page's own points, scaled with the page */
.sheet .bible { position: absolute; width: 396px; height: 612px; transform-origin: 0 0; pointer-events: none; }

.bnote {
    position: absolute;
    left: 334.2px;
    width: 43.6px;
    font: 5.4px/1.12 Schola, Georgia, serif;
    color: #141414;
    padding-left: 3px;
    text-indent: -3px;                         /* a note's later lines hang in */
    overflow-wrap: break-word;
}

body.reader-page { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }

.reader-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-bottom: 1px solid var(--rule);
    background: var(--page);
    flex-wrap: wrap;
}

.reader-bar .group { display: flex; align-items: center; gap: 4px; }

.reader-bar .sep { width: 1px; height: 24px; background: var(--rule); margin: 0 6px; }

.reader-bar button, .reader-bar select {
    height: 32px;
    min-width: 32px;
    padding: 0 8px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--ink);
    font: 500 14px var(--sans);
    cursor: pointer;
}

.reader-bar select { border-color: var(--rule); background: #fff; }

.reader-bar button:hover { background: #f1ede4; }

.reader-bar button.on { background: var(--accent-soft); border-color: #e2c4b8; }

.reader-bar button:disabled { opacity: 0.4; cursor: default; }

.reader-bar .title { font-family: var(--serif); font-size: 19px; font-weight: 600; min-width: 140px; text-align: center; }

.swatch {
    width: 22px !important;
    min-width: 22px !important;
    height: 22px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    border: 1px solid rgba(0, 0, 0, 0.2) !important;
}

.swatch.on { outline: 2px solid var(--focus); outline-offset: 2px; }

.reader-bar .note { color: var(--ink-soft); font-size: 13px; }

.reader-bar .sync { margin-left: auto; color: var(--ink-soft); font-size: 13px; }

.reader-stage {
    flex: 1;
    overflow: auto;
    background: #e9e5dc;
    position: relative;
}

.sheet {
    position: relative;
    margin: 24px auto;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
    transform-origin: 0 0;
}

.sheet canvas.pdf { position: absolute; display: block; }

.sheet canvas.ink { position: absolute; left: 0; top: 0; mix-blend-mode: multiply; }

.sheet .texts { position: absolute; left: 0; top: 0; pointer-events: none; }

.sheet .texts .typed { pointer-events: auto; }

.sheet.drawing .texts .typed { pointer-events: none; }      /* (ink goes over typed notes) */

.sheet.drawing canvas.ink { cursor: crosshair; touch-action: none; }

.typed {
    position: absolute;
    font-family: "New York", Georgia, "Times New Roman", serif;
    line-height: 1.2;
    white-space: pre-wrap;
    word-wrap: break-word;
    outline: none;
}

.typed a { color: #1d5fd1; }

.typed.editing { outline: 1px dashed #9aa7bd; background: rgba(255, 255, 255, 0.6); }

.sheet.typing { cursor: text; }

/* the card: a reference's verses, or a word's Greek or Hebrew */
.card-dialog {
    width: min(520px, calc(100vw - 32px));
    max-height: min(80vh, 720px);
    padding: 22px 24px;
    border: 1px solid var(--rule);
    border-radius: 12px;
    background: var(--page);
    color: var(--ink);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.card-dialog::backdrop { background: rgba(30, 26, 20, 0.35); }

.card-close {
    position: absolute;
    top: 8px;
    right: 10px;
    border: 0;
    background: none;
    font-size: 26px;
    line-height: 1;
    color: var(--ink-soft);
    cursor: pointer;
}

.card-dialog h2 { font-family: var(--serif); font-size: 26px; margin: 0 0 4px; }

.card-dialog .sub { color: var(--ink-soft); font-size: 14px; margin-bottom: 14px; }

.card-dialog .verses { font-family: var(--serif); font-size: 19px; line-height: 1.5; }

.card-dialog .verses sup { font-family: var(--sans); font-size: 11px; color: var(--ink-soft); margin-right: 3px; }

.card-dialog .original { font-family: "SBL Hebrew", "SBL Greek", "Times New Roman", serif; font-size: 40px; margin: 4px 0 10px; }

.card-dialog .original[dir=rtl] { text-align: right; }

.card-dialog dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0 0 12px; }

.card-dialog dt { color: var(--ink-soft); font-size: 14px; }

.card-dialog dd { margin: 0; }

.card-dialog .section { margin-top: 14px; }

.card-dialog .section h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-soft); margin: 0 0 4px; }

.card-dialog .credit { margin-top: 16px; font-size: 12px; color: var(--ink-soft); }

.card-dialog .actions { margin-top: 18px; }

.signin-hint {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--ink);
    color: #fff;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
}

.signin-hint a { color: #ffd9c9; }

@media (max-width: 640px) {
    .site-header { padding: 10px 16px; }
    .hero { padding: 48px 16px 32px; }
    .features, .prose { padding-left: 16px; padding-right: 16px; }
    .card { margin: 24px 16px; }
}
