/* ============================================
   THE JOURNAL OF BILLY THE BULL
   A book, not a website.
   ============================================ */

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

html { scroll-behavior: smooth; }

body {
    font-family: 'EB Garamond', Garamond, Georgia, serif;
    color: #1a1a1a;
    background: #2a2a2a; /* the desk under the book */
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    padding: 40px 20px;
}

/* subtle paper grain applied to pages */
:root {
    --ink: #1a1a1a;
    --ink-soft: #4a4a4a;
    --ink-mute: #8a8a8a;
    --paper: #f6f1e4;
    --paper-shade: #ece5d1;
    --paper-edge: #d8cfb4;
    --rule: #2a2a2a;
    --serif: 'EB Garamond', Garamond, Georgia, serif;
    --type: 'Special Elite', 'Courier New', monospace;
    --mono: 'JetBrains Mono', ui-monospace, monospace;
}

/* ============================================
   THE BOOK
   ============================================ */
.book {
    max-width: 720px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 40px;
}

/* ============================================
   PAGES
   ============================================ */
.page {
    background: var(--paper);
    background-image:
        /* aged edge shadow */
        radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,0.08) 100%),
        /* faint fiber texture */
        repeating-linear-gradient(
            90deg,
            transparent 0, transparent 2px,
            rgba(0,0,0,0.008) 2px, rgba(0,0,0,0.008) 3px
        ),
        repeating-linear-gradient(
            0deg,
            transparent 0, transparent 3px,
            rgba(0,0,0,0.006) 3px, rgba(0,0,0,0.006) 4px
        );
    color: var(--ink);
    padding: 0;
    min-height: 900px;
    position: relative;
    box-shadow:
        0 1px 0 rgba(255,255,255,0.05) inset,
        0 20px 40px rgba(0,0,0,0.5),
        0 40px 80px rgba(0,0,0,0.3);
    border: 1px solid var(--paper-edge);
    /* torn edge feel */
    clip-path: polygon(
        0% 0.5%, 2% 0%, 5% 0.3%, 8% 0%, 12% 0.4%, 18% 0%, 25% 0.3%, 33% 0%,
        42% 0.4%, 50% 0%, 58% 0.3%, 67% 0%, 75% 0.4%, 82% 0%, 88% 0.3%, 93% 0%,
        97% 0.4%, 100% 0%,
        100% 100%, 97% 99.6%, 93% 100%, 88% 99.7%, 82% 100%, 75% 99.6%,
        67% 100%, 58% 99.7%, 50% 100%, 42% 99.6%, 33% 100%, 25% 99.7%,
        18% 100%, 12% 99.6%, 8% 100%, 5% 99.7%, 2% 100%, 0% 99.5%
    );
}

.page-inner {
    padding: 90px 80px 70px;
    position: relative;
    min-height: 900px;
    display: flex;
    flex-direction: column;
}

/* folio number in top corner */
.folio {
    position: absolute;
    top: 40px;
    right: 60px;
    font-family: var(--serif);
    font-style: italic;
    font-size: 14px;
    color: var(--ink-mute);
}

.page-foot {
    margin-top: auto;
    padding-top: 40px;
    text-align: center;
    font-family: var(--serif);
    font-style: italic;
    font-size: 13px;
    color: var(--ink-mute);
    letter-spacing: 0.15em;
}

/* ============================================
   COVER PAGE
   ============================================ */
.cover {
    background: #ececd5;
    background-image:
        radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.12) 100%),
        repeating-linear-gradient(
            45deg,
            transparent 0, transparent 3px,
            rgba(0,0,0,0.01) 3px, rgba(0,0,0,0.01) 4px
        );
    border: 1px solid #c8bfa4;
}

.cover-inner {
    padding: 80px 70px;
    min-height: 900px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    text-align: center;
    border: 2px double var(--ink);
    margin: 24px;
    position: relative;
}

.cover-inner::before,
.cover-inner::after {
    content: "";
    position: absolute;
    left: 12px;
    right: 12px;
    height: 1px;
    background: var(--ink);
}
.cover-inner::before { top: 12px; }
.cover-inner::after { bottom: 12px; }

.cover-mono {
    font-family: var(--type);
    font-size: 12px;
    letter-spacing: 0.4em;
    margin-bottom: 20px;
    color: var(--ink);
}

.cover-name {
    font-family: var(--serif);
    font-size: 44px;
    font-weight: 600;
    letter-spacing: 0.05em;
    line-height: 1.1;
}
.cover-name span {
    font-style: italic;
    font-weight: 400;
    font-size: 32px;
    display: block;
    margin: 6px 0;
    color: var(--ink-soft);
}

.cover-mid {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px 0;
}

.cover-portrait {
    width: 220px;
    height: auto;
    mix-blend-mode: multiply;
}

.cover-title {
    font-family: var(--serif);
    font-style: italic;
    font-size: 32px;
    margin-bottom: 16px;
    letter-spacing: 0.02em;
}

.cover-sub {
    font-family: var(--serif);
    font-size: 17px;
    color: var(--ink-soft);
    line-height: 1.5;
    margin-bottom: 32px;
}

