/* JamRadar — reference component CSS.
   Needs tokens/tokens.css first. Fonts: Anton, Archivo (400/600/800),
   Stardos Stencil (700), Special Elite, Permanent Marker.
   This is a reference build of the design, not a framework: copy the parts
   you need into your own component system. Class prefix: jr-. */

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--body-size);
  line-height: var(--body-line);
  -webkit-font-smoothing: antialiased;
}

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.jr-display-xl, .jr-display-l, .jr-display-m, .jr-display-s {
  margin: 0; font-family: var(--font-display); font-weight: 400; text-transform: uppercase;
}
.jr-display-xl { font-size: clamp(60px, 16vw, 176px); line-height: var(--display-xl-line); letter-spacing: var(--display-xl-tracking); }
.jr-display-l  { font-size: clamp(40px, 9vw, 72px); line-height: var(--display-l-line); }
.jr-display-m  { font-size: var(--display-m-size); line-height: var(--display-m-line); }
.jr-display-s  { font-size: var(--display-s-size); line-height: var(--display-s-line); letter-spacing: 1px; }

.jr-label {
  font-family: var(--font-type); font-size: var(--label-size); line-height: var(--label-line);
  letter-spacing: var(--label-tracking); text-transform: uppercase;
}
.jr-meta  { font-family: var(--font-type); font-size: var(--meta-size); line-height: var(--meta-line); color: var(--ink-soft); }
.jr-small { font-size: var(--small-size); line-height: var(--small-line); color: var(--ink-soft); }
.jr-hand  { font-family: var(--font-hand); font-size: var(--hand-size); line-height: var(--hand-line); color: var(--marker); }

.jr-rule { border: 0; border-top: var(--stroke-rule) var(--ink); margin: 0; }

.jr-visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Texture ----------
   Add .jr-tex to any surface and set its level with one of the modifiers.
   Dark surfaces get crackle (screen); ink fills get toner + mottle (multiply).
   Tiles are 1024 px and seamless. Never on stickers, inputs or map tiles. */
.jr-tex { position: relative; isolation: isolate; }
.jr-tex::after {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; /* behind content, above the background */
  background-image: url("/textures/crackle-light.webp");
  background-size: 1024px 1024px;
  mix-blend-mode: screen;
  opacity: var(--jr-tex, var(--texture-browse));
}
.jr-tex--hero   { --jr-tex: var(--texture-hero); }
.jr-tex--browse { --jr-tex: var(--texture-browse); }
.jr-tex--task   { --jr-tex: var(--texture-task); }
.jr-tex--ink::after {
  background-image: url("/textures/toner.webp"), url("/textures/mottle-dark.webp");
  mix-blend-mode: multiply;
}
[data-theme="inverted"] .jr-tex::after {
  background-image: url("/textures/crackle-dark.webp");
  mix-blend-mode: multiply;
}
[data-theme="inverted"] .jr-tex--ink::after {
  background-image: url("/textures/mottle-light.webp");
  mix-blend-mode: screen;
}

