/* ============================================================
   Home + matchmaking: sticky notes on ruled paper
   ============================================================ */
#main-menu-screen.active {
    display: flex;
    flex-direction: column;
    gap: 30px;
    padding: 24px 24px calc(var(--drawer-peek) + 28px + var(--safe-bottom)) 34px;
}
body.drawer-open { overflow: hidden; }

/* Mode cards become stuck-on notes */
.mode-list { display: flex; flex-direction: column; gap: 26px; padding-top: 10px; }
.mode-card {
    --tilt: -1.5deg;
    position: relative;
    display: block;
    min-height: 88px;
    padding: 16px 18px 18px;
    text-align: left;
    color: var(--ink);
    background: var(--sticky-yellow);
    box-shadow: var(--shadow-note);
    transform: rotate(var(--tilt));
    animation: stickOn 0.5s var(--ease-spring) both;
    transition: transform var(--dur-fast) var(--ease-smooth), box-shadow var(--dur-fast) var(--ease-smooth);
}
.mode-card::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 50%;
    width: 74px;
    height: 22px;
    margin-left: -37px;
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(0, 0, 0, 0.08);
    transform: rotate(-3deg);
}
.mode-card:nth-child(1) { animation-delay: 0.05s; }
.mode-card:nth-child(2) { --tilt: 1.2deg; margin-left: 24px; background: var(--sticky-pink); animation-delay: 0.15s; }
.mode-card:nth-child(2)::before { transform: rotate(4deg); }
.mode-card:nth-child(3) { --tilt: -0.8deg; margin-right: 20px; background: var(--sticky-blue); animation-delay: 0.25s; }
.mode-card:nth-child(3)::before { transform: rotate(-6deg); }
.mode-card:hover { transform: rotate(0) translateY(-2px); box-shadow: var(--shadow-note-lg); }
.mode-card:active { transform: rotate(var(--tilt)) scale(0.985); box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.15); }
.mode-card.selected { outline: 2.5px solid var(--pen-red); outline-offset: 4px; border-radius: 2px; }
.mode-card-icon, .mode-card-chev { display: none; }
.mode-card-text { display: flex; flex-direction: column; gap: 6px; }
.mode-name { font-family: var(--font-hand); font-weight: 700; font-size: 1.9rem; line-height: 1; }
.mode-desc { font-size: 1.05rem; line-height: 1.25; color: #3A3A3A; }

/* "got a note? write the code here" */
.join-game-section { padding-left: 26px; }
.join-game-section .section-title { font-size: 1.25rem; color: #3A3A3A; }
.join-row { display: flex; align-items: flex-end; gap: 12px; }
.join-row input {
    flex: 1;
    min-width: 0;
    min-height: var(--tap);
    padding: 0 4px;
    border: none;
    border-bottom: 2px solid var(--ink);
    background: transparent;
    font-family: var(--font-hand);
    font-size: 26px;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-me);
}
.join-row input:focus { outline: none; border-bottom-color: var(--ink-me); }
.join-row input::placeholder { letter-spacing: 0.02em; text-transform: none; font-weight: 500; color: var(--ink-3); }
.join-row .btn { border-radius: var(--sketch-oval); border-color: var(--ink-me); color: var(--ink-me); background: transparent; box-shadow: none; font-family: var(--font-hand); font-weight: 700; font-size: 1.4rem; }
.join-row .btn:active { background: rgba(31, 58, 147, 0.08); transform: scale(0.96); }

/* Word packs: index tabs */
.wordpack-section { padding-left: 26px; }
.pack-scroller { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 8px 4px 12px; margin: 0 -4px; scrollbar-width: none; }
.pack-scroller::-webkit-scrollbar { display: none; }
.wordpack-card {
    flex: 0 0 150px;
    scroll-snap-align: start;
    position: relative;
    padding: 12px 14px;
    background: var(--paper-2);
    box-shadow: var(--shadow-note);
    text-align: left;
    color: var(--ink);
    transform: rotate(-1deg);
}
.wordpack-card:nth-child(even) { transform: rotate(1.2deg); background: var(--sticky-green); }
.wordpack-card.selected { outline: 2.5px solid var(--pen-red); outline-offset: 3px; }
.wordpack-card.locked { opacity: 0.7; }
.wordpack-name { font-family: var(--font-hand); font-weight: 700; font-size: 1.4rem; line-height: 1; margin-bottom: 4px; }
.wordpack-desc { font-size: 0.95rem; color: var(--ink-2); line-height: 1.25; margin-bottom: 8px; min-height: 2.5em; }
.wordpack-meta { display: flex; justify-content: space-between; align-items: center; font-size: 0.9rem; color: var(--ink-3); }
.wordpack-price { font-family: var(--font-hand); font-weight: 700; font-size: 1.1rem; color: var(--pen-red); }
.wordpack-price.owned { color: var(--ink-2); }
.wordpack-lock { position: absolute; top: 6px; right: 8px; font-size: 0.8rem; opacity: 0.6; }

/* Sign your name */
.auth-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-start; gap: 8px 12px; padding: 14px 0 0; font-size: 1.05rem; color: var(--ink-2); }
.page-turn { display: none; }
.leaf + .leaf { margin-top: 18px; }
#auth-signed-in { display: flex; align-items: center; gap: 10px; }
.auth-avatar { width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid var(--ink); }
.auth-name { font-family: var(--font-hand); font-weight: 700; font-size: 1.3rem; color: var(--ink-me); }
.google-sign-in-btn { font-family: var(--font-hand); font-weight: 700; font-size: 1.3rem; color: var(--ink-me); text-decoration: underline; text-decoration-style: wavy; text-underline-offset: 4px; }
.auth-logout-btn { color: var(--ink-2); text-decoration: underline; font-size: 0.95rem; min-height: 32px; }

