/* Spaces (round 18, assets/space.js): the Anime/Manga switch, the 18+ "after dark" look, and what the anime notebook keeps to itself. */

/* ---------- The switch ---------- */
/* The brand and the switch share the top bar's first cell; the navigation stays centred on the page. When the start cell
   would reach the nav, space.js (fitBar) steps down html .topbar[data-fit]: 1 drops the words beside the seals, 2 the
   badge, 3 the brand name, and only 4 lets the nav move off-centre into the room that is left. */
.topbar-start { position: relative; z-index: 2; justify-self: start; display: flex; align-items: center; gap: 16px; min-width: 0; }
.space-switch { display: flex; align-items: center; gap: 6px; flex: none; }
@media (min-width: 761px) {
    .topbar.has-space-switch { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); column-gap: 16px; }
    .topbar.has-space-switch > nav { justify-self: center; }
    /* "Anime notebook for tonight" says the wrong thing in the manga space, and the bar needs the room. */
    .topbar.has-space-switch .brand small { display: none; }
    .topbar.has-space-switch[data-fit="1"] .space-type-word,
    .topbar.has-space-switch[data-fit="2"] .space-type-word,
    .topbar.has-space-switch[data-fit="3"] .space-type-word,
    .topbar.has-space-switch[data-fit="4"] .space-type-word { display: none; }
    .topbar.has-space-switch[data-fit="2"] .space-badge,
    .topbar.has-space-switch[data-fit="3"] .space-badge,
    .topbar.has-space-switch[data-fit="4"] .space-badge { display: none; }
    .topbar.has-space-switch[data-fit="3"] .brand > span:not(.brand-mark),
    .topbar.has-space-switch[data-fit="4"] .brand > span:not(.brand-mark) { display: none; }
    .topbar.has-space-switch[data-fit="4"] { grid-template-columns: auto minmax(0, 1fr) auto; }
    .topbar.has-space-switch[data-fit="1"] .space-type-mark,
    .topbar.has-space-switch[data-fit="2"] .space-type-mark,
    .topbar.has-space-switch[data-fit="3"] .space-type-mark,
    .topbar.has-space-switch[data-fit="4"] .space-type-mark { font-size: 15px; }
}
.space-type { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255, 255, 255, .03); }
.space-type button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 34px; min-height: 30px; padding: 0 10px; border: 0; border-radius: 999px; background: none; color: #8d8b84; font: 800 10px/1 Arial, sans-serif; letter-spacing: .1em; text-transform: uppercase; transition: color .2s, background-color .2s; }
.space-type button[aria-pressed="true"] { color: var(--ink); background: var(--paper); }
.space-type button:focus-visible, .space-adult:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.space-type-mark { font-family: "Yu Mincho", "MS Mincho", serif; font-size: 13px; letter-spacing: 0; }
.space-adult { display: inline-flex; align-items: center; gap: 5px; min-height: 38px; padding: 0 11px; border: 1px solid var(--line); border-radius: 999px; background: none; color: #8d8b84; font: 800 10px/1 Arial, sans-serif; letter-spacing: .08em; }
.space-adult span { font-family: "Yu Mincho", "MS Mincho", serif; font-size: 14px; }
.space-adult[aria-pressed="true"] { color: #fff; border-color: transparent; background: linear-gradient(135deg, #ff2e7e, #a32cff); box-shadow: 0 0 18px rgba(255, 46, 126, .45); }
.space-badge { display: inline-block; margin-left: 2px; padding: 4px 7px; border: 1px solid currentColor; border-radius: 3px; color: var(--red); font: 800 9px/1 Arial, sans-serif; letter-spacing: .14em; text-transform: uppercase; }
.space-badge[hidden] { display: none; }

@media (max-width: 760px) {
    .topbar-start { gap: 10px; }
    /* On a phone the seal is the brand: the name gives its room to the switch, the bell and the avatar. */
    .topbar.has-space-switch .brand > span:not(.brand-mark) { display: none; }
    .space-type button { position: relative; min-width: 38px; padding: 0 9px; min-height: 32px; }
    .space-type-word { display: none; }
    .space-type-mark { font-size: 15px; }
    .space-adult { position: relative; min-height: 34px; padding: 0 9px; }
    /* The seals stay small; the finger gets 44 px. The bar is 56 to 68 px tall, and the gaps to the neighbours are
       shared: a seal reaches 6 px outwards, never over the seal beside it. */
    .space-type button::after, .space-adult::after { content: ''; position: absolute; inset: -6px 0; }
    .space-type button:first-child::after { left: -6px; }
    .space-type button:last-child::after { right: -6px; }
    .space-adult::after { inset: -6px -7px -6px -5px; }
    .space-adult b { display: none; }
    .space-badge { display: none; }
}

/* ---------- What belongs to the anime notebook only ---------- */
/* Match, Wrapped, Help me choose, sharing: none of them reads a manga or 18+ notebook, and nothing from an 18+ notebook may
   ever be shared. space.js and app.js keep their requests away too; this only hides the doors. */
html[data-space]:not([data-space="anime"]) [data-anime-only],
html[data-space]:not([data-space="anime"]) .card-share,
html[data-space]:not([data-space="anime"]) [data-ad-share],
html[data-space]:not([data-space="anime"]) [data-share-anime],
html[data-space]:not([data-space="anime"]) .deck-modes,
html[data-space]:not([data-space="anime"]) #emptyShelf,
html[data-space]:not([data-space="anime"]) .sync-row,
html[data-space]:not([data-space="anime"]) #nbCopyTitle,
html[data-space]:not([data-space="anime"]) .nb-quick [data-nb-tab-link="settings"],
html[data-space]:not([data-space="anime"]) .account-connection,
html[data-space]:not([data-space="anime"]) .watch-checkin,
html[data-space]:not([data-space="anime"]) .checkin-cue,
html[data-space]:not([data-space="anime"]) #firstRunResume,
html[data-space]:not([data-space="anime"]) #nbWrapped,
html[data-space]:not([data-space="anime"]) .nb-kicker > span { display: none !important; }

/* ---------- The 18+ hard limits replace the anime Skip chips ---------- */
html:not([data-adult="true"]) [data-space-only="adult"],
html[data-adult="true"] .mood-avoid [data-avoid]:not([data-space-only]) { display: none; }

/* ---------- 18+: who do you want to see ---------- */
.mood-who { margin: 14px 0 4px; }
.mood-who-label { display: block; color: #6e695f; font-size: 7px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.mood-who-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 6px; }
.mood-who-options button { min-height: 36px; padding: 0 6px; border: 1px solid #aaa697; color: var(--ink); background: transparent; font: italic 13px/1.1 Georgia, serif; }
.mood-who-options button[aria-pressed="true"] { color: #fff; border-color: transparent; background: linear-gradient(135deg, #ff2e7e, #a32cff); box-shadow: 0 0 14px rgba(255, 46, 126, .35); }
@media (max-width: 760px) { .mood-who-label { font-size: 11px; } .mood-who-options button { min-height: 44px; font-size: 15px; } }

/* ---------- Settings: the 18+ card and its dialog ---------- */
.space-adult-card h2 { margin: 14px 0 8px; font: 400 25px/1.1 Georgia, serif; letter-spacing: -.03em; }
.space-adult-card p { margin: 0 0 12px; color: #5f5b52; font-size: 13px; line-height: 1.5; }
.space-adult-card .space-adult-count { color: var(--ink); font-weight: 700; }
.space-adult-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 6px 0 12px; }
.space-adult-actions .primary { min-height: 40px; padding: 0 18px; }
.space-adult-card .text-action { padding: 0; border: 0; background: none; color: var(--red); font-size: 12px; text-decoration: underline; }

.space-dialog { width: min(480px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0; overscroll-behavior: contain; border: 0; color: #2b1020; background: #fff1f6; box-shadow: 10px 10px 0 #2a0b1d, 0 0 60px rgba(255, 46, 126, .35); }
.space-dialog::backdrop { background: rgba(18, 4, 15, .78); backdrop-filter: blur(6px); }
.space-dialog-inner { position: relative; padding: 28px 26px 22px; }
.space-dialog-seal { position: absolute; right: 22px; top: 18px; display: grid; place-items: center; width: 46px; height: 46px; color: #fff; background: linear-gradient(135deg, #ff2e7e, #a32cff); font: 26px/1 "Yu Mincho", "MS Mincho", serif; transform: rotate(-6deg); }
.space-dialog h2 { margin: 0 64px 10px 0; font: 400 26px/1.1 Georgia, serif; letter-spacing: -.03em; }
.space-dialog p { margin: 0 0 12px; font-size: 14px; line-height: 1.5; }
.space-dialog-points { margin: 0 0 16px; padding-left: 18px; font-size: 13px; line-height: 1.5; }
.space-dialog-points li { margin: 4px 0; }
.space-check { display: grid; grid-template-columns: 22px 1fr; gap: 8px; align-items: start; margin: 10px 0; font-size: 13px; line-height: 1.45; }
.space-check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: #ff2e7e; }
.space-check a { color: #b3125a; }
.space-dialog-error { min-height: 1em; color: #c0122f; font-weight: 700; }
.space-dialog-actions { display: flex; justify-content: flex-end; align-items: center; gap: 14px; margin-top: 8px; }
.space-dialog-actions .text-action { border: 0; background: none; color: #6b4a5c; font-size: 13px; text-decoration: underline; }
.space-dialog-actions .primary { min-height: 42px; padding: 0 20px; color: #fff; background: linear-gradient(135deg, #ff2e7e, #a32cff); }
.space-dialog-actions .primary:disabled { opacity: .45; cursor: not-allowed; }
/* Phones: the quiet text buttons ("Cancel", "Withdraw") are 44 px to the touch. */
@media (max-width: 760px) {
    .space-adult-card .text-action, .space-dialog-actions .text-action { min-height: 44px; padding: 0 8px; }
}

/* ---------- 18+: after dark ---------- */
/* The same pages in another light: wine-dark night, blush paper, neon pink where the red seal was. */
html[data-adult="true"] {
    --ink: #1c0716;
    --night: #12040f;
    --paper: #ffe8f1;
    --paper-deep: #f6c6da;
    --red: #ff2e7e;
    --blue: #7a2cff;
    --muted: #b88aa6;
    --line: rgba(255, 170, 210, .22);
    background: var(--night);
}
html[data-adult="true"] body {
    background:
        radial-gradient(1200px 700px at 85% -10%, rgba(163, 44, 255, .22), transparent 60%),
        radial-gradient(900px 600px at -10% 110%, rgba(255, 46, 126, .18), transparent 60%),
        var(--night);
    background-attachment: fixed;
}
html[data-adult="true"] body::before { opacity: .16; background-image: radial-gradient(rgba(255, 140, 190, .35) .55px, transparent .7px); }
html[data-adult="true"] .brand-mark { font-size: 0; background: linear-gradient(135deg, #ff2e7e, #a32cff); box-shadow: 0 0 22px rgba(255, 46, 126, .55); }
html[data-adult="true"] .brand-mark::after { content: '艶'; font-size: 24px; }
html[data-adult="true"] .space-badge { color: #ff6aa6; text-shadow: 0 0 10px rgba(255, 46, 126, .7); }
html[data-adult="true"] .sheet { box-shadow: 9px 9px 0 #2a0b1d, 0 0 40px rgba(255, 46, 126, .12); background-image: repeating-linear-gradient(0deg, transparent 0 27px, rgba(120, 20, 70, .06) 28px); }
html[data-adult="true"] .anime-card { box-shadow: 0 0 0 1px rgba(255, 46, 126, .35), 0 18px 60px rgba(163, 44, 255, .25); }
html[data-adult="true"] .match-badge { background: linear-gradient(135deg, #ff2e7e, #a32cff); }
html[data-adult="true"] .nav-button.active::after { background: linear-gradient(90deg, #ff2e7e, #a32cff); box-shadow: 0 0 10px rgba(255, 46, 126, .7); }
html[data-adult="true"] .primary:hover { background: #ff2e7e; }
html[data-adult="true"] .topbar { border-bottom-color: rgba(255, 46, 126, .28); }
@media (max-width: 760px) {
    html[data-adult="true"] .topbar nav:not(.hidden) { background: #160512; border-top-color: rgba(255, 46, 126, .3); }
}
@media (prefers-reduced-motion: no-preference) {
    html[data-adult="true"] .brand-mark { animation: space-glow 3.2s ease-in-out infinite alternate; }
    @keyframes space-glow { from { box-shadow: 0 0 12px rgba(255, 46, 126, .35); } to { box-shadow: 0 0 26px rgba(163, 44, 255, .6); } }
}

/* The notebook's dark rails and tiles take the night's colour instead of their fixed grey. */
html[data-adult="true"] .nb-tabs { background: #1c0718; border-bottom-color: rgba(255, 46, 126, .25); }
html[data-adult="true"] .nb-tabs button { color: #c99ab6; }
html[data-adult="true"] .nb-tabs button > span { color: #8d5d7b; }
html[data-adult="true"] .nb-tabs button[aria-selected="true"], html[data-adult="true"] .nb-tabs button:hover { color: #ffe8f1; }
html[data-adult="true"] .nb-tabs button[aria-selected="true"] > span { color: #ff2e7e; }
html[data-adult="true"] .nb-stat { background: #22091d; border-color: rgba(255, 46, 126, .28); color: #ffe8f1; }
html[data-adult="true"] .nb-stat > span:last-child { color: #d7a6c3; }
html[data-adult="true"] .nb-stat-mark { color: rgba(255, 190, 225, .08); }
html[data-adult="true"] .nb-kicker > b { color: #e08ab6; }
html[data-adult="true"] .nb-hanko { background: linear-gradient(135deg, #ff2e7e, #a32cff); box-shadow: 5px 5px 0 #2a0b1d; }
html[data-adult="true"] .toast { background: linear-gradient(135deg, #ff2e7e, #a32cff); box-shadow: 5px 5px 0 #2a0b1d; }
/* The admin console is the operator's tool, not part of the night: it keeps AniMood's own paper and ink. */
/* Match is the anime notebook's social side, open from every space: it keeps AniMood's own paper and ink too. */
html[data-adult="true"] #adminView, html[data-space="manga"] #adminView,
html[data-adult="true"] #matchView, html[data-space="manga"] #matchView {
    --ink: #121212; --night: #171719; --paper: #f2eedf; --paper-deep: #ded7c2; --red: #ef4b3f; --blue: #244c78; --muted: #8f8c83; --line: rgba(242, 238, 223, .2);
}

/* Manga: the same paper, a cooler accent so the switch shows at a glance. */
html[data-space="manga"] { --red: #2f6fdd; }
html[data-space="manga"] .space-badge { color: #6ea0ff; }
html[data-space="manga"] .toast { background: #2f6fdd; }

/* ---------- The deck's "Made in" filter (mood panel) ---------- */
.mood-origin { margin: 10px 0 4px; }
.mood-origin label { display: block; color: #6e695f; font-size: 7px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.mood-origin select { width: 100%; height: 38px; margin-top: 6px; padding: 0 7px; border: 1px solid #aaa697; border-radius: 0; color: var(--ink); background: transparent; font-size: 9px; }
@media (max-width: 760px) {
    .mood-origin label { font-size: 11px; }
    .mood-origin select { font-size: 16px; }
}
/* iPad: iOS zooms the page into a field under 16 px (the selects beside it do the same, app.css). */
@media (pointer: coarse) {
    .mood-origin select { font-size: 16px; }
}