/* ---------- Sticker (primary action) ---------- */
.jr-sticker-wrap { position: relative; display: inline-block; transform: rotate(var(--jr-tilt, -1.5deg)); }
.jr-sticker {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; padding: 14px 26px; border: 0; cursor: pointer;
  background-color: var(--sticker);
  background-image: linear-gradient(135deg, rgba(255,255,255,.6) 0%, rgba(255,255,255,0) 38%);
  color: var(--on-sticker);
  font-family: var(--font-display); font-size: 22px; letter-spacing: 1px; text-transform: uppercase;
  border-radius: var(--radius-sticker);
  box-shadow: var(--shadow-sticker);
  text-decoration: none;
  transition: transform 120ms ease-out, box-shadow 120ms ease-out;
}
.jr-sticker--block { display: flex; width: 100%; }
.jr-sticker--small { min-height: 44px; padding: 10px 16px; font-family: var(--font-ui); font-weight: 600; font-size: 16px; letter-spacing: 0; text-transform: none; }
.jr-sticker--icon  { width: 56px; height: 52px; padding: 0; }
.jr-sticker:hover  { transform: translateY(-1px); box-shadow: 0 3px 0 rgba(0,0,0,.3), 0 12px 22px rgba(0,0,0,.45); }
.jr-sticker:active { transform: translateY(1px); box-shadow: 0 1px 0 rgba(0,0,0,.3), 0 4px 10px rgba(0,0,0,.4); }
.jr-sticker:disabled, .jr-sticker[aria-disabled="true"] {
  background: transparent; color: var(--ink-soft); border: 2px dashed var(--ink-soft);
  box-shadow: none; cursor: not-allowed; transform: none;
}
.jr-tape {
  position: absolute; width: 64px; height: 20px; pointer-events: none;
  background: var(--tape);
  clip-path: polygon(0 0,96% 0,100% 20%,96% 40%,100% 60%,96% 80%,100% 100%,0 100%,4% 80%,0 60%,4% 40%,0 20%);
}
.jr-tape--top    { top: -10px; left: 50%; margin-left: -32px; transform: rotate(-4deg); }
.jr-tape--tl     { top: -10px; left: -18px; transform: rotate(-30deg); }
.jr-tape--br     { bottom: -10px; right: -18px; transform: rotate(-30deg); }

/* ---------- Ink buttons and links (secondary) ---------- */
.jr-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; cursor: pointer;
  background: transparent; color: var(--ink); border: var(--stroke-control) var(--ink);
  font-family: var(--font-display); font-size: 18px; letter-spacing: 1px; text-transform: uppercase;
  text-decoration: none;
}
.jr-btn--solid { background: var(--ink-block); color: var(--on-ink); }
.jr-btn:hover { background: color-mix(in srgb, var(--ink) 12%, transparent); }
.jr-btn--solid:hover { background: var(--ink-block); filter: brightness(1.08); }

.jr-link {
  color: var(--ink); font-weight: 600;
  text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 5px;
  padding: 12px 0; display: inline-block;
}

.jr-icon-btn {
  width: 48px; height: 48px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--ground-raised); color: var(--ink); border: var(--stroke-frame) var(--ink); cursor: pointer; padding: 0;
}
.jr-icon-btn--plain { background: transparent; border: var(--stroke-control) var(--ink); width: 44px; height: 44px; }
.jr-icon-btn--solid { background: var(--ink-block); color: var(--on-ink); }
.jr-icon-btn--lg    { width: 56px; height: 56px; }
.jr-icon { width: 24px; height: 24px; flex: 0 0 auto; }

/* ---------- Badge ---------- */
.jr-badge {
  display: inline-block; background: var(--ink-block); color: var(--on-ink);
  font-family: var(--font-stencil); font-weight: 700; font-size: 14px; letter-spacing: 1px;
  text-transform: uppercase; line-height: 1; padding: 3px 6px;
}
/* numbers: plain font, the stencil 1 reads as an I */
.jr-badge--count { font-family: var(--font-ui); font-weight: 800; font-size: 13px; letter-spacing: 0; }

/* ---------- Fields ---------- */
.jr-field { display: flex; flex-direction: column; gap: 8px; }
.jr-input, .jr-select, .jr-textarea {
  width: 100%; min-height: 48px; padding: 12px 14px;
  background: var(--ground); color: var(--ink);
  border: var(--stroke-control) var(--ink); border-radius: 0;
  font-family: var(--font-ui); font-size: 16px; /* 16px stops iOS zoom */
}
.jr-input::placeholder, .jr-textarea::placeholder { color: var(--ink-soft); opacity: 1; }
.jr-textarea { resize: vertical; }
.jr-select-wrap { position: relative; display: block; }
.jr-select { appearance: none; -webkit-appearance: none; padding-right: 40px; }
.jr-select-wrap::after {
  content: ""; position: absolute; right: 14px; top: 50%; margin-top: -5px;
  border-left: 7px solid transparent; border-right: 7px solid transparent; border-top: 10px solid var(--ink);
  pointer-events: none;
}
.jr-field[data-invalid] .jr-input,
.jr-field[data-invalid] .jr-textarea { border-color: var(--signal-error); }
.jr-error { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--signal-error); }
.jr-help  { font-size: 14px; color: var(--ink-soft); }

