/* ═══════════════════════════════════════════════════════════════════════════
   UNDER-THE-DOOR NOTES
   Things slipped beneath the gap. Each character has a hand.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── OVERLAY ─────────────────────────────────────────────────────────────── */

.note-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    pointer-events: none;
    transition: background 0.4s ease;
}

.note-overlay.active {
    pointer-events: auto;
}

.note-overlay.note-picked-up {
    background: rgba(5, 4, 3, 0.85);
    align-items: center;
}

/* ─── NOTE FRAMING ────────────────────────────────────────────────────────── */

.note-framing {
    position: absolute;
    top: 30%;
    left: 50%;
    transform: translateX(-50%);
    max-width: 420px;
    text-align: center;
    opacity: 0;
    transition: opacity 0.8s ease;
    z-index: 2;
    pointer-events: none;
}

.note-framing--visible {
    opacity: 1;
    pointer-events: auto;
}

.note-framing--reading {
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.note-framing-text {
    font-family: 'EB Garamond', serif;
    font-size: 1rem;
    font-style: italic;
    color: rgba(212, 197, 169, 0.6);
    line-height: 1.7;
    margin: 0 0 16px;
}

.note-framing-dismiss {
    background: none;
    border: 1px solid rgba(212, 197, 169, 0.2);
    color: rgba(212, 197, 169, 0.5);
    font-family: 'EB Garamond', serif;
    font-size: 1.2rem;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.note-framing-dismiss:hover {
    border-color: rgba(212, 197, 169, 0.5);
    color: rgba(212, 197, 169, 0.8);
}

/* ─── BASE NOTE ───────────────────────────────────────────────────────────── */

.note {
    position: relative;
    width: min(380px, 85vw);
    transform: translateY(110%) rotate(var(--note-rotation, 0deg));
    transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1),
                box-shadow 0.4s ease;
    cursor: pointer;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.4));
    -webkit-tap-highlight-color: transparent;
}

.note.note--sliding-in {
    transform: translateY(-20px) rotate(var(--note-rotation, 0deg));
}

.note.note--picked-up {
    transform: translateY(0) rotate(0deg) scale(1.05);
    filter: drop-shadow(0 12px 40px rgba(0,0,0,0.6));
    z-index: 10;
}

.note.note--dismissing {
    animation: noteDismiss 0.4s ease-in forwards;
}

@keyframes noteDismiss {
    0% { transform: translateY(0) rotate(0deg) scale(1.05); opacity: 1; }
    100% { transform: translateY(60px) rotate(3deg) scale(0.95); opacity: 0; }
}

/* Paper sliding sound cue — subtle bounce at arrival */
@keyframes noteSlideIn {
    0% { transform: translateY(110%) rotate(var(--note-rotation, 0deg)); }
    70% { transform: translateY(-30px) rotate(var(--note-rotation, 0deg)); }
    85% { transform: translateY(-15px) rotate(var(--note-rotation, 0deg)); }
    100% { transform: translateY(-20px) rotate(var(--note-rotation, 0deg)); }
}

