/* ═══════════════════════════════════════════════════════
   THE MAIN PHRASE OF THE INTERNET — Digital Monument
   ═══════════════════════════════════════════════════════ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg:        #0d0d0d;
    --bg-card:   #141414;
    --text:      #eaeaea;
    --text-dim:  #666;
    --gold:      #f5c518;
    --border:    #222;
}

html {
    font-size: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
        'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 2rem 1.5rem 3rem;
    line-height: 1.5;
}

.container {
    max-width: 720px;
    width: 100%;
    position: relative;
}

/* ═══════════════════════════════════════════════════════
   BACKGROUND NUMBER
   ═══════════════════════════════════════════════════════ */

.background-number {
    position: fixed;
    right: -60px;
    top: -40px;
    font-size: clamp(180px, 30vw, 360px);
    font-weight: 900;
    color: rgba(255, 255, 255, 0.025);
    line-height: 1;
    pointer-events: none;
    user-select: none;
    z-index: 0;
    letter-spacing: -0.04em;
}

/* ═══════════════════════════════════════════════════════
   HEADER (smaller)
   ═══════════════════════════════════════════════════════ */

.header {
    position: relative;
    z-index: 1;
    margin-bottom: 0.5rem;
    text-align: center;
}

.title {
    font-size: clamp(18px, 3vw, 26px);
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: 0.02em;
    color: var(--text-dim);
    margin-bottom: 0.5rem;
}

.context {
    font-size: 13px;
    color: #444;
    line-height: 1.6;
}

.context .context-br {
    display: none;
}

@media (max-width: 480px) {
    .context .context-br {
        display: inline;
    }
}

/* ═══════════════════════════════════════════════════════
   PHRASE AREA (main visual object)
   ═══════════════════════════════════════════════════════ */

.phrase-area {
    position: relative;
    z-index: 1;
    text-align: center;
    margin-bottom: 2rem;
    padding: 2.5rem 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.phrase-label {
    font-size: 10px;
    font-weight: 600;
    color: #555;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 0.75rem;
}

.phrase-number {
    font-size: 13px;
    font-weight: 600;
    color: var(--gold);
    letter-spacing: 0.04em;
    margin-bottom: 1rem;
}

.phrase-remaining {
    font-size: 12px;
    color: #555;
    margin-bottom: 1.5rem;
    min-height: 1.2em;
}

.phrase-text {
    font-size: clamp(48px, 10vw, 96px);
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.03em;
    word-break: break-word;
    margin-bottom: 1.5rem;
    color: var(--text);
}

.phrase-text .placeholder {
    color: var(--text-dim);
    font-weight: 400;
    font-size: clamp(24px, 4vw, 36px);
    font-style: italic;
    letter-spacing: 0;
}

.phrase-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.35rem 0.4rem;
    font-size: 14px;
    color: var(--text-dim);
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.meta-author {
    color: var(--gold);
    font-weight: 600;
}

.meta-sep {
    color: #333;
}

.meta-price {
    font-weight: 700;
    color: var(--gold);
    font-variant-numeric: tabular-nums;
}

/* ─── Replace button ─── */

.replace-btn {
    display: inline-block;
    padding: 0.85rem 2rem;
    background: transparent;
    border: 1px solid var(--text-dim);
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease;
    border-radius: 0;
}

.replace-btn:hover {
    border-color: var(--gold);
    color: var(--gold);
}

.replace-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    border-color: var(--text-dim);
    color: var(--text-dim);
}

/* ═══════════════════════════════════════════════════════
   ACTION AREA (form, shown after clicking replace)
   ═══════════════════════════════════════════════════════ */

.action-area {
    position: relative;
    z-index: 1;
    margin-bottom: 1.5rem;
}

.price-note {
    text-align: center;
    font-size: 14px;
    color: var(--text-dim);
    margin-bottom: 0.75rem;
}

.price-note strong {
    color: var(--gold);
}

.price-rule-sub {
    font-size: 12px;
    color: #444;
}

.phrase-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.form-fields {
    display: flex;
    gap: 0.75rem;
}

.field {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.field label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
}