/* ---------- Chips (multi-select) ---------- */
.jr-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.jr-chip {
  min-height: 44px; padding: 9px 14px; cursor: pointer;
  background: transparent; color: var(--ink); border: var(--stroke-control) var(--ink);
  font-family: var(--font-ui); font-weight: 600; font-size: 15px;
}
.jr-chip[aria-pressed="true"] { background: var(--ink-block); color: var(--on-ink); }
.jr-chip--more { border-style: dashed; }

/* ---------- Choice list (single select, e.g. goal) ---------- */
.jr-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.jr-choice {
  display: flex; align-items: center; gap: 10px; text-align: left; cursor: pointer;
  min-height: 44px; padding: 6px 12px;
  background: transparent; color: var(--ink); border: var(--stroke-control) var(--ink);
  font-family: var(--font-ui); font-weight: 600; font-size: 15px; line-height: 1.2;
}
.jr-choice::before { content: ""; flex: 0 0 auto; width: 14px; height: 14px; border: 2px solid currentColor; }
.jr-choice[aria-checked="true"] { background: var(--ink-block); color: var(--on-ink); }
.jr-choice[aria-checked="true"]::before { background: currentColor; }

/* ---------- Switch ---------- */
.jr-switch {
  position: relative; flex: 0 0 auto; width: 60px; height: 34px; padding: 0; cursor: pointer;
  border-radius: var(--radius-round); background: transparent; border: var(--stroke-control) var(--ink);
}
.jr-switch::after {
  content: ""; position: absolute; top: 4px; left: 4px; width: 22px; height: 22px;
  border-radius: var(--radius-round); background: var(--ink); transition: left 140ms ease-out;
}
.jr-switch[aria-checked="true"] { background: var(--ink-block); }
.jr-switch[aria-checked="true"]::after { left: 30px; background: var(--on-ink); }
.jr-setting { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.jr-setting__text { display: flex; flex-direction: column; gap: 4px; }

/* ---------- Range (native input, styled) ---------- */
.jr-range { -webkit-appearance: none; appearance: none; width: 100%; height: 44px; background: transparent; margin: 0; cursor: pointer; }
.jr-range::-webkit-slider-runnable-track { height: 6px; background: linear-gradient(var(--ink), var(--ink)) 0 / var(--jr-fill, 0%) 100% no-repeat, var(--ink-soft); }
.jr-range::-moz-range-track { height: 6px; background: var(--ink-soft); }
.jr-range::-moz-range-progress { height: 6px; background: var(--ink); }
.jr-range::-webkit-slider-thumb {
  -webkit-appearance: none; width: 26px; height: 26px; margin-top: -10px;
  background: var(--ink-block); border: 3px solid var(--ground-raised); outline: 2px solid var(--ink); border-radius: 0;
}
.jr-range::-moz-range-thumb { width: 20px; height: 20px; background: var(--ink-block); border: 3px solid var(--ground-raised); outline: 2px solid var(--ink); border-radius: 0; }

/* ---------- Instrument row + skill meter ---------- */
.jr-instrument { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 14px 0; border-bottom: var(--stroke-rule) var(--ink); }
.jr-instrument__name { font-family: var(--font-display); font-size: 20px; text-transform: uppercase; }
.jr-skill { margin-left: auto; display: flex; align-items: center; gap: 10px; font-family: var(--font-type); font-size: 14px; }
.jr-skill__bars { display: flex; gap: 2px; }
.jr-skill__bars span { width: 8px; height: 14px; border: 2px solid var(--ink); }
.jr-skill__bars span.on { background: var(--ink); }

/* ---------- Map pins (as HTML markers) ---------- */
.jr-pin { width: 28px; height: 38px; color: var(--pin); filter: drop-shadow(0 2px 0 rgba(0,0,0,.55)); transform-origin: 50% 100%; transition: transform 160ms cubic-bezier(.2,.9,.3,1.2); cursor: pointer; }
.jr-pin[aria-pressed="true"], .jr-pin--selected { transform: scale(1.4); color: var(--pin-selected); }
.jr-cluster {
  width: 44px; height: 44px; border-radius: var(--radius-round);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--ink-block); color: var(--on-ink); border: 3px solid var(--map-land); outline: 2px solid var(--ink);
  font-family: var(--font-display); font-size: 18px;
}
.jr-you { width: 56px; height: 56px; border-radius: var(--radius-round); border: 3px dashed var(--pin-you); display: inline-flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--pin-you) 20%, transparent); }
.jr-you::after { content: ""; width: 14px; height: 14px; border-radius: var(--radius-round); background: var(--pin-you); }

