/* SHUTWIDE RADIO — the floating music, date and weather widget (radio.js).
   All of its colours and sizes are the tokens below; dark mode retunes them. */

:root {
  --radio-bg: rgba(255, 255, 255, .8);      /* panel, over the photos */
  --radio-solid: #FFFFFF;                   /* behind icon clouds */
  --radio-body: #F3EFEA;                    /* the little iPod */
  --radio-screen: #E6E0D8;
  --radio-line: color-mix(in srgb, var(--ink) 13%, transparent);
  --radio-soft: color-mix(in srgb, var(--ink) 58%, transparent);
  --radio-accent: var(--red);
  --radio-blue: var(--blue);
  --radio-sun: #D39B33;
  --radio-grain: .07;
  --radio-width: 300px;
  --radio-gap: clamp(14px, 1.8vw, 28px);    /* from the screen edges */
  --radio-icon: 42px;                       /* collapsed iPod width */
}
@media (prefers-color-scheme: dark) {
  :root {
    --radio-bg: rgba(30, 30, 30, .82);
    --radio-solid: #1E1E1E;
    --radio-body: #2A2928;
    --radio-screen: #161616;
    --radio-sun: #E2B458;
    --radio-grain: .05;
  }
}

.radio {
  position: fixed;
  z-index: 60;
  right: max(var(--radio-gap), env(safe-area-inset-right));
  bottom: max(var(--radio-gap), env(safe-area-inset-bottom));
  font-family: var(--font);
  color: var(--ink);
  transition: opacity .3s var(--ease), visibility 0s linear 0s;
}
/* Out of the way while a photo, CONTACT or ABOUT is open. */
body:has(dialog[open]) .radio { opacity: 0; visibility: hidden; transition: opacity .3s var(--ease), visibility 0s linear .3s; }

/* ---------- Collapsed: the iPod ---------- */

.radio__toggle {
  display: block;
  width: var(--radio-icon);
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transform-origin: 100% 100%;
  transition: opacity .3s var(--ease), transform .45s var(--ease);
}
.radio__toggle svg { display: block; width: 100%; height: auto; overflow: visible; }
.radio__ipod-body { fill: var(--radio-body); stroke: var(--radio-line); }
.radio__ipod-screen { fill: var(--radio-screen); }
.radio__ipod-wheel { fill: none; stroke: var(--radio-line); stroke-width: 1.2; transition: stroke .3s; }
.radio__ipod-hub { fill: var(--radio-screen); }
.radio__ipod-arc {
  fill: none;
  stroke: var(--radio-accent);
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-dasharray: 9 60;
  opacity: 0;
  transform-origin: 22px 45px;
  transition: opacity .4s var(--ease);
}
@media (hover: hover) {
  .radio__toggle:hover { transform: translateY(-2px); }
  .radio__toggle:hover .radio__ipod-wheel { stroke: var(--radio-accent); }
}
.radio__toggle:focus-visible { outline: 2px solid var(--radio-blue); outline-offset: 4px; border-radius: 10px; }

/* Playing: a red mark turns slowly round the click wheel. */
.radio.is-playing .radio__ipod-arc { opacity: 1; animation: radio-spin 5s linear infinite; }
@keyframes radio-spin { to { transform: rotate(360deg); } }

/* ---------- Expanded: the panel ---------- */

.radio__panel {
  position: absolute;
  right: 0;
  bottom: 0;
  width: min(var(--radio-width), 100vw - 2 * var(--radio-gap));
  max-height: calc(100dvh - 2 * var(--radio-gap));
  overflow: hidden auto;
  overscroll-behavior: contain;
  padding: 15px 16px 13px;
  border: 1px solid var(--radio-line);
  border-radius: 14px;
  background: var(--radio-bg);
  -webkit-backdrop-filter: blur(16px) saturate(1.05);
  backdrop-filter: blur(16px) saturate(1.05);
  box-shadow: 0 18px 40px -28px rgba(0, 0, 0, .35);
  transform-origin: calc(100% - var(--radio-icon) / 2) calc(100% - 20px);
  opacity: 0;
  transform: translateY(8px) scale(.94);
  visibility: hidden;
  transition: opacity .32s var(--ease), transform .5s var(--ease), visibility 0s linear .5s;
}
/* Analog grain, very faint. */
.radio__panel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: var(--radio-grain);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1.4 -.2'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}
.radio.is-open .radio__panel {
  opacity: 1;
  transform: none;
  visibility: visible;
  transition: opacity .32s var(--ease), transform .5s var(--ease), visibility 0s;
}
.radio.is-open .radio__toggle { opacity: 0; transform: scale(.85); pointer-events: none; }

/* The panel's rows settle in one after another. */
.radio__panel > * {
  position: relative;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .3s var(--ease), transform .45s var(--ease);
}
.radio.is-open .radio__panel > * { opacity: 1; transform: none; }
.radio.is-open .radio__panel > :nth-child(2) { transition-delay: .05s; }
.radio.is-open .radio__panel > :nth-child(3) { transition-delay: .1s; }
.radio.is-open .radio__panel > :nth-child(4) { transition-delay: .15s; }
.radio.is-open .radio__panel > :nth-child(5) { transition-delay: .2s; }