.cover-rule {
    width: 80px;
    height: 1px;
    background: var(--ink);
    margin: 0 auto 24px;
}

.cover-meta {
    display: flex;
    justify-content: space-around;
    font-family: var(--type);
    font-size: 11px;
    letter-spacing: 0.3em;
    color: var(--ink);
}

/* ============================================
   FRONTISPIECE
   ============================================ */
.epigraph {
    margin-top: 40px;
    text-align: center;
    font-family: var(--serif);
    font-style: italic;
    font-size: 22px;
    line-height: 1.8;
    color: var(--ink);
}
.epigraph p { margin: 0; }
.epigraph .attr {
    margin-top: 24px;
    font-size: 14px;
    color: var(--ink-mute);
    font-style: italic;
    letter-spacing: 0.05em;
}

.frontis-mark {
    margin: 60px auto;
    display: flex;
    justify-content: center;
}
.frontis-mark .mark {
    width: 140px;
    mix-blend-mode: multiply;
}

.frontis-note {
    max-width: 460px;
    margin: 0 auto;
    font-size: 14px;
    line-height: 1.7;
    color: var(--ink-soft);
    text-align: justify;
    hyphens: auto;
}
.frontis-note em { font-style: italic; }

/* ============================================
   CHAPTER HEADS
   ============================================ */
.chapter-head {
    text-align: center;
    margin-bottom: 40px;
}

.chapter-eyebrow {
    font-family: var(--type);
    font-size: 11px;
    letter-spacing: 0.4em;
    color: var(--ink-soft);
    margin-bottom: 16px;
    text-transform: uppercase;
}

.chapter-title {
    font-family: var(--serif);
    font-size: 42px;
    font-weight: 500;
    letter-spacing: 0.01em;
    line-height: 1.1;
    color: var(--ink);
    margin-bottom: 20px;
}

.chapter-rule {
    font-family: var(--serif);
    font-size: 18px;
    letter-spacing: 0.5em;
    color: var(--ink-mute);
}

/* ============================================
   PROSE
   ============================================ */
.prose {
    font-family: var(--serif);
    font-size: 18px;
    line-height: 1.75;
    color: var(--ink);
    max-width: 500px;
    margin: 0 auto;
    text-align: justify;
    hyphens: auto;
    -webkit-hyphens: auto;
}

.prose p {
    margin-bottom: 18px;
    text-indent: 0;
}

.prose p + p {
    text-indent: 1.6em;
}

.prose em {
    font-style: italic;
}

.dropcap {
    float: left;
    font-family: var(--serif);
    font-size: 68px;
    line-height: 0.85;
    font-weight: 500;
    padding: 6px 8px 0 0;
    margin-top: 4px;
}

.signoff {
    text-align: right;
    font-style: italic;
    margin-top: 32px;
    color: var(--ink-soft);
    text-indent: 0 !important;
}

.observations {
    margin: 20px 0 20px 24px;
    padding: 0;
    list-style: none;
    counter-reset: obs;
}
.observations li {
    counter-increment: obs;
    padding: 8px 0 8px 40px;
    position: relative;
    font-size: 17px;
    line-height: 1.7;
    text-align: left;
}
.observations li::before {
    content: counter(obs, upper-roman) ".";
    position: absolute;
    left: 0;
    top: 8px;
    font-family: var(--serif);
    font-style: italic;
    font-weight: 500;
    color: var(--ink-soft);
}

/* ============================================
   THE LEDGER
   ============================================ */
.ledger-intro {
    font-family: var(--serif);
    font-style: italic;
    font-size: 16px;
    text-align: center;
    color: var(--ink-soft);
    max-width: 480px;
    margin: 0 auto 40px;
    line-height: 1.6;
}

.ledger {
    max-width: 500px;
    margin: 0 auto;
    padding: 30px 0;
    border-top: 1px solid var(--ink);
    border-bottom: 1px solid var(--ink);
}

.ledger-row {
    display: flex;
    align-items: baseline;
    padding: 6px 0;
    font-family: var(--serif);
    font-size: 17px;
    gap: 8px;
}

.ledger-row.current {
    font-weight: 600;
    font-size: 20px;
}

.ledger-row.muted {
    color: var(--ink-soft);
    font-size: 15px;
    font-style: italic;
}

.ledger-label { flex-shrink: 0; }

.ledger-dots {
    flex: 1;
    border-bottom: 1px dotted var(--ink-mute);
    transform: translateY(-4px);
    min-width: 20px;
}

.ledger-value {
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
    font-family: var(--serif);
}

.progress-block {
    max-width: 500px;
    margin: 40px auto 20px;
    text-align: center;
}

.progress-caption {
    font-family: var(--serif);
    font-style: italic;
    font-size: 14px;
    color: var(--ink-soft);
    margin-bottom: 16px;
}

.progress-track {
    position: relative;
    height: 8px;
    background: var(--paper-shade);
    border: 1px solid var(--ink);
    margin-bottom: 40px;
}

.progress-fill {
    height: 100%;
    background: var(--ink);
    transition: width 0.8s ease;
}