.note.note--sliding-in {
    animation: noteSlideIn 0.8s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* ─── NOTE PAPER ──────────────────────────────────────────────────────────── */

.note-paper {
    position: relative;
    padding: 28px 24px;
    min-height: 200px;
    border-radius: 2px;
    overflow: hidden;
    font-family: var(--note-font, 'Homemade Apple', cursive);
    color: var(--note-ink, #1a1a2e);
    font-size: 14px;
    line-height: 1.8;
}

/* ─── PAPER TYPES ─────────────────────────────────────────────────────────── */

/* Graph paper — Milton */
.note-paper--graph {
    background-color: #f5f3ec;
    background-image:
        linear-gradient(rgba(74, 144, 226, 0.12) 1px, transparent 1px),
        linear-gradient(90deg, rgba(74, 144, 226, 0.12) 1px, transparent 1px);
    background-size: 18px 18px;
    padding-left: 42px;
    border-left: 2px solid rgba(210, 60, 60, 0.25);
}

/* Yellow legal pad — Caleb */
.note-paper--legal {
    background-color: #fdf5c8;
    background-image:
        linear-gradient(rgba(74, 100, 180, 0.18) 1px, transparent 1px);
    background-size: 100% 26px;
    background-position: 0 24px;
    padding-left: 48px;
    border-left: 3px solid rgba(210, 60, 60, 0.3);
}

.note-paper--legal::before {
    content: '';
    position: absolute;
    left: 38px;
    top: 0;
    bottom: 0;
    width: 1px;
    background: rgba(210, 60, 60, 0.15);
}

/* Cream stationery — Dotty */
.note-paper--cream {
    background-color: #f5efe6;
    border: 1px solid #d4c5a9;
    padding: 32px 28px;
}

.note-paper--cream::before {
    content: '';
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 1px;
    background: linear-gradient(90deg, transparent, #c9a278, transparent);
}

/* Theatre programme — Rufus */
.note-paper--programme {
    background-color: #f2ece0;
    border: 2px solid #8b7355;
    padding: 24px;
}

.note-paper--programme::before {
    content: '';
    position: absolute;
    inset: 6px;
    border: 1px solid rgba(139, 115, 85, 0.3);
    pointer-events: none;
}

/* Racing form — Wire */
.note-paper--racing {
    background-color: #faf6ef;
    padding: 24px 20px;
}

.note-paper--racing::before {
    content: '';
    position: absolute;
    bottom: 30px;
    left: 20px;
    right: 20px;
    height: 1px;
    background: #999;
}

/* Torn notebook — Marisol */
.note-paper--notebook {
    background-color: #fff;
    border-left: none;
    padding: 20px 24px 20px 20px;
    clip-path: polygon(
        0% 0%, 2% 3%, 0% 6%, 1% 9%, 0% 12%, 2% 15%,
        0% 18%, 1% 100%, 100% 100%, 100% 0%
    );
}

.note-paper--notebook::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px, transparent 4px,
        #ddd 4px, #ddd 6px
    );
}

/* Hotel stationery — Solomon, Anonymous */
.note-paper--hotel {
    background-color: #faf8f3;
    border: 1px solid #d8d0c0;
    padding: 36px 28px 28px;
}

.note-paper--hotel .note-hotel-crest {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Cinzel', serif;
    font-size: 8px;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: rgba(139, 115, 85, 0.4);
}

/* Cocktail napkin — Priya */
.note-paper--napkin {
    background-color: #fff;
    border-radius: 4px;
    padding: 24px;
    width: min(280px, 70vw);
}

.note-paper--napkin::before {
    content: '';
    position: absolute;
    inset: 8px;
    border: 1px solid rgba(0,0,0,0.05);
    border-radius: 2px;
}

/* Nightclub napkin — Tane */
.note-paper--flyer {
    background-color: #1a1a1a;
    color: #f0e8d8;
    padding: 24px;
    border-radius: 0;
}

/* Heavy card stock — Constance */
.note-paper--cardstock {
    background-color: #f8f5ee;
    border: none;
    padding: 32px 28px;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.06);
}

/* Typewriter — Vance */
.note-paper--typewriter {
    background-color: #f0e8d4;
    padding: 28px 24px;
}

.note-paper--typewriter .note-content {
    position: relative;
}

.note-paper--typewriter .note-content::after {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent 0px,
        transparent 22px,
        rgba(0,0,0,0.03) 22px,
        rgba(0,0,0,0.03) 23px
    );
    pointer-events: none;
}

/* ─── CONTENT STYLING ─────────────────────────────────────────────────────── */