.field input {
    width: 100%;
    padding: 0.65rem 0.8rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s ease;
    border-radius: 0;
}

.field input:focus {
    border-color: var(--gold);
}

.field input::placeholder {
    color: #444;
}

#submitBtn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.85rem 1.25rem;
    background: var(--gold);
    color: #0d0d0d;
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: opacity 0.15s ease;
    border-radius: 0;
}

#submitBtn:hover {
    opacity: 0.85;
}

#submitBtn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.btn-text {
    letter-spacing: 0.02em;
}

.btn-price {
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Courier New', monospace;
    font-weight: 700;
    font-size: 16px;
}

.cancel-btn {
    display: block;
    width: 100%;
    padding: 0.5rem;
    background: transparent;
    border: none;
    color: #444;
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    text-align: center;
    transition: color 0.15s ease;
}

.cancel-btn:hover {
    color: var(--text-dim);
}

/* ═══════════════════════════════════════════════════════
   STRIP (share + most shared)
   ═══════════════════════════════════════════════════════ */

.strip {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.share-btn {
    padding: 0.4rem 0.8rem;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease;
    border-radius: 0;
}

.share-btn:hover {
    border-color: var(--gold);
    color: var(--text);
}

.share-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.strip-sep {
    width: 1px;
    height: 20px;
    background: var(--border);
}

.most-shared-ever {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    align-items: baseline;
}

.mse-label {
    font-size: 12px;
    color: #555;
}

.mse-text {
    font-size: 13px;
    font-style: italic;
    color: var(--text-dim);
}

/* ═══════════════════════════════════════════════════════
   STATS
   ═══════════════════════════════════════════════════════ */

.stats-line {
    position: relative;
    z-index: 1;
    text-align: center;
    font-size: 20px;
    color: #888;
    margin-bottom: 0;
    padding: 1rem 0;
    line-height: 1.5;
    border-top: 1px solid var(--border);
}

.stats-line strong {
    color: var(--text);
    font-weight: 800;
}

/* ═══════════════════════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════════════════════ */

.footer {
    position: relative;
    z-index: 1;
    text-align: center;
    font-size: 12px;
    color: #333;
    line-height: 1.8;
    padding-top: 1rem;
}

.footer-link {
    color: #888;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.15s ease;
}

.footer-link:hover {
    color: var(--text);
}

.footer-sep {
    margin: 0 0.3rem;
    color: #333;
}

.footer-text {
    color: #333;
}

/* ═══════════════════════════════════════════════════════
   ARCHIVE PAGE
   ═══════════════════════════════════════════════════════ */

.page-archive {
    padding: 2rem 1.5rem;
}

.archive-header {
    margin-bottom: 1.5rem;
}

.archive-back {
    font-size: 13px;
    color: var(--text-dim);
    text-decoration: none;
    display: inline-block;
    margin-bottom: 0.75rem;
    transition: color 0.15s ease;
}

.archive-back:hover {
    color: var(--text);
}

.archive-title {
    font-size: clamp(24px, 4vw, 36px);
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 0.35rem;
}

.archive-subtitle {
    font-size: 14px;
    color: var(--text-dim);
}

.archive-controls {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.archive-search {
    flex: 1;
    padding: 0.6rem 0.8rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s ease;
    border-radius: 0;
}

.archive-search:focus {
    border-color: var(--gold);
}

.archive-search::placeholder {
    color: #444;
}

.archive-sort {
    padding: 0.6rem 0.8rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    outline: none;
    cursor: pointer;
    border-radius: 0;
    min-width: 150px;
}

.archive-sort:focus {
    border-color: var(--gold);
}

.archive-stats {
    font-size: 12px;
    color: #444;
    margin-bottom: 0.75rem;
}

.archive-stats strong {
    color: var(--text-dim);
}

.archive-list-full {
    margin-bottom: 2rem;
}

.archive-table {
    display: flex;
    flex-direction: column;
    border-top: 1px solid var(--border);
    font-size: 13px;
}

.atr {
    display: grid;
    grid-template-columns: 50px 1fr 110px 80px 90px;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--border);
    transition: background 0.12s ease;
}

.atr-header {
    font-size: 11px;
    font-weight: 700;
    color: #444;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding-top: 0.65rem;
    padding-bottom: 0.55rem;
}

.atr-row {
    cursor: pointer;
}

.atr-row:hover {
    background: #1a1a1a;
}

.col-num {
    font-weight: 800;
    color: var(--gold);
    font-variant-numeric: tabular-nums;
}

.col-phrase {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-style: italic;
    color: var(--text);
}

.col-author {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-dim);
}