/* ---------- Pin label (the callout is a sticker) ---------- */
.jr-pin-label {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px; width: 250px; text-align: left; cursor: pointer;
  border: 0; padding: 12px 14px 10px; border-radius: var(--radius-sticker); box-shadow: var(--shadow-sticker);
  background-color: var(--sticker);
  background-image: linear-gradient(135deg, rgba(255,255,255,.6) 0%, rgba(255,255,255,0) 38%);
  color: var(--on-sticker); font-family: var(--font-ui);
}
.jr-pin-label__top { display: flex; width: 100%; justify-content: space-between; align-items: baseline; }
.jr-pin-label__name { font-family: var(--font-display); font-size: 24px; text-transform: uppercase; }
.jr-pin-label__dist { font-family: var(--font-type); font-size: 13px; color: #4a3f47; }
.jr-pin-label__sub  { font-size: 14px; color: #4a3f47; }
.jr-pin-label__cta {
  margin-top: 8px; align-self: stretch; display: flex; align-items: center; justify-content: space-between;
  border-top: 2px dashed var(--on-sticker); padding-top: 8px;
  font-family: var(--font-display); font-size: 18px; letter-spacing: 1px; text-transform: uppercase;
}

/* ---------- Top bar + account menu ---------- */
.jr-topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 16px; min-height: 60px; background: var(--ground); border-bottom: var(--stroke-rule) var(--ink);
}
.jr-topbar__logo { display: block; height: 24px; width: auto; color: var(--ink); }
@media (min-width: 1024px) { .jr-topbar { padding: 8px 24px; } .jr-topbar__logo { height: 26px; } }
.jr-account {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; cursor: pointer;
  background: var(--ground-raised); color: var(--ink); border: var(--stroke-control) var(--ink);
  font-family: var(--font-ui); font-weight: 600; font-size: 16px;
}

/* ---------- Menu ---------- */
.jr-menu {
  min-width: 200px; display: flex; flex-direction: column;
  background: var(--ground-raised); border: var(--stroke-frame) var(--ink); box-shadow: var(--shadow-pin);
}
.jr-menu__item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 46px; padding: 0 14px; text-align: left; cursor: pointer;
  background: transparent; color: var(--ink); border: 0; font-family: var(--font-ui); font-weight: 600; font-size: 16px; text-decoration: none;
}
.jr-menu__item + .jr-menu__item { border-top: var(--stroke-rule) var(--ink); }
.jr-menu__item:hover, .jr-menu__item:focus-visible { background: color-mix(in srgb, var(--ink) 14%, transparent); }
.jr-menu__item--danger { color: var(--signal-error); }

/* ---------- Conversation list ---------- */
.jr-convo { display: flex; align-items: flex-start; gap: 12px; padding: 16px; border-bottom: var(--stroke-rule) var(--ink); }
.jr-convo__main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; color: inherit; text-decoration: none; }
.jr-convo__name { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-size: 22px; text-transform: uppercase; }
.jr-convo[aria-current="true"] { background: var(--ink-block); color: var(--on-ink); }
.jr-convo[aria-current="true"] .jr-small { color: var(--on-ink); }