.note-content {
    position: relative;
    z-index: 1;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.note-content .crossed-out {
    text-decoration: line-through;
    text-decoration-color: var(--note-ink, #1a1a2e);
    opacity: 0.6;
}

.note-content .rewritten {
    position: relative;
    display: inline;
}

.note-content .rewritten::before {
    content: attr(data-original);
    position: absolute;
    top: -1.4em;
    left: 0;
    text-decoration: line-through;
    opacity: 0.35;
    font-size: 0.85em;
    white-space: nowrap;
}

.note-content .redacted {
    background: var(--note-ink, #1a1a2e);
    color: transparent;
    padding: 0 4px;
    border-radius: 1px;
    user-select: none;
}

.note-content .margin-note {
    position: absolute;
    right: -8px;
    font-size: 0.75em;
    color: rgba(210, 60, 60, 0.7);
    transform: rotate(-2deg);
    white-space: nowrap;
}

/* Caleb's obsessive annotations */
.note--caleb .note-content .see-also {
    display: block;
    margin-top: 8px;
    font-size: 0.8em;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.7;
}

.note--caleb .note-content .circled {
    border: 1.5px solid var(--note-ink);
    border-radius: 50%;
    padding: 0 4px;
    display: inline-block;
}

/* Dotty's lipstick kiss */
.note-svg--kiss {
    position: absolute;
    bottom: 16px;
    right: 20px;
    width: 36px;
    height: 30px;
    opacity: 0.6;
}

/* Priya's glass ring */
.note-svg--glass-ring {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 70px;
    height: 70px;
    opacity: 0.12;
}

/* Constance's pressed flower */
.note-svg--flower {
    position: absolute;
    bottom: 20px;
    left: 24px;
    width: 50px;
    height: 60px;
    opacity: 0.25;
}

/* Milton's contraption diagrams */
.note-svg--contraption {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 140px;
    height: 100px;
    opacity: 0.2;
}

/* Rufus signature flourish */
.note-signature {
    display: block;
    margin-top: 16px;
    font-size: 1.3em;
    text-align: right;
    font-style: italic;
}

/* Vance glitch/static */
.note--vance .note-paper {
    animation: vanceGlitch 4s infinite;
}

@keyframes vanceGlitch {
    0%, 94%, 100% { filter: none; }
    95% { filter: blur(1px) brightness(1.1); transform: translateX(1px); }
    96% { filter: none; transform: translateX(-1px); }
    97% { filter: blur(0.5px); transform: translateX(0); }
}

/* ─── NOTE VIEWER (collected notes in chapters modal) ─────────────────────── */

.chapters-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(212, 197, 169, 0.2);
}

.chapters-tab {
    background: none;
    border: none;
    color: var(--parchment-dark);
    font-family: 'Cinzel', serif;
    font-size: 0.85rem;
    padding: 8px 16px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
    position: relative;
}

.chapters-tab:hover {
    color: var(--parchment);
}

.chapters-tab.active {
    color: var(--brass-highlight);
    border-bottom-color: var(--brass-highlight);
}

.chapters-tab .tab-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    background: var(--blood-fresh);
    border-radius: 50%;
}

/* Notes list */
.notes-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 4px;
}

.notes-list::-webkit-scrollbar { width: 4px; }
.notes-list::-webkit-scrollbar-thumb { background: rgba(212, 197, 169, 0.3); border-radius: 2px; }

.note-card {
    background: rgba(30, 24, 18, 0.6);
    border: 1px solid rgba(212, 197, 169, 0.1);
    border-radius: 4px;
    padding: 14px 16px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.note-card:hover {
    background: rgba(40, 32, 24, 0.8);
    border-color: rgba(212, 197, 169, 0.2);
}

.note-card.unread {
    border-left: 3px solid var(--brass-highlight);
}

.note-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.note-card-from {
    font-family: 'Cinzel', serif;
    font-size: 0.8rem;
    color: var(--parchment);
    letter-spacing: 1px;
}

.note-card-date {
    font-size: 0.7rem;
    color: var(--parchment-dark);
}

.note-card-preview {
    font-family: 'EB Garamond', serif;
    font-size: 0.85rem;
    color: var(--parchment-dark);
    line-height: 1.5;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Empty notes state */
.notes-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--parchment-dark);
    font-family: 'EB Garamond', serif;
    font-style: italic;
}

/* ─── COMMENCE MODE — WAITING STATE ───────────────────────────────────────── */

.commence-waiting {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    z-index: var(--z-ui);
    pointer-events: none;
}

.commence-waiting-text {
    font-family: 'EB Garamond', serif;
    font-size: 0.9rem;
    color: rgba(212, 197, 169, 0.4);
    font-style: italic;
    animation: commenceBreath 4s ease-in-out infinite;
}

@keyframes commenceBreath {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.6; }
}

/* Knock indicator — shadow under the door */
.knock-indicator {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 40px;
    background: radial-gradient(ellipse, rgba(0,0,0,0.4) 0%, transparent 70%);
    opacity: 0;
    z-index: var(--z-ui);
    transition: opacity 0.3s;
}

.knock-indicator.active {
    opacity: 1;
    animation: knockPulse 1.5s ease-in-out 2;
}

@keyframes knockPulse {
    0%, 100% { transform: translateX(-50%) scaleX(1); }
    50% { transform: translateX(-50%) scaleX(1.15); }
}