/* The drawer: a folded sheet tucked under the bottom edge. Pulling it up
   reveals the crawlable "about" copy. */
:root { --drawer-peek: 56px; }
.app:not(.screen-main-menu) .drawer,
.app:not(.screen-main-menu) .drawer-scrim { display: none !important; }
.drawer {
    position: fixed;
    left: 50%;
    bottom: 0;
    width: min(100%, var(--content-max));
    height: min(calc(100dvh - 96px - var(--safe-top)), 780px);
    display: flex;
    flex-direction: column;
    background: var(--paper-2);
    background-image: repeating-linear-gradient(180deg, transparent 0 31px, var(--rule) 31px 32px);
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.18);
    transform: translate(-50%, calc(100% - var(--drawer-peek) - var(--safe-bottom)));
    transition: transform 0.5s var(--ease-spring);
    z-index: 45;
}
.drawer.open { transform: translate(-50%, 0); }
.drawer::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 50%;
    width: 84px;
    height: 24px;
    margin-left: -42px;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.08);
    transform: rotate(-2deg);
    pointer-events: none;
}
.drawer-handle {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    min-height: var(--drawer-peek);
    padding: 8px 16px 6px;
    font-family: var(--font-hand);
    font-weight: 700;
    font-size: 1.3rem;
    color: var(--ink-me);
}
.drawer-grip { width: 44px; height: 4px; border-radius: 2px; background: var(--pencil); }
.drawer:not(.open) .drawer-grip { animation: drawerNudge 3s ease-in-out 2s 2; }
.drawer.open .drawer-tab-text::after { content: ' ↓'; }
.drawer-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 24px calc(28px + var(--safe-bottom)) 34px;
}
.drawer-scrim { position: fixed; inset: 0; background: rgba(60, 50, 30, 0.25); z-index: 44; }
@keyframes drawerNudge { 0%, 100% { transform: translateY(0); } 12% { transform: translateY(-6px); } 24% { transform: translateY(0); } }

/* Crawlable copy as the back of the page */
.seo-content { padding: 12px 0 0 0; color: var(--ink-2); font-size: 1.05rem; line-height: 1.45; }
.seo-content h2 { font-size: 1.6rem; color: var(--ink); margin-bottom: 8px; }
.seo-content h2 + p { margin-bottom: 18px; }
.seo-modes { display: grid; gap: 14px; margin-bottom: 18px; }
.seo-mode { padding: 12px 14px; background: var(--paper-2); box-shadow: var(--shadow-note); transform: rotate(-0.6deg); }
.seo-mode:nth-child(2) { transform: rotate(0.8deg); }
.seo-mode h3 { font-size: 1.3rem; color: var(--ink); margin-bottom: 4px; }
.seo-mode p { font-size: 1rem; color: var(--ink-2); }
.faq-item { padding: 8px 0 10px; border-bottom: 1px dashed var(--pencil); }
.faq-item h3 { font-size: 1.25rem; color: var(--ink); margin-bottom: 4px; }
.faq-item p { font-size: 1rem; }
.seo-links { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 18px; font-family: var(--font-hand); font-weight: 700; font-size: 1.25rem; }
.seo-links a { color: var(--ink-me); text-decoration: none; }
.seo-links a:hover { text-decoration: underline wavy; }

