/* styles/theme-wheel.css - the theme wheel (scripts/theme-wheel.js builds the markup).

   It is the site's HUD, so it has one look whatever skin is underneath: dark translucent wedges
   on a scrim that dims, desaturates and softens the page, a light wedge for the highlight, and
   a thin rim on the theme that is on now. Faces are named directly rather than through the
   --font-* tokens, because the Wikipedia and Dev skins repoint those. */

.theme-wheel {
  --tw-size: min(92vw, 72vh, 600px);
  --tw-ink: #f4f1ea;
  --tw-equipped: #e3a468;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: transparent;
  color: var(--tw-ink);
  font-family: "Instrument Sans", "Instrument Fallback", system-ui, sans-serif;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;                    /* a finger drags the highlight, never the page */
}
@supports (height: 1dvh) { .theme-wheel { --tw-size: min(92vw, 72dvh, 600px); } }
.theme-wheel[open] { display: grid; place-items: center; }
.theme-wheel:not(.has-hot), .theme-wheel.is-out { cursor: default; }
.theme-wheel::backdrop {
  background: rgb(6 7 10 / 0.6);
  -webkit-backdrop-filter: blur(4px) saturate(0.3);
  backdrop-filter: blur(4px) saturate(0.3);
}

.tw {
  position: relative;
  width: var(--tw-size);
  height: var(--tw-size);
  container-type: inline-size;
}
.tw__art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 10px 40px rgb(0 0 0 / 0.45));
}
.tw__wedge {
  fill: rgb(16 17 21 / 0.8);
  stroke: rgb(255 255 255 / 0.08);
  stroke-width: 0.4;
}
.tw__wedge.is-hot { fill: rgb(238 235 228 / 0.95); stroke: rgb(255 255 255 / 0.9); }
.tw__hub-disc { fill: rgb(10 11 14 / 0.88); stroke: rgb(255 255 255 / 0.08); stroke-width: 0.4; }
.tw__rim { fill: none; stroke: none; stroke-width: 1.6; stroke-linecap: round; }
.tw__rim.is-equipped { stroke: var(--tw-equipped); }