/* Answer prompt during knock */
.knock-prompt {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    z-index: var(--z-ui);
    display: flex;
    gap: 16px;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.knock-prompt.visible {
    opacity: 1;
}

.knock-prompt button {
    font-family: 'Cinzel', serif;
    font-size: 0.8rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    padding: 10px 24px;
    border: 1px solid rgba(212, 197, 169, 0.3);
    background: rgba(10, 8, 6, 0.7);
    color: var(--parchment);
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    backdrop-filter: blur(4px);
}

.knock-prompt button:hover {
    background: rgba(20, 16, 12, 0.9);
    border-color: var(--brass-highlight);
}

.knock-prompt .knock-answer {
    border-color: var(--brass-mid);
}

/* Commence button on landing page */
.commence-btn {
    font-family: 'Cinzel', serif;
    font-size: 0.75rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    padding: 12px 32px;
    border: 1px solid rgba(212, 197, 169, 0.25);
    background: rgba(10, 8, 6, 0.5);
    color: var(--parchment);
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 12px;
    backdrop-filter: blur(4px);
}

.commence-btn:hover {
    background: rgba(20, 16, 12, 0.7);
    border-color: var(--brass-highlight);
    letter-spacing: 4px;
}

/* ─── PRE-COMMENCE RITUAL ─────────────────────────────────────────────────── */

.ritual-content {
    max-width: 420px;
    text-align: center;
    padding: 36px 28px;
}

.ritual-header h2 {
    font-family: 'Cinzel', serif;
    font-size: 1.1rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--parchment);
    margin-bottom: 24px;
}

.ritual-section {
    margin-bottom: 20px;
}

.ritual-prompt {
    font-family: 'EB Garamond', serif;
    font-size: 1rem;
    color: var(--parchment);
    margin-bottom: 8px;
}

.ritual-subtext {
    font-family: 'EB Garamond', serif;
    font-size: 0.85rem;
    color: var(--parchment-dark);
    font-style: italic;
    margin-bottom: 16px;
}

.ritual-suggestion {
    font-family: 'EB Garamond', serif;
    font-size: 1rem;
    color: var(--parchment);
    line-height: 1.6;
    margin-bottom: 20px;
    font-style: italic;
}

.ritual-upload-btn {
    display: inline-block;
    font-family: 'Cinzel', serif;
    font-size: 0.75rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    padding: 10px 24px;
    border: 1px solid rgba(212, 197, 169, 0.3);
    background: rgba(10, 8, 6, 0.5);
    color: var(--parchment);
    cursor: pointer;
    transition: all 0.2s;
}

.ritual-upload-btn:hover {
    border-color: var(--brass-highlight);
    background: rgba(20, 16, 12, 0.7);
}

.ritual-photo-preview {
    margin: 16px auto;
    max-width: 200px;
    border: 1px solid rgba(212, 197, 169, 0.2);
    border-radius: 4px;
    overflow: hidden;
}

.ritual-photo-preview img {
    width: 100%;
    height: auto;
    display: block;
}

.ritual-toggle {
    margin: 16px 0;
}

.ritual-toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: 'EB Garamond', serif;
    font-size: 0.9rem;
    color: var(--parchment-dark);
    cursor: pointer;
}

.ritual-toggle-label input[type="checkbox"] {
    accent-color: var(--brass-highlight);
    width: 16px;
    height: 16px;
}

.ritual-action-btn {
    display: inline-block;
    font-family: 'Cinzel', serif;
    font-size: 0.75rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    padding: 10px 28px;
    border: 1px solid var(--brass-mid);
    background: rgba(10, 8, 6, 0.6);
    color: var(--parchment);
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 12px;
}

.ritual-action-btn:hover {
    background: rgba(20, 16, 12, 0.8);
    border-color: var(--brass-highlight);
}

.ritual-action-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.ritual-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px;
    font-family: 'EB Garamond', serif;
    font-style: italic;
    color: var(--parchment-dark);
}

.ritual-recommendation {
    margin-top: 20px;
}

.ritual-recommendation .note {
    transform: rotate(var(--note-rotation, 0deg));
    margin: 0 auto 16px;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.4));
}

.ritual-skip-btn {
    display: block;
    width: 100%;
    background: none;
    border: none;
    font-family: 'EB Garamond', serif;
    font-size: 0.85rem;
    color: var(--parchment-dark);
    cursor: pointer;
    padding: 16px;
    margin-top: 8px;
    transition: color 0.2s;
    font-style: italic;
}

.ritual-skip-btn:hover {
    color: var(--parchment);
}

/* ─── RESPONSIVE ──────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
    .note {
        width: 90vw;
    }
    .note-paper {
        font-size: 13px;
        padding: 22px 18px;
    }
    .note-paper--graph { padding-left: 36px; }
    .note-paper--legal { padding-left: 40px; }
}

@media (prefers-reduced-motion: reduce) {
    .note { transition: none; }
    .note.note--sliding-in { animation: none; transform: translateY(-20px) rotate(var(--note-rotation, 0deg)); }
    .note--vance .note-paper { animation: none; }
    .commence-waiting-text { animation: none; opacity: 0.5; }
}