.radio p { margin: 0; }
.radio__head { display: grid; grid-template-columns: 1fr auto; row-gap: 3px; }
.radio__name { color: var(--radio-accent); font-size: 13px; letter-spacing: .06em; }
.radio__close {
  grid-row: span 3;
  align-self: start;
  width: 28px;
  height: 28px;
  margin: -6px -8px 0 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--radio-blue);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform .3s var(--ease), background-color .2s;
}
.radio__close svg { width: 13px; height: 13px; }
@media (hover: hover) { .radio__close:hover { transform: rotate(90deg); } }
.radio__close:focus-visible { outline: 2px solid var(--radio-blue); outline-offset: 1px; }
.radio__rotation { font-size: 11px; letter-spacing: .14em; }
.radio__date {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--radio-soft);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .12em;
  font-variant-numeric: tabular-nums;
}
.radio__onair {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--radio-accent);
  opacity: 0;
  transition: opacity .4s var(--ease);
}
.radio__onair::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.radio.is-playing .radio__onair { opacity: 1; }
.radio.is-playing .radio__onair::before { animation: radio-breathe 2.4s ease-in-out infinite; }
@keyframes radio-breathe { 50% { opacity: .35; } }

.radio__section { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--radio-line); }
.radio__label { margin-bottom: 8px !important; color: var(--radio-soft); font-size: 10px; letter-spacing: .16em; }

/* Track of the day */
.radio__track {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.radio__cover { width: 40px; height: 40px; border-radius: 4px; object-fit: cover; background: var(--radio-screen); }
.radio__track-text { min-width: 0; display: grid; gap: 2px; }
.radio__track-name,
.radio__track-artist { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.radio__track-name { font-size: 13px; }
.radio__track-artist { color: var(--radio-soft); font-size: 12px; font-weight: 500; }
.radio__play {
  width: 30px;
  height: 30px;
  border: 1px solid var(--radio-line);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--radio-accent);
  transition: border-color .25s, transform .3s var(--ease);
}
.radio__play svg { width: 10px; height: 10px; margin-left: 2px; }
@media (hover: hover) { .radio__track:hover .radio__play { border-color: var(--radio-accent); transform: scale(1.06); } }
.radio__track:focus-visible { outline: 2px solid var(--radio-blue); outline-offset: 4px; border-radius: 6px; }
.radio__track[aria-pressed="true"] .radio__play { border-color: var(--radio-accent); }

/* Spotify's own player, untouched */
.radio__player {
  position: relative;
  min-height: 152px;
  border-radius: 12px;
  overflow: hidden;
  background: color-mix(in srgb, var(--ink) 6%, transparent);
}
.radio__player iframe { display: block; border: 0; }
.radio__status {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 0 20px;
  color: var(--radio-soft);
  font-size: 11px;
  letter-spacing: .12em;
  text-align: center;
  pointer-events: none; /* never in the way of Spotify's controls */
  transition: opacity .3s;
}
.radio__status[hidden] { display: grid; opacity: 0; pointer-events: none; }
.radio__links { display: flex; justify-content: space-between; gap: 12px; margin-top: 9px !important; font-size: 10px; letter-spacing: .14em; }
.radio__links button,
.radio__links a {
  padding: 2px 0;
  border: 0;
  background: none;
  color: var(--radio-blue);
  font: inherit;
  letter-spacing: inherit;
  cursor: pointer;
  transition: opacity .2s;
}
.radio__links a { margin-left: auto; }
@media (hover: hover) { .radio__links :is(button, a):hover { opacity: .65; } }
.radio__links :is(button, a):focus-visible { outline: 2px solid var(--radio-blue); outline-offset: 2px; border-radius: 3px; }

/* Weather */
.radio__weather { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0; padding: 0; list-style: none; }
.radio__place { display: grid; gap: 4px; }
.radio__place-name { color: var(--radio-soft); font-size: 10px; letter-spacing: .14em; }
.radio__place-now { display: flex; align-items: center; gap: 7px; font-size: 16px; font-variant-numeric: tabular-nums; }
.radio__wx { width: 24px; height: 24px; flex: none; transition: opacity .4s var(--ease); }
.radio__wx.is-changing { opacity: 0; }
.radio__wx :is(path, line, circle) { fill: none; stroke: var(--radio-soft); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.radio__wx .wx-cloud { fill: var(--radio-solid); }
.radio__wx .wx-sun { stroke: var(--radio-sun); }
.radio__wx .wx-rain { stroke: var(--radio-blue); }
.radio__wx .wx-bolt { stroke: var(--radio-accent); }
.radio__wx .wx-snow { fill: var(--radio-blue); stroke: none; }
.radio__credit { margin-top: 9px !important; color: var(--radio-soft); font-size: 9px; font-weight: 500; letter-spacing: .08em; opacity: .8; }

/* ---------- Phones ---------- */

@media (max-width: 700px) {
  :root { --radio-gap: 12px; --radio-icon: 34px; }
  .radio__panel { padding: 14px 14px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .radio.is-playing .radio__ipod-arc { animation: none; }
  .radio.is-playing .radio__onair::before { animation: none; }
}