/* ---------- Message bubbles ---------- */
.jr-thread { display: flex; flex-direction: column; gap: 14px; padding: 16px; }
.jr-msg { max-width: 78%; display: flex; flex-direction: column; gap: 4px; }
.jr-msg p { margin: 0; padding: 10px 14px; line-height: 1.5; }
.jr-msg--in  { align-self: flex-start; }
.jr-msg--in p  { border: var(--stroke-control) var(--ink); }
.jr-msg--out { align-self: flex-end; align-items: flex-end; }
.jr-msg--out p { background: var(--ink-block); color: var(--on-ink); }
.jr-msg--failed p { background: transparent; color: var(--ink); border: 2px dashed var(--signal-error); }
.jr-msg__retry { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--signal-error); }
.jr-day { display: flex; align-items: center; gap: 12px; font-family: var(--font-type); font-size: 13px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--ink-soft); }
.jr-day::before, .jr-day::after { content: ""; flex: 1; border-top: var(--stroke-rule) var(--ink); }
.jr-composer { display: flex; align-items: flex-end; gap: 12px; padding: 14px 16px; border-top: var(--stroke-rule) var(--ink); }

/* ---------- Progress steps ---------- */
.jr-steps { display: flex; gap: 6px; }
.jr-steps span { flex: 1; height: 8px; border: 2px solid var(--ink); }
.jr-steps span.done { background: var(--ink-block); }

/* ---------- Stencil strip (one per screen) ---------- */
.jr-stencil-strip {
  display: inline-block; align-self: flex-start; background: var(--ink-block); color: var(--on-ink);
  font-family: var(--font-stencil); font-weight: 700; font-size: 40px; line-height: .9; text-transform: uppercase;
  padding: 4px 12px 6px; transform: rotate(-2deg);
}

/* ---------- Panel / empty state ---------- */
.jr-panel { background: var(--ground-raised); border: var(--stroke-frame) var(--ink); padding: 20px 18px; display: flex; flex-direction: column; gap: 14px; }

/* ---------- Status banner ---------- */
.jr-banner { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--ink-block); color: var(--on-ink); font-weight: 600; font-size: 15px; line-height: 1.35; }
.jr-toast  { display: inline-flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--ground-raised); color: var(--ink); border: var(--stroke-frame) var(--ink); font-weight: 600; font-size: 15px; }

/* ---------- Sheet (phone) / dialog (desktop) ---------- */
.jr-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.6); }
.jr-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; max-height: calc(100dvh - 56px);
  display: flex; flex-direction: column;
  background: var(--ground-raised); color: var(--ink); border-top: var(--stroke-frame) var(--ink);
  animation: jr-sheet-in 220ms cubic-bezier(.2,.8,.2,1);
}
.jr-sheet__head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: var(--stroke-rule) var(--ink); }
.jr-sheet__body { flex: 1 1 auto; overflow: auto; padding: 16px; }
.jr-sheet__foot { display: flex; gap: 14px; padding: 14px 16px calc(20px + env(safe-area-inset-bottom)); border-top: var(--stroke-rule) var(--ink); }
@media (min-width: 1024px) {
  .jr-sheet { left: 50%; right: auto; bottom: auto; top: 50%; width: 420px; max-height: 80vh; transform: translate(-50%, -50%); border: var(--stroke-frame) var(--ink); animation: jr-fade-in 160ms ease-out; }
}
@keyframes jr-sheet-in { from { transform: translateY(100%); } to { transform: none; } }
@keyframes jr-fade-in  { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Musician counter bar ---------- */
.jr-counter { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; background: var(--ink-block); color: var(--on-ink); font-family: var(--font-type); font-size: 15px; }
.jr-counter .jr-icon-btn { background: transparent; color: var(--on-ink); border: var(--stroke-control) var(--on-ink); width: 44px; height: 44px; }

/* ---------- Motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
  .jr-sticker-wrap, .jr-stencil-strip { transform: none; }
}
/* Windows high contrast: keep stickers and chips visible */
@media (forced-colors: active) {
  .jr-sticker, .jr-chip, .jr-choice, .jr-switch { border: 2px solid ButtonText; }
  .jr-tex::after { display: none; }
}
