/* ===== SHARED ESSAY LAYOUT =====
   Linked by all pages in /writing/*.html
   Edit here to apply changes across every essay at once.
   ================================================== */

/* Playfair Display is loaded via <link> in each essay page's <head>.
   This file only references the family name — no @import needed. */

/* Reading progress bar */
.reading-progress {
    position: fixed;
    top: 0; left: 0;
    height: 2px;
    background: var(--accent);
    z-index: 200;
    width: 0%;
    transition: width 0.1s linear;
}

/* Layout containers */
.essay-header {
    max-width: 720px;
    margin: 0 auto;
    padding: 140px 48px 24px;
}

.essay-body-wrap {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 48px 60px;
}

.essay-refs {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 48px 40px;
}

.essay-end {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 48px 60px;
}

.essay-foot-nav {
    max-width: 720px;
    margin: 0 auto;
    padding: 32px 48px 80px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 32px;
    flex-wrap: wrap;
}

/* Category label */
.essay-cat {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 20px;
}

/* Title */
.essay-title {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: clamp(2rem, 4vw, 3rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.12;
    margin-bottom: 24px;
    color: var(--text);
}

.essay-title em {
    font-style: italic;
    color: var(--accent);
}

/* Meta */
.essay-meta {
    display: flex;
    align-items: center;
    gap: 14px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.essay-meta-dot {
    width: 3px; height: 3px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
}

.essay-subtitle {
    font-size: 1rem;
    line-height: 1.65;
    color: var(--text-muted);
    margin-bottom: 28px;
}

.essay-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin-bottom: 0;
}

/* Action bar (listen + share) */
.essay-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0 4px;
}

.essay-listen-btn[hidden],
.essay-player-bar[hidden] { display: none !important; }

.essay-listen-btn {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background: none;
    border: none;
    padding: 0;
    cursor: default;
    color: var(--text-muted);
    opacity: 0.4;
}

.essay-listen-btn:not([disabled]) {
    cursor: pointer;
    opacity: 1;
    color: var(--text);
}

.essay-listen-play {
    width: 36px; height: 36px;
    border-radius: 50%;
    border: 1.5px solid currentColor;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.essay-listen-label {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.essay-share-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 8px 18px;
    cursor: pointer;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    transition: border-color 0.2s, background 0.2s;
}

.essay-share-btn:hover {
    border-color: var(--text);
    background: var(--bg-secondary);
}

/* Body typography */
.essay-body {
    font-size: 1.05rem;
    line-height: 1.85;
    color: var(--text);
}

.essay-body p { margin-bottom: 24px; }

.essay-body p:first-of-type { font-size: 1.1rem; }

.essay-body p:first-of-type::first-letter {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 4.2rem;
    font-weight: 400;
    float: left;
    line-height: 0.78;
    margin: 10px 14px 0 0;
    color: var(--accent);
}

.essay-body h2 {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.25;
    margin: 52px 0 18px;
    color: var(--text);
}

.essay-body strong { font-weight: 600; color: var(--text); }
.essay-body em { font-style: italic; }

.essay-body a {
    color: var(--accent);
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s;
}
.essay-body a:hover { border-bottom-color: var(--accent); }

/* Inline code */
.essay-body code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: var(--bg-secondary);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--border);
}

/* Blockquote */
.essay-body blockquote {
    border-left: 2px solid var(--accent);
    padding: 4px 0 4px 28px;
    margin: 36px 0;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-style: italic;
    font-size: 1.3rem;
    line-height: 1.55;
    color: var(--text);
}

/* Arrow lists */
.essay-body ul {
    margin: 24px 0;
    padding-left: 0;
    list-style: none;
}

.essay-body ul li {
    font-size: 1.05rem;
    line-height: 1.75;
    padding-left: 28px;
    margin-bottom: 14px;
    position: relative;
    color: var(--text);
}