/* ---- the segments: real controls, laid over their wedges ------------------------------- */
.tw__seg {
  position: absolute;
  left: var(--x);
  top: var(--y);
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35em;
  min-width: 44px;
  min-height: 44px;
  padding: 6px;
  border: 0;
  background: none;
  color: rgb(244 241 234 / 0.82);
  font: 500 clamp(11px, 2.6cqi, 15px) / 1.15 "Instrument Sans", "Instrument Fallback", system-ui, sans-serif;
  letter-spacing: 0.02em;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: inherit;
  outline: none;                         /* the lit wedge is the focus indicator */
}
.tw__seg.is-hot { color: #121214; }
.tw__glyph {
  width: clamp(20px, 5.6cqi, 32px);
  height: clamp(20px, 5.6cqi, 32px);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tw__equipped {
  display: none;
  font-size: 0.72em;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--tw-equipped);
}
.tw__seg[aria-current] .tw__equipped { display: block; }
.tw__seg.is-hot .tw__equipped { color: #7a3f10; }
.is-recommend .tw__equipped { letter-spacing: 0.06em; }   /* "Recommended" (from the home page's CTA) is longer than "Current" */

/* ---- the hub: what is highlighted, or what is on now ------------------------------------ */
.tw__hub {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 50%;
  height: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(3px, 1.1cqi, 8px);
  padding: 0 9%;
  border: 0;
  border-radius: 50%;
  background: none;
  color: inherit;
  font: inherit;
  text-align: center;
  cursor: inherit;
  outline: none;
}
.tw__hub:focus-visible { outline: 2px solid rgb(244 241 234 / 0.55); outline-offset: -5px; }
.tw__eyebrow {
  font-size: clamp(9px, 1.8cqi, 11px);
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgb(244 241 234 / 0.55);
}
.tw__stills {
  width: 64%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: 4px;
  background: #1b1c20;
  box-shadow: 0 0 0 1px rgb(255 255 255 / 0.14);
}
.tw__stills img { display: block; width: 100%; height: 100%; object-fit: cover; }
.tw__stills img[hidden] { display: none; }
.tw__name {
  font: 500 clamp(16px, 4.7cqi, 28px) / 1.05 "Newsreader Display", "Newsreader Fallback", Georgia, serif;
  color: var(--tw-ink);
}
.tw__line {
  max-width: 100%;
  font-size: clamp(10.5px, 2.3cqi, 13px);
  line-height: 1.3;
  color: rgb(244 241 234 / 0.68);
  text-wrap: balance;
}

/* ---- the welcome: the first visit's heading above the ring --------------------------------
   Only when the wheel opened by itself (.is-welcome). Set in the wheel's own ink and faces, on
   the scrim, with no box of its own, so it reads as the wheel's caption rather than a banner.
   The ring gives up enough height for it; on a short landscape screen it sits beside the ring. */
.tw-hello { display: none; }
.theme-wheel.is-welcome {
  --tw-size: min(88vw, calc(100vh - 12.5rem), 560px);
  padding: 16px;
}
@supports (height: 1dvh) {
  .theme-wheel.is-welcome { --tw-size: min(88vw, calc(100dvh - 12.5rem), 560px); }
}
.theme-wheel.is-welcome[open] {
  grid-template-rows: auto auto;
  align-content: center;
  row-gap: clamp(20px, 3.4vh, 36px);
}
.theme-wheel.is-welcome::backdrop { background: rgb(6 7 10 / 0.72); }   /* words need more dark than a ring */
.theme-wheel.is-welcome .tw-hello {
  display: block;
  text-shadow: 0 1px 16px rgb(6 7 10 / 0.55);
  max-width: 34rem;
  text-align: center;
  cursor: default;
}
.tw-hello__h {
  margin: 0;
  font: 400 clamp(28px, 2.2vw + 18px, 46px) / 1.05 "Newsreader Display", "Newsreader Fallback", Georgia, serif;
  letter-spacing: -0.012em;
  color: var(--tw-ink);
  text-wrap: balance;
}
.tw-hello__d {
  max-width: 30rem;
  margin: 0.7em auto 0;
  font-size: clamp(13.5px, 0.4vw + 12px, 15.5px);
  line-height: 1.45;
  color: rgb(244 241 234 / 0.8);
  text-wrap: balance;
}
@media (min-width: 640px) { .tw-hello__d span { display: block; } }   /* one sentence a line */
@media (max-height: 520px) and (min-aspect-ratio: 4/3) {
  .tw-hello__d span { display: inline; }
  .theme-wheel.is-welcome { --tw-size: min(calc(100vh - 32px), 56vw, 560px); }
  @supports (height: 1dvh) {
    .theme-wheel.is-welcome { --tw-size: min(calc(100dvh - 32px), 56vw, 560px); }
  }
  .theme-wheel.is-welcome[open] {
    grid-template-rows: none;
    grid-template-columns: minmax(0, 16rem) auto;
    align-content: normal;
    justify-content: center;
    column-gap: clamp(20px, 4vw, 48px);
  }
  .theme-wheel.is-welcome .tw-hello { text-align: start; }
  .theme-wheel.is-welcome .tw-hello__d { margin-inline: 0; }
}

/* ---- motion: one short open, a faster close, nothing for the highlight -------------------
   Only `from` keyframes on the way in, so the resting state is the plain styles above and is
   whole with every animation switched off. */
@media (prefers-reduced-motion: no-preference) {
  .theme-wheel[open]::backdrop { animation: tw-fade 160ms ease-out; }
  .theme-wheel[open] .tw { animation: tw-in 200ms cubic-bezier(0.23, 1, 0.32, 1); }
  .theme-wheel.is-closing::backdrop { animation: tw-fade-out 110ms ease-out forwards; }
  .theme-wheel.is-closing .tw { animation: tw-out 110ms ease-out forwards; }
  /* The welcome is seen once, so it may take a breath longer: the words first, the ring a
     beat after them. backwards fill holds the ring at its first frame during that beat. */
  .theme-wheel.is-welcome[open] .tw-hello { animation: tw-rise 320ms cubic-bezier(0.23, 1, 0.32, 1); }
  .theme-wheel.is-welcome[open] .tw { animation-delay: 80ms; animation-duration: 260ms; animation-fill-mode: backwards; }
  .theme-wheel.is-welcome.is-closing .tw-hello { animation: tw-fade-out 110ms ease-out forwards; }
  .theme-wheel.is-welcome.is-closing .tw { animation: tw-out 110ms ease-out forwards; }
}
@keyframes tw-rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes tw-fade { from { opacity: 0; } }
@keyframes tw-in { from { opacity: 0; transform: scale(0.94); } }
@keyframes tw-fade-out { to { opacity: 0; } }
@keyframes tw-out { to { opacity: 0; transform: scale(0.97); } }

/* A small wheel (a landscape phone): the labels may wrap and the hub keeps only the name. */
@container (max-width: 300px) {
  .tw__seg { white-space: normal; max-width: 21cqi; }
  .tw__line, .tw__eyebrow { display: none; }
  .is-welcome .tw__eyebrow { display: block; }   /* "Stay on" is the point of the hub here */
}

@media (forced-colors: active) {
  .tw__wedge, .tw__hub-disc { fill: Canvas; stroke: CanvasText; }
  .tw__wedge.is-hot { fill: Highlight; }
  .tw__rim.is-equipped { stroke: Highlight; }
  .tw__seg.is-hot { forced-color-adjust: none; color: HighlightText; background: Highlight; }
  .tw__seg.is-hot .tw__equipped { color: HighlightText; }
}

/* ---- the nudge (theme-wheel.js) ----------------------------------------------------------
   A friendly, hand-drawn reminder at the trigger, every so often, for people still on the
   default theme: a red marker loop round the button, an arrow, a scribbled note. Drawn in with
   the strokes, gone in a moment, never in the way of the pointer. */
.tw-nudge {
  --tw-pen: #e5484d;
  position: fixed;
  z-index: 60;
  pointer-events: none;
  opacity: 0;
  transition: opacity 220ms ease;
}
.tw-nudge.is-in { opacity: 1; }
.tw-nudge.is-out { opacity: 0; transition-duration: 380ms; }
.tw-nudge svg {
  position: absolute;
  overflow: visible;
  fill: none;
  stroke: var(--tw-pen);
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tw-nudge path {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}
.tw-nudge.is-in path {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 700ms cubic-bezier(.65, 0, .35, 1);
}
.tw-nudge.is-in .tw-nudge__arrow path { transition-delay: 450ms; }
.tw-nudge.is-in .tw-nudge__arrow path + path { transition-delay: 950ms; transition-duration: 200ms; }
.tw-nudge__loop {
  inset: 0;
  width: 100%;
  height: 100%;
  stroke-width: 2.4;
}
.tw-nudge__loop path { vector-effect: non-scaling-stroke; }
.tw-nudge__arrow {
  top: calc(100% - 2px);
  left: 55%;
  width: 72px;
  height: 48px;
  stroke-width: 2.6;
}
.tw-nudge__note {
  position: absolute;
  top: calc(100% + 40px);
  left: calc(55% + 58px);
  color: var(--tw-pen);
  font: 700 17px/1.1 "Segoe Print", "Ink Free", "Bradley Hand", "Chalkboard SE", "Comic Sans MS", cursive;
  white-space: nowrap;
  padding: 4px 10px 5px;
  border: 1.5px solid var(--tw-pen);
  border-radius: 10px;
  background: var(--ground, Canvas);
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.28);
  transform: rotate(-4deg);
  transform-origin: left top;
  opacity: 0;
  transition: opacity 300ms ease 1000ms;
}
.tw-nudge.is-in .tw-nudge__note { opacity: 1; }
/* Not enough room on the right: the arrow and the note hang to the left, mirrored. */
.tw-nudge--left .tw-nudge__arrow { left: auto; right: 55%; transform: scaleX(-1); }
.tw-nudge--left .tw-nudge__note { left: auto; right: calc(55% + 58px); transform: rotate(4deg); transform-origin: right top; }
/* No room either side (a phone): the arrow points straight up, the note sits centred below. */
.tw-nudge--below .tw-nudge__arrow { left: 50%; transform: translateX(-50%); }
.tw-nudge--below .tw-nudge__note { left: 50%; top: calc(100% + 50px); transform: translateX(-50%) rotate(-3deg); transform-origin: center top; }
@media (prefers-reduced-motion: reduce) {
  .tw-nudge path { stroke-dashoffset: 0; }
  .tw-nudge.is-in path, .tw-nudge__note { transition: none; }
}
@media (forced-colors: active) {
  .tw-nudge { --tw-pen: CanvasText; }
}