.col-lived {
    font-weight: 700;
    color: var(--gold);
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.col-discovered {
    font-weight: 600;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
    text-align: right;
}

/* ═══════════════════════════════════════════════════════
   PHRASE DETAIL MODAL
   ═══════════════════════════════════════════════════════ */

#phraseDetailOverlay {
    position: fixed;
    inset: 0;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

#phraseDetailOverlay[hidden] {
    display: none;
}

.detail-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
}

.detail-modal {
    position: relative;
    max-width: 480px;
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 2rem 2rem 1.5rem;
    text-align: center;
}

.detail-close {
    position: absolute;
    top: 0.5rem;
    right: 0.75rem;
    background: none;
    border: none;
    color: #444;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0.25rem;
    transition: color 0.15s ease;
    font-family: inherit;
}

.detail-close:hover {
    color: var(--text);
}

.detail-number {
    font-size: clamp(60px, 12vw, 100px);
    font-weight: 900;
    color: rgba(245, 197, 24, 0.06);
    line-height: 1;
    margin-bottom: 0.5rem;
    letter-spacing: -0.04em;
}

.detail-phrase {
    font-size: clamp(22px, 4vw, 32px);
    font-weight: 700;
    line-height: 1.2;
    color: var(--text);
    margin-bottom: 0.35rem;
    word-break: break-word;
}

.detail-author {
    font-size: 15px;
    color: var(--gold);
    font-weight: 600;
    margin-bottom: 1rem;
}

.detail-divider {
    height: 1px;
    background: var(--border);
    margin-bottom: 1rem;
}

.detail-metrics {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.dm-lived {
    font-size: 18px;
    font-weight: 700;
    color: var(--gold);
}

.dm-discovered {
    font-size: 14px;
    color: var(--text-dim);
    font-weight: 600;
}

.detail-meta {
    font-size: 12px;
    color: #555;
    line-height: 1.8;
}

.detail-meta strong {
    color: var(--text-dim);
}

/* ═══════════════════════════════════════════════════════
   WITNESSES
   ═══════════════════════════════════════════════════════ */

.detail-witnesses {
    text-align: left;
    margin-top: 0.5rem;
}

.dw-header {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.75rem;
}

.dw-empty {
    font-size: 13px;
    color: #444;
    font-style: italic;
    margin-bottom: 1rem;
}

.dw-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-bottom: 1rem;
    max-height: 240px;
    overflow-y: auto;
}

.dw-item {
    font-size: 13px;
    line-height: 1.5;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border);
}

.dwi-id {
    font-weight: 700;
    color: var(--gold);
    margin-right: 0.4rem;
}

.dwi-text {
    color: var(--text);
}

.dwi-author {
    color: #555;
    font-size: 12px;
    margin-left: 0.3rem;
}