.essay-body ul li::before {
    content: "→";
    position: absolute;
    left: 0;
    color: var(--accent);
}

/* Footnote superscripts */
.essay-body sup {
    font-size: 0.68rem;
    color: var(--accent);
    font-weight: 500;
}

.essay-body sup a { border-bottom: none; }

/* References section */
.essay-refs-title {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 20px;
    padding-top: 32px;
    border-top: 1px solid var(--border);
}

.ref-item {
    font-size: 0.82rem;
    line-height: 1.65;
    color: var(--text-muted);
    margin-bottom: 12px;
    padding-left: 24px;
    position: relative;
}

.ref-num {
    position: absolute;
    left: 0;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--accent);
    font-weight: 500;
    top: 3px;
}

.ref-item a { color: var(--accent); word-break: break-word; }
.ref-item a:hover { text-decoration: underline; }

/* End mark */
.essay-end-mark {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.5rem;
    color: var(--accent);
    font-style: italic;
    margin-bottom: 32px;
}

/* Author bio */
.essay-bio {
    display: flex;
    gap: 18px;
    align-items: flex-start;
    padding: 28px;
    background: #f7f7f5;
    border-radius: 8px;
}

.essay-bio-avatar {
    width: 48px; height: 48px;
    border-radius: 50%;
    background: linear-gradient(160deg, var(--accent), #a5b4fc);
    flex-shrink: 0;
}

.essay-bio-text {
    font-size: 0.88rem;
    line-height: 1.65;
    color: var(--text-muted);
}

.essay-bio-text strong { color: var(--text); font-weight: 600; }

/* Bottom navigation */
.essay-back-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    transition: color 0.2s;
}
.essay-back-link:hover { color: var(--text); }

.essay-next {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    max-width: 300px;
    text-decoration: none;
    color: inherit;
}

.essay-next-label {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.essay-next-title {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.1rem;
    font-weight: 400;
    color: var(--text);
    text-align: right;
    line-height: 1.2;
    transition: color 0.2s;
}

.essay-next:hover .essay-next-title { color: var(--accent); }

/* Audio player bar */
.essay-player-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 1 50%;
    min-width: 0;
}

.essay-player-playpause {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1.5px solid currentColor;
    background: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text);
    flex-shrink: 0;
    padding: 0;
}

.essay-player-time {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 32px;
}

.essay-player-scrubber {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 3px;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    min-width: 0;
}

.essay-player-scrubber::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--text);
    cursor: pointer;
}

.essay-player-scrubber::-moz-range-thumb {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--text);
    border: none;
    cursor: pointer;
}

/* Essay images */
.essay-img {
    width: 100%;
    border-radius: 6px;
    margin: 32px 0;
    display: block;
}

.essay-img-caption {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--text-muted);
    letter-spacing: 0.04em;
    margin-top: -20px;
    margin-bottom: 32px;
}

/* Essay table */
.essay-table-wrap {
    overflow-x: auto;
    margin: 36px 0;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.essay-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    line-height: 1.55;
}

.essay-table th {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    background: var(--bg-secondary);
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.essay-table td {
    padding: 14px 16px;
    vertical-align: top;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.essay-table tbody tr:last-child td {
    border-bottom: none;
}

.essay-table td:first-child {
    white-space: nowrap;
}

/* Responsive */
@media (max-width: 768px) {
    .essay-header,
    .essay-body-wrap,
    .essay-refs,
    .essay-end,
    .essay-foot-nav { padding-left: 24px; padding-right: 24px; }

    .essay-header { padding-top: 100px; }

    .essay-body p,
    .essay-body ul li { font-size: 1rem; }

    .essay-body p:first-of-type { font-size: 1.05rem; }

    .essay-body blockquote { font-size: 1.15rem; }

    .essay-foot-nav { flex-direction: column; align-items: flex-start; }

    .essay-next { align-items: flex-start; }
    .essay-next-title { text-align: left; }
}
