/* web/kit/kit.css: the Petadex's look on the web. Ink on stone, the addon's
   own faces, and colour that means something. Each cover's colours are in
   kit/covers.css (built from Theme.lua); put data-cover on <html>. API.md
   lists what's here. */

@font-face { font-family: "Petadex Display"; src: url("/kit/fonts/PetadexDisplay.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Petadex Shout"; src: url("/kit/fonts/PetadexShout.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Petadex Text"; src: url("/kit/fonts/PetadexText.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Petadex Text"; src: url("/kit/fonts/PetadexTextMedium.ttf") format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Petadex Mono"; src: url("/kit/fonts/PetadexMono.ttf") format("truetype"); font-display: swap; }

:root {
	--f-display: "Petadex Display", "Archivo", "Helvetica Neue", Arial, sans-serif;
	--f-shout: "Petadex Shout", "Archivo Narrow", "Arial Narrow", sans-serif;
	--f-text: "Petadex Text", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
	--f-mono: "Petadex Mono", "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;

	/* Motion. Moments reveal slowly on a long tail; the interface is quick. No bounce. */
	--ease: cubic-bezier(0.23, 1, 0.32, 1);          /* the interface: out, quick */
	--ease-moment: cubic-bezier(0.16, 1, 0.3, 1);    /* moments: out, long tail */
	--ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);   /* something already on screen moving */
	--t-fast: 150ms;
	--t-ui: 300ms;
	--t-moment: 700ms;

	--gutter: clamp(16px, 4.4vw, 56px);
	--measure: 34em;
	--wide: 1320px;
	--radius: 20px;
	--radius-s: 12px;
}

/* --- Tokens made from each cover's colours ------------------------------------------------- */
/* covers.css holds each cover's own colours, from Theme.lua. These follow from them, mixed in
   oklab, and sit on every [data-cover] so an element with a cover of its own works out its own.
   --pencil       the faintest ink that still reads: words not inked yet, a control's edge
                  (3.6:1 on Paper, 4:1 on the dark covers). Never for words at rest: use ink2.
   --accent-fill  the accent as a fill under --on-accent words: darker on Paper, to reach 4.5:1.
   --text, --muted  the addon's names for ink and ink2 (Theme.lua's own text and muted are chat
                  colours, the same in every cover). Prefer --ink and --ink2. */
[data-cover] {
	--pencil: var(--ink3);
	--accent-fill: var(--accent);
	--text: var(--ink);
	--muted: var(--ink2);
}
[data-cover="leather"] { /* Paper, the light cover */
	--pencil: color-mix(in oklab, var(--ink3) 88%, var(--ink));
	--accent-fill: color-mix(in oklab, var(--accent) 92%, var(--ink));
}

/* --- Ground and type ---------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { background: var(--page); color: var(--ink); -webkit-text-size-adjust: 100%; scroll-padding-top: 88px; }
body {
	margin: 0; min-height: 100vh; background: var(--page); color: var(--ink);
	font: 400 17px/1.55 var(--f-text); font-feature-settings: "cv11", "ss01";
	-webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility;
}
img, canvas, svg, video { display: block; max-width: 100%; }
a { color: inherit; text-decoration-color: var(--ink3); text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
p { margin: 0; text-wrap: pretty; }
h1, h2, h3, h4 { margin: 0; font-weight: 400; text-wrap: balance; }
::selection { background: var(--accent-fill); color: var(--on-accent); }

.display { font-family: var(--f-display); font-weight: 400; letter-spacing: 0; line-height: 0.98; }
.shout { font-family: var(--f-shout); font-size: 12px; line-height: 1.2; text-transform: uppercase; color: var(--ink2); letter-spacing: 0.02em; }
.mono, .num { font-family: var(--f-mono); font-variant-numeric: tabular-nums; letter-spacing: 0; }
.ink2 { color: var(--ink2); }
.ink3 { color: var(--ink3); } /* for marks that aren't read (a separator, an icon), never words */
.lede { font-size: clamp(18px, 1.5vw, 21px); line-height: 1.5; color: var(--ink2); max-width: var(--measure); }
.wrap { width: 100%; max-width: var(--wide); margin-inline: auto; padding-inline: var(--gutter); }
.hair { height: 1px; background: var(--hair); border: 0; margin: 0; }
[hidden] { display: none !important; }
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Focus is neutral, never the accent. */
:focus-visible { outline: 2px solid var(--ink2); outline-offset: 3px; border-radius: 6px; }
.skip { position: absolute; left: 12px; top: 12px; z-index: 100; padding: 10px 16px; border-radius: 999px; background: var(--raised); color: var(--ink); text-decoration: none; transform: translateY(calc(-100% - 24px)); transition: transform var(--t-fast) var(--ease); }
.skip:focus { transform: none; }

/* --- Buttons and pills --------------------------------------------------------------------- */
/* The accent fills one button per screen. Everything else is a quiet fill. */
.btn {
	-webkit-appearance: none; appearance: none; border: 0; cursor: pointer; text-decoration: none;
	display: inline-flex; align-items: center; justify-content: center; gap: 10px;
	min-height: 48px; padding: 0 22px; border-radius: 999px;
	font: 500 15px/1 var(--f-text); color: var(--ink); background: var(--secondary);
	transition: transform 160ms var(--ease), background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
	-webkit-tap-highlight-color: transparent; touch-action: manipulation; white-space: nowrap;
}
.btn:active { transform: scale(0.96); }
.btn.primary { background: var(--accent-fill); color: var(--on-accent); }
.btn.quiet { background: transparent; padding-inline: 14px; }
.btn.small { min-height: 40px; padding: 0 16px; font-size: 14px; }
@media (any-pointer: coarse) { .btn.small { min-height: 44px; } } /* a finger's 44px; 40 stays for a mouse */
.btn svg { width: 16px; height: 16px; flex: none; }
@media (hover: hover) and (pointer: fine) {
	.btn:hover { background: var(--secondary-hover); }
	.btn.primary:hover { background: color-mix(in oklab, var(--accent-fill) 86%, var(--ink)); }
	.btn.quiet:hover { background: var(--sunken); }
}
/* A Listen button keeps its width while it says Stop (kit.js holds it), so nothing under the
   pointer moves. */

/* A switch: <button class="switch" role="switch" aria-checked="false"><span class="track"
   aria-hidden="true"><span class="knob"></span></span>Its words</button>. Off is a pencil ring
   with the knob at the left; on is the accent, knob at the right: position and fill both say it.
   Toggle aria-checked yourself. A key press moves it at once; a pointer eases it. */
.switch {
	-webkit-appearance: none; appearance: none; border: 0; background: none; padding: 0; margin: 0; cursor: pointer;
	display: inline-flex; align-items: center; gap: 12px; min-height: 44px; text-align: left;
	font: 400 15px/1.3 var(--f-text); color: var(--ink); -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.switch .track {
	position: relative; flex: none; width: 40px; height: 24px; border-radius: 999px; background: transparent;
	box-shadow: inset 0 0 0 1.5px var(--pencil);
	transition: background-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), transform 160ms var(--ease);
}
.switch .knob {
	position: absolute; top: 4px; left: 4px; width: 16px; height: 16px; border-radius: 50%; background: var(--ink2);
	transition: transform var(--t-ui) var(--ease), background-color var(--t-fast) var(--ease);
}
.switch[aria-checked="true"] .track { background: var(--accent-fill); box-shadow: inset 0 0 0 1.5px var(--accent-fill); }
.switch[aria-checked="true"] .knob { transform: translateX(16px); background: var(--on-accent); }
.switch:active .track { transform: scale(0.96); }
.switch:focus-visible .track, .switch:focus-visible .knob { transition: none; }
@media (hover: hover) and (pointer: fine) {
	.switch:hover .track { box-shadow: inset 0 0 0 1.5px var(--ink2); }
	.switch[aria-checked="true"]:hover .track { background: color-mix(in oklab, var(--accent-fill) 86%, var(--ink)); box-shadow: inset 0 0 0 1.5px color-mix(in oklab, var(--accent-fill) 86%, var(--ink)); }
}
.pill { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; padding: 0 14px; border-radius: 999px; background: var(--sunken); font: 400 14px/1 var(--f-text); color: var(--ink2); }

/* Listen: the speaker, and its wave while he speaks. */
.speaker .wave { opacity: 0.5; transition: opacity var(--t-fast) var(--ease); }
.speaker[aria-pressed="true"] .wave { opacity: 1; animation: speak 1.1s var(--ease-in-out) infinite alternate; }
@keyframes speak { from { opacity: 0.35; } to { opacity: 1; } }

/* --- Rarity, family, portraits ---------------------------------------------------------------- */
.rarity { display: inline-flex; align-items: center; gap: 8px; }
.rarity::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--r, var(--common)); flex: none; }
[data-rarity="common"] { --r: var(--common); }
[data-rarity="uncommon"] { --r: var(--uncommon); }
[data-rarity="rare"] { --r: var(--rare); }
[data-rarity="legendary"] { --r: var(--legendary); }
[data-rarity="mythical"] { --r: var(--mythical); }

/* A companion's round portrait: its family's wash, its picture, and a ring in its rarity
   once it's yours. Size it with --size. The ring grows with it, from 2px to 6px at 540
   (--ring-w sets it outright). A gap (.portrait.gap) is a dark silhouette. Bare (.portrait.bare)
   is one with no picture to show: the wash and the ring, and from 160px up the first letter of
   its name, small, in Display. */
.portrait {
	--size: 72px; position: relative; width: var(--size); height: var(--size); border-radius: 50%; flex: none;
	background: radial-gradient(closest-side, color-mix(in oklab, var(--fam, var(--family-5)) 34%, var(--page)) 0%, color-mix(in oklab, var(--fam, var(--family-5)) 14%, var(--page)) 100%);
	overflow: hidden; isolation: isolate;
}
.portrait img { position: absolute; inset: 6%; width: 88%; height: 88%; object-fit: contain; }
.portrait::after { content: ""; position: absolute; inset: 0; border-radius: 50%; box-shadow: inset 0 0 0 var(--ring-w, clamp(2px, calc(1.75px + var(--size) * 0.0079), 6px)) var(--r, transparent); pointer-events: none; }
.portrait.gap { background: var(--sunken); }
.portrait.gap img { filter: brightness(0); opacity: 0.55; }
.portrait.gap::after { box-shadow: inset 0 0 0 1px var(--hair); }
[data-cover="leather"] .portrait.gap img { opacity: 0.18; }
.portrait.bare { container-type: inline-size; }
.portrait .initial {
	position: absolute; inset: 0; display: grid; place-items: center; padding-bottom: 1.5cqi;
	font: 400 11cqi/1 var(--f-display); color: color-mix(in oklab, var(--fam, var(--family-5)) 50%, var(--ink2)); pointer-events: none;
}
@container (max-width: 159px) { .portrait .initial { display: none; } }
.portrait .initial:not(:only-child) { display: none; } /* a page that puts its own in, has its own */

/* --- Spoken ink ------------------------------------------------------------------------------ */
/* A line appears whole in pencil, then each word inks to full strength as it's said.
   Nothing reflows and nothing slides (UI/Widgets.lua, W.Speak). It ends at ink, or at ink2 on
   an element with class ink2 (or ink3: words are never left in ink3, so it ends at ink2 too). */
.inking .w { color: var(--pencil, var(--ink3)); transition: color 280ms linear; }
.inking:is(.ink2, .ink3) { --ink-to: var(--ink2); }
.inking .w.on { color: var(--ink-to, var(--ink)); }
.inking.hidden .w { color: transparent; }
.inking.hidden .w.on { color: var(--ink-to, var(--ink)); }

/* --- The mark ---------------------------------------------------------------------------- */
/* the press kit's logo: the circle in amber and the name's own lettering (kit/logo.css), sized together by font-size */
.mark { position: relative; display: inline-flex; align-items: center; text-decoration: none; color: var(--ink); --mark-ink: var(--petadex); }
/* a link's 44px for a finger, above and below a small lockup, without moving it */
a.mark::before { content: ""; position: absolute; inset: min(0px, calc(50% - 22px)) 0; }
.mark canvas { width: 1.15em; height: 1.15em; flex: none; }
/* the word's still there to read out and copy; what's seen is its drawing, with the room the kit leaves before it */
.mark .name {
	flex: none; height: 1.15em; width: calc(1.15em * var(--petadex-name-wide)); overflow: hidden; white-space: nowrap; text-indent: 110%; line-height: 1;
	background: currentColor; -webkit-mask: var(--petadex-name) 0 0 / 100% 100% no-repeat; mask: var(--petadex-name) 0 0 / 100% 100% no-repeat; forced-color-adjust: none;
}

/* --- Turntable ------------------------------------------------------------------------------ */
.turntable { position: relative; aspect-ratio: 1; touch-action: pan-y; cursor: grab; user-select: none; -webkit-user-select: none; }
.turntable:active { cursor: grabbing; }
.turntable > i { position: absolute; inset: 0; background-repeat: no-repeat; background-size: 600% 600%; pointer-events: none; }

/* --- Models --------------------------------------------------------------------------------- */
/* A companion's own model, live (Petadex.model): a transparent canvas over whatever the page puts
   behind it, a wash, a ring, a card. A sideways drag turns it; an up-and-down one scrolls the page.
   A shadow (a gap) is black, as quiet as a portrait's gap. */
.model { touch-action: pan-y pinch-zoom; }
.model > canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
.model.turns { cursor: grab; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.model.turns:active { cursor: grabbing; }
.model.silhouette > canvas { opacity: 0.55; }
[data-cover="leather"] .model.silhouette > canvas { opacity: 0.18; }
.portrait.live { container-type: inline-size; }

/* --- The signature -------------------------------------------------------------------------- */
.signature { display: block; width: 100%; height: auto; overflow: visible; }
.signature path { fill: none; stroke: var(--ink); stroke-linecap: round; stroke-linejoin: round; }

/* --- A cover change ------------------------------------------------------------------------- */
/* One change, one motion: while the new cover opens in its circle, nothing else eases. */
html.cover-swap *, html.cover-swap *::before, html.cover-swap *::after { transition: none !important; }
/* the old cover holds still outside the circle: no cross-fade under it */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }

/* --- Reduced motion ------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
	.inking .w, .inking.hidden .w { color: var(--ink-to, var(--ink)); } /* words are simply there */
}