.dw-form {
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.dw-form-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.dw-input {
    flex: 1;
    padding: 0.5rem 0.6rem;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    outline: none;
    border-radius: 0;
}

.dw-input:focus {
    border-color: var(--gold);
}

.dw-price {
    font-size: 13px;
    font-weight: 700;
    color: var(--gold);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.dw-textarea {
    width: 100%;
    padding: 0.5rem 0.6rem;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    outline: none;
    resize: vertical;
    border-radius: 0;
}

.dw-textarea:focus {
    border-color: var(--gold);
}

.dw-submit {
    width: 100%;
    padding: 0.6rem 1rem;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease;
    border-radius: 0;
}

.dw-submit:hover {
    border-color: var(--gold);
    color: var(--gold);
}

.archive-footer {
    text-align: center;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.archive-footer a {
    font-size: 13px;
    color: var(--text-dim);
    text-decoration: none;
    transition: color 0.15s ease;
}

.archive-footer a:hover {
    color: var(--text);
}

/* ═══════════════════════════════════════════════════════
   FREEZE OVERLAY
   ═══════════════════════════════════════════════════════ */

#freezeOverlay {
    position: fixed;
    inset: 0;
    z-index: 999;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    backdrop-filter: blur(4px);
}

#freezeOverlay[hidden] {
    display: none;
}

.freeze-inner {
    max-width: 520px;
    width: 100%;
    text-align: center;
}

.freeze-number {
    font-size: clamp(80px, 15vw, 140px);
    font-weight: 900;
    color: rgba(245, 197, 24, 0.06);
    line-height: 1;
    margin-bottom: 0.5rem;
    letter-spacing: -0.04em;
}

.freeze-inner h1 {
    font-size: clamp(22px, 4vw, 32px);
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
}

.freeze-status {
    font-size: 13px;
    font-weight: 600;
    color: var(--gold);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 2rem;
}

.freeze-phrase {
    padding: 1.5rem 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

.freeze-word {
    font-size: clamp(24px, 4vw, 40px);
    font-weight: 700;
    font-style: italic;
    line-height: 1.3;
    margin-bottom: 0.5rem;
}

.freeze-author {
    font-size: 15px;
    color: var(--gold);
    font-weight: 600;
}

.freeze-badge {
    display: inline-block;
    background: var(--gold);
    color: #0d0d0d;
    font-size: 12px;
    font-weight: 700;
    padding: 0.5rem 1.25rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 1rem;
}

.freeze-note {
    font-size: 14px;
    color: #555;
    line-height: 1.5;
}

/* ═══════════════════════════════════════════════════════
   STRIPE LOADING OVERLAY
   ═══════════════════════════════════════════════════════ */

#stripeLoading {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    backdrop-filter: blur(4px);
}

#stripeLoading[hidden] {
    display: none;
}

.stripe-loading-inner {
    max-width: 400px;
    width: 100%;
    text-align: center;
}

.stripe-loading-spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 1.5rem;
    border: 2px solid var(--border);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: stripe-spin 0.8s linear infinite;
}

@keyframes stripe-spin {
    to { transform: rotate(360deg); }
}

.stripe-loading-text {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.stripe-loading-sub {
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.5;
}

/* ═══════════════════════════════════════════════════════
   PAYMENT BUTTON STATES
   ═══════════════════════════════════════════════════════ */

#submitBtn.loading {
    opacity: 0.7;
    cursor: wait;
}

#submitBtn.loading .btn-text {
    font-size: 13px;
}

/* ═══════════════════════════════════════════════════════
   TOAST
   ═══════════════════════════════════════════════════════ */

.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    font-size: 14px;
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
    z-index: 100;
}

.toast.show {
    opacity: 1;
}

/* ═══════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════ */

@media (max-width: 600px) {
    body {
        padding: 1.5rem 1rem 2rem;
    }

    .form-fields {
        flex-direction: column;
        gap: 0.65rem;
    }

    #submitBtn {
        padding: 0.75rem 1rem;
        font-size: 14px;
    }

    .btn-price {
        font-size: 15px;
    }

    .background-number {
        right: -30px;
        top: -20px;
    }

    .phrase-area {
        padding: 1.5rem 0;
    }

    .phrase-text {
        font-size: clamp(36px, 10vw, 56px);
    }

    .phrase-meta {
        font-size: 13px;
        flex-direction: column;
        gap: 0.15rem;
    }

    .strip {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .strip-sep {
        display: none;
    }

    .archive-controls {
        flex-direction: column;
    }

    .archive-sort {
        min-width: auto;
    }

    .atr {
        grid-template-columns: 40px 1fr 70px 60px;
        padding: 0.5rem 0.4rem;
        gap: 0.3rem;
        font-size: 12px;
    }

    .atr .col-author {
        display: none;
    }

    .atr-header .col-author {
        display: none;
    }

}