.progress-tick {
    position: absolute;
    top: 14px;
    transform: translateX(-50%);
    font-family: var(--serif);
    font-style: italic;
    font-size: 12px;
    color: var(--ink-mute);
}
.progress-tick.right { transform: translateX(-100%); }

.progress-num {
    font-family: var(--serif);
    font-style: italic;
    font-size: 15px;
    color: var(--ink-soft);
}

.ledger-foot {
    max-width: 500px;
    margin: 40px auto 0;
    text-align: center;
    font-size: 14px;
    color: var(--ink-soft);
}
.ledger-foot p { margin-bottom: 16px; font-style: italic; }

.wallet-line {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    padding: 10px 14px;
    border: 1px dashed var(--ink-mute);
    background: rgba(0,0,0,0.02);
    margin-bottom: 12px;
    max-width: 100%;
}

.wl-label {
    font-family: var(--serif);
    font-style: italic;
    color: var(--ink-soft);
    font-size: 13px;
}

.wallet-line code {
    font-family: var(--mono);
    font-size: 11px;
    word-break: break-all;
    color: var(--ink);
}

.copy-btn {
    font-family: var(--serif);
    font-style: italic;
    font-size: 13px;
    color: var(--ink-soft);
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
    padding: 2px 4px;
}
.copy-btn:hover { color: var(--ink); }
.copy-btn.copied { color: #2f6d3a; text-decoration: none; }

.wallet-links {
    font-family: var(--serif);
    font-style: italic;
    font-size: 14px;
    color: var(--ink-soft);
}
.wallet-links a {
    color: var(--ink);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 0.5px;
}
.wallet-links a:hover { color: #2f6d3a; }
.wallet-links span { margin: 0 8px; color: var(--ink-mute); }

/* ============================================
   TORN / HANDWRITTEN NEXT ENTRY
   ============================================ */
.torn .page-inner {
    position: relative;
}

.handwritten {
    max-width: 400px;
    margin: 60px auto 40px;
    font-family: var(--type);
    font-size: 20px;
    line-height: 2.4;
    color: var(--ink-soft);
    text-align: left;
    /* faux notebook lines */
    background-image: repeating-linear-gradient(
        transparent 0,
        transparent 47px,
        rgba(0,0,0,0.15) 47px,
        rgba(0,0,0,0.15) 48px
    );
    padding: 4px 8px;
    transform: rotate(-0.6deg);
}
.handwritten p { margin: 0; }
.handwritten .hw-small { font-size: 15px; margin-top: 30px; color: var(--ink-mute); }

.corner-mark {
    position: absolute;
    bottom: 90px;
    right: 60px;
    width: 90px;
    opacity: 0.35;
    mix-blend-mode: multiply;
    transform: rotate(6deg);
}

/* ============================================
   COLOPHON
   ============================================ */
.colophon {
    text-align: center;
}

.colophon-inner {
    max-width: 480px;
    margin: 60px auto 0;
    font-family: var(--serif);
    color: var(--ink);
}

.colophon-title {
    font-family: var(--serif);
    font-style: italic;
    font-size: 32px;
    margin-bottom: 12px;
}

.colophon-rule {
    font-size: 16px;
    letter-spacing: 0.5em;
    color: var(--ink-mute);
    margin-bottom: 32px;
}

.colophon-inner p {
    font-size: 15px;
    line-height: 1.75;
    color: var(--ink-soft);
    margin-bottom: 16px;
}

.colophon-inner p.tiny {
    font-size: 12px;
    font-style: italic;
    color: var(--ink-mute);
    margin-top: 24px;
}

.colophon-sig {
    margin-top: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
}
.colophon-sig .mark.small {
    width: 60px;
    mix-blend-mode: multiply;
}
.sig-line {
    font-family: var(--serif);
    font-style: italic;
    font-size: 18px;
    color: var(--ink);
    text-align: left;
}
.sig-sub {
    font-family: var(--serif);
    font-style: italic;
    font-size: 13px;
    color: var(--ink-mute);
    text-align: left;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 720px) {
    body { padding: 20px 12px; }
    .book { gap: 24px; }
    .page-inner { padding: 70px 32px 60px; min-height: 700px; }
    .page { min-height: 700px; }
    .cover-inner { padding: 60px 28px; margin: 16px; min-height: 700px; }
    .cover-name { font-size: 32px; }
    .cover-name span { font-size: 22px; }
    .cover-portrait { width: 160px; }
    .cover-title { font-size: 24px; }
    .cover-meta { flex-direction: column; gap: 8px; font-size: 10px; }
    .chapter-title { font-size: 30px; }
    .prose { font-size: 16px; }
    .dropcap { font-size: 52px; }
    .ledger-row { font-size: 15px; }
    .ledger-row.current { font-size: 17px; }
    .folio { top: 24px; right: 32px; }
    .corner-mark { right: 30px; bottom: 70px; width: 70px; }
    .handwritten { font-size: 17px; line-height: 2.2; background-image: repeating-linear-gradient(transparent 0, transparent 39px, rgba(0,0,0,0.15) 39px, rgba(0,0,0,0.15) 40px); }
}