/* Matchmaking: a paper plane looking for a pen pal */
#matchmaking-screen.active { display: flex; flex: 1; align-items: center; justify-content: center; padding: var(--gutter); }
.matchmaking-content { display: flex; flex-direction: column; align-items: center; gap: 18px; text-align: center; }
.matchmaking-spinner {
    width: 84px;
    height: 84px;
    border-radius: 50%;
    border: 2.5px dashed var(--ink-me);
    animation: spin 6s linear infinite;
}
.matchmaking-title { font-size: 2rem; color: var(--ink-me); transform: rotate(-2deg); }
.matchmaking-subtitle { color: var(--ink-2); font-size: 1.15rem; }
.matchmaking-content.found .matchmaking-spinner { border-style: solid; border-color: var(--pen-red); animation: stickOn 0.5s var(--ease-spring); }
.matchmaking-content.found .matchmaking-title { color: var(--pen-red); }

@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 600px) {
    .seo-modes { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 1024px) {
    #main-menu-screen.active { padding: 6px 30px 40px 60px; gap: 24px; }
    .mode-list { gap: 24px; }
    .app.screen-main-menu .intro { max-width: 40ch; }
    /* The drawer is the right page: no tab, no scrim, no transform, no scrolling */
    .drawer { position: static; width: auto; height: 100%; margin: 0; transform: none; transition: none; box-shadow: none; background: transparent; }
    .drawer.open { transform: none; }
    .drawer::before, .drawer-handle, .drawer-scrim { display: none !important; }
    .drawer-body { display: flex; flex-direction: column; height: 100%; overflow: hidden; padding: 0; }
    .seo-content { display: flex; flex-direction: column; flex: 1; min-height: 0; padding: 0; border: none; }
    /* Leaves: one page of the notebook at a time */
    .leaves { position: relative; flex: 1; min-height: 0; perspective: 1800px; perspective-origin: left center; }
    .leaf { position: absolute; inset: 0; padding: 56px 52px 20px 48px; overflow: hidden; display: none; transform-origin: left center; backface-visibility: hidden; background-color: var(--paper); background-image: repeating-linear-gradient(180deg, transparent 0 31px, var(--rule) 31px 32px); }
    .leaf.turning-out, .leaf.turning-in { box-shadow: 10px 0 24px rgba(0, 0, 0, 0.18); }
    .leaf.active { display: block; }
    .leaf.turning-out { display: block; z-index: 2; animation: leafOut 0.6s cubic-bezier(0.4, 0, 0.7, 0.2) both; }
    .leaf.turning-in { display: block; z-index: 2; animation: leafIn 0.6s cubic-bezier(0.2, 0.8, 0.4, 1) both; }
    .leaf.turning-out::after, .leaf.turning-in::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(0,0,0,0.18), transparent 30%); pointer-events: none; }
    .leaf + .leaf { margin-top: 0; }
    .leaf h2:first-child { margin-top: 0; }
    /* page-turn controls */
    .page-turn { display: flex; align-items: flex-end; justify-content: space-between; padding: 0 24px 0 40px; font-family: var(--font-hand); font-weight: 700; color: var(--ink-3); }
    .page-turn-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; font-family: var(--font-hand); font-weight: 700; font-size: 1.15rem; color: var(--ink-me); }
    .page-turn-btn:disabled { opacity: 0.3; }
    .page-num { font-size: 1rem; padding-bottom: 8px; }
    .dog-ear { width: 22px; height: 22px; background: linear-gradient(225deg, var(--paper-3) 50%, transparent 50%); border-left: 1px solid rgba(0,0,0,0.12); border-top: 1px solid rgba(0,0,0,0.12); transform: rotate(180deg); box-shadow: -1px -1px 3px rgba(0,0,0,0.12); }
    .page-turn-btn.next:hover .dog-ear { width: 30px; height: 30px; }
    .page-foot { display: flex; flex-direction: column; gap: 10px; padding: 12px 0 26px; border-top: 2px dashed var(--pencil); margin: 6px 44px 0 48px; }
    .page-foot .seo-links { display: flex; justify-content: space-between; gap: 12px; margin: 0; padding: 0; font-size: 1.1rem; white-space: nowrap; }
    .page-foot .seo-links a { flex: 0 1 auto; }
    .page-foot .auth-row { display: flex; flex-wrap: nowrap; justify-content: space-between; align-items: center; gap: 12px; padding: 4px 0 0; font-size: 1rem; }
    .page-foot .auth-row span { flex: 1; }
    .page-foot .google-sign-in-btn { white-space: nowrap; }
    .page-turn { display: flex; align-items: center; justify-content: space-between; padding: 0 44px 0 48px; }
    .page-turn-btn .dog-ear { display: none; }
    body.drawer-open { overflow: auto; }
}
@keyframes leafOut { from { transform: rotateY(0); } to { transform: rotateY(-110deg); } }
@keyframes leafIn { from { transform: rotateY(-110deg); } to { transform: rotateY(0); } }
