/* ── First-visit content picker — "What do you want to read?" (components/content-welcome; 'content_welcome' per site →
   CONTENT_WELCOME in plugins/settings.php; behaviour in assets/scripts/content-welcome.js) ─────────────────────────────
   A visitor who has not chosen yet is asked once what the site should list for them: All, Comics or Novels — one card
   each, a fan of three of that kind's covers over its name, what it lists and how many series there are.

   The frame is the Appearance dialog's (.td-modal / .td-dialog / .td-head … in global-deferred.css): a centred dialog
   from 768px, the site's bottom sheet below — so the frame, its head tile and its × already follow the roundness level
   (ui-radius.css) and the plain option (ui-plain.css). This sheet only adds the cards (.cw-*), and everything a site
   option reaches is written here, on the tokens:
     themes       --c-* tokens and the text tiers (--ta-b / --ta-m): dark, light, the colour schemes, the gradient themes
     accent       --zmio-accent-* (the reader's), then the scheme's, then violet
     ui_round     cards and covers on the card scale (--ui-rc-*), the arrow tile on the control scale (--ui-r-*)
     ui_plain     no hairline on the cards or the covers
     ui_controls  the cards as the site's row controls are drawn: 1 ghost · 2 joined · 3 solid · 4 outline · 5 accent
     icon_pack    every glyph comes from icon()                                                                      */

.cw-dialog { max-width: 760px; outline: 0; }

.cw-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }

/* ── a card ── */
.cw-opt {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 14px;
    border: 1px solid rgb(var(--c-white) / .08);
    border-radius: var(--ui-rc-xl, .75rem);
    background: rgb(var(--c-white) / .04);
    color: rgb(var(--c-white) / calc(var(--ta-b, 0) + var(--ta-m, 1) * .75));
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.cw-opt:hover, .cw-opt:focus-visible { background: rgb(var(--c-white) / .08); border-color: rgba(var(--zmio-accent-rgb, var(--scheme-rgb, 167, 139, 250)), .55); color: rgb(var(--c-white)); }
.cw-opt:focus-visible { outline: 2px solid var(--zmio-accent-soft, #a78bfa); outline-offset: 2px; }
.cw-opt.is-busy { pointer-events: none; opacity: .7; }

/* ── its fan of covers: the middle one upright in front, one leaning out behind it on each side ── */
.cw-fan {
    --cw-w: 100px;      /* the front cover's width (2:3) */
    --cw-side: .86;     /* a side cover's size against it */
    --cw-out: 50px;     /* how far a side cover's middle sits from the fan's */
    --cw-tilt: 9deg;
    position: relative;
    flex: none;
    display: block;
    height: calc(var(--cw-w) * 1.5 + 14px);
    margin-bottom: 12px;
}
.cw-cover {
    position: absolute;
    left: 50%;
    top: 4px;
    width: var(--cw-w);
    aspect-ratio: 2 / 3;
    overflow: hidden;
    border-radius: var(--ui-rc-lg, .5rem);
    background: rgb(var(--c-surface-3));
    box-shadow: 0 8px 20px rgb(0 0 0 / .45);
    transform: translateX(-50%);
    transition: transform .3s cubic-bezier(.2, .8, .2, 1), filter .2s ease;
    will-change: transform;
}
/* its hairline lies ON the picture (a ring, not a border: a border would leave a rim of the frame's own colour around
   the picture once the plain option clears it) */
.cw-cover::after { content: ""; position: absolute; inset: 0; z-index: 1; border-radius: inherit; box-shadow: inset 0 0 0 1px rgb(var(--c-white) / .2); pointer-events: none; }
.cw-cover img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; max-width: none; object-fit: cover; }
/* a cover that has no picture (none came, or it failed to load): a quiet tile with the kind's icon */
.cw-cover-ph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: rgb(var(--c-white) / .25); }
.cw-cover-ph svg { width: 34%; height: auto; }
.cw-cover.has-img .cw-cover-ph { display: none; }
.cw-cover:not(.has-img) img { display: none; }

.cw-cover--c { z-index: 2; }
.cw-cover--l, .cw-cover--r { z-index: 1; top: calc(4px + var(--cw-w) * .14); width: calc(var(--cw-w) * var(--cw-side)); filter: brightness(.82); }
/* until the dialog is in (.cw-in, set by the script once it shows) the three lie stacked; then they are dealt out */
.cw-in .cw-cover--l { transform: translateX(calc(-50% - var(--cw-out))) rotate(calc(var(--cw-tilt) * -1)); }
.cw-in .cw-cover--r { transform: translateX(calc(-50% + var(--cw-out))) rotate(var(--cw-tilt)); }
/* two covers only: the pair sits in the middle together */
.cw-in .cw-fan[data-n="2"] .cw-cover--c { transform: translateX(calc(-50% + var(--cw-out) * .4)); }
.cw-in .cw-fan[data-n="2"] .cw-cover--l { transform: translateX(calc(-50% - var(--cw-out) * .6)) rotate(calc(var(--cw-tilt) * -1)); }
/* pointed at (or focused): the fan opens a little wider and the front cover lifts */
.cw-in .cw-opt:is(:hover, :focus-visible) .cw-cover--c { transform: translate(-50%, -4px); }
.cw-in .cw-opt:is(:hover, :focus-visible) .cw-cover--l { transform: translateX(calc(-50% - var(--cw-out) * 1.16)) rotate(calc(var(--cw-tilt) * -1.4)); filter: none; }
.cw-in .cw-opt:is(:hover, :focus-visible) .cw-cover--r { transform: translateX(calc(-50% + var(--cw-out) * 1.16)) rotate(calc(var(--cw-tilt) * 1.4)); filter: none; }
.cw-in .cw-opt:is(:hover, :focus-visible) .cw-fan[data-n="2"] .cw-cover--c { transform: translate(calc(-50% + var(--cw-out) * .5), -4px); }
.cw-in .cw-opt:is(:hover, :focus-visible) .cw-fan[data-n="2"] .cw-cover--l { transform: translateX(calc(-50% - var(--cw-out) * .72)) rotate(calc(var(--cw-tilt) * -1.4)); }

/* ── its text: the kind's icon and name, what it lists, how many series; the arrow rides the name's line, at its end ── */
.cw-foot { position: relative; display: flex; align-items: center; gap: 10px; min-width: 0; }
.cw-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.cw-name { display: flex; align-items: center; gap: 7px; min-width: 0; padding-right: 36px; font-size: 15px; line-height: 1.3; font-weight: 700; color: rgb(var(--c-white)); }
.cw-name svg { flex: none; width: 16px; height: 16px; color: var(--zmio-accent-soft, rgb(var(--c-violet-soft))); }
.cw-desc { margin-top: 2px; font-size: 12.5px; line-height: 1.35; color: rgb(var(--c-white) / calc(var(--ta-b, 0) + var(--ta-m, 1) * .55)); }
.cw-count { margin-top: 6px; font-size: 11px; line-height: 1.3; font-weight: 600; letter-spacing: .02em; color: rgb(var(--c-white) / calc(var(--ta-b, 0) + var(--ta-m, 1) * .42)); }
.cw-go { position: absolute; top: -4px; right: 0; flex: none; display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: var(--ui-r-full, 9999px); background: rgb(var(--c-white) / .06); color: rgb(var(--c-white) / calc(var(--ta-b, 0) + var(--ta-m, 1) * .6)); transition: background-color .15s ease, color .15s ease, transform .15s ease; }
.cw-go svg { width: 13px; height: 13px; }
.cw-opt:hover .cw-go, .cw-opt:focus-visible .cw-go { background: var(--zmio-accent-pill-bg, var(--scheme-pill, linear-gradient(135deg, rgb(109, 40, 217), rgb(167, 139, 250)))); color: #fff; transform: translateX(2px); }

/* the light themes: softer cover shadows (a dark one reads as a smudge on a light panel) */
html[data-theme="light"] .cw-cover { box-shadow: 0 6px 16px rgb(0 0 0 / .18); }
html[data-theme="light"] .cw-cover--l, html[data-theme="light"] .cw-cover--r { filter: brightness(.94); }

/* ── ui_controls: the cards as the site draws its row controls ── */
/* 2 · joined — the three fuse into one bar: no gap, the hairlines overlap, the inner corners square */
html[data-ui-controls="2"] .cw-grid { gap: 0; }
html[data-ui-controls="2"] .cw-opt + .cw-opt { margin-left: -1px; }
html[data-ui-controls="2"] .cw-opt:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; }
html[data-ui-controls="2"] .cw-opt:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
html[data-ui-controls="2"] .cw-opt:is(:hover, :focus-visible) { z-index: 1; }
/* 3 · solid — filled tiles, no hairline */
html[data-ui-controls="3"] .cw-opt { border-color: transparent; background: rgb(var(--c-white) / .1); }
html[data-ui-controls="3"] .cw-opt:is(:hover, :focus-visible) { border-color: transparent; background: rgb(var(--c-white) / .17); }
/* 4 · outline — clear tiles with a stronger hairline; pointed at, the line takes the accent */
html[data-ui-controls="4"] .cw-opt { border-color: rgb(var(--c-white) / .18); background: transparent; }
html[data-ui-controls="4"] .cw-opt:is(:hover, :focus-visible) { border-color: rgba(var(--zmio-accent-rgb, var(--scheme-rgb, 167, 139, 250)), .9); background: transparent; }
/* 5 · accent — the arrow in the site accent from the start, as the rows' arrows are */
html[data-ui-controls="5"] .cw-go { background: var(--zmio-accent-pill-bg, var(--scheme-pill, linear-gradient(135deg, rgb(109, 40, 217), rgb(167, 139, 250)))); color: #fff; }

/* ── ui_plain: no hairlines — the cards keep their fill and their gap, the covers their shadow. Joined cards would
   read as one block without the lines between them, so there they stand apart again. ── */
html[data-ui-plain] .cw-opt:not(:focus-visible) { border-color: transparent !important; }
html[data-ui-plain] .cw-cover::after { content: none; }
/* the frame too, also while it holds the focus (it is focused when it opens; ui-plain.css spares a focused frame its line) */
html[data-ui-plain] .cw-dialog { border-color: transparent !important; }
html[data-ui-plain][data-ui-controls="2"] .cw-grid { gap: 8px; }
html[data-ui-plain][data-ui-controls="2"] .cw-opt { margin-left: 0; border-radius: var(--ui-rc-xl, .75rem); }
html[data-ui-plain][data-ui-controls="4"] .cw-opt { background: rgb(var(--c-white) / .04); } /* an outline with no line is nothing: the ghost fill */

/* ── below 768px: the bottom sheet — a row per choice: the fan, the text, the arrow ── */
@media (max-width: 767.98px) {
    .cw-grid { grid-template-columns: minmax(0, 1fr); gap: 8px; }
    .cw-opt { flex-direction: row; align-items: center; gap: 12px; padding: 10px 12px 10px 10px; }
    .cw-fan { --cw-w: 52px; --cw-out: 27px; width: 112px; height: calc(var(--cw-w) * 1.5 + 10px); margin: 0; }
    .cw-cover { top: 3px; border-radius: var(--ui-rc-md, .375rem); box-shadow: 0 4px 12px rgb(0 0 0 / .45); } /* small covers: the next corner down, so a high roundness level does not turn them into capsules */
    .cw-cover--l, .cw-cover--r { top: calc(3px + var(--cw-w) * .14); }
    .cw-foot { flex: 1 1 auto; }
    .cw-name { padding-right: 0; }
    .cw-go { position: static; } /* the row's last item, level with its middle */
    .cw-count { margin-top: 4px; }
    /* the head: its text may run to a few lines here, so the × sits at its top; a slightly smaller title */
    .cw-dialog .td-head { align-items: flex-start; }
    .cw-dialog .td-title { font-size: 17px; }
    .cw-dialog .td-x { margin-top: -4px; }
    /* joined: the rows fuse top to bottom instead */
    html[data-ui-controls="2"] .cw-opt + .cw-opt { margin-left: 0; margin-top: -1px; }
    html[data-ui-controls="2"] .cw-opt:not(:first-child) { border-top-left-radius: 0; border-top-right-radius: 0; border-bottom-left-radius: var(--ui-rc-xl, .75rem); }
    html[data-ui-controls="2"] .cw-opt:not(:last-child) { border-bottom-left-radius: 0; border-bottom-right-radius: 0; border-top-right-radius: var(--ui-rc-xl, .75rem); }
    html[data-ui-controls="2"] .cw-opt:not(:first-child):not(:last-child) { border-radius: 0; }
    html[data-ui-plain][data-ui-controls="2"] .cw-opt, html[data-ui-plain][data-ui-controls="2"] .cw-opt:not(:first-child):not(:last-child) { margin-top: 0; border-radius: var(--ui-rc-xl, .75rem); }
}
/* a narrow phone: a smaller fan, so the text keeps its room */
@media (max-width: 359.98px) {
    .cw-fan { --cw-w: 44px; --cw-out: 22px; width: 92px; }
    .cw-opt { gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
    .cw-opt, .cw-cover, .cw-go { transition: none; }
}
