:root {
  color-scheme: light;
  --ink: #211a28;
  --paper: #e9ddff;
  --cream: #fff9eb;
  --card: #ffdc91;
  --tomato: #b33326;
  --mint: #dffc9c;
  --mono: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  font-family: system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body { margin: 0; }
button { color: inherit; font: inherit; }
button:focus-visible { outline: 3px solid #57319c; outline-offset: 5px; }
::selection { background: var(--ink); color: var(--mint); }

.page {
  width: min(100% - clamp(2rem, 8vw, 8rem), 78rem);
  margin-inline: auto;
}

.masthead, .footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-family: var(--mono);
}

.masthead {
  min-height: 5rem;
  border-bottom: 2px solid var(--ink);
  padding-block: .75rem;
}

.wordmark, .site-status {
  display: inline-flex;
  align-items: center;
  font-size: clamp(.65rem, 1.5vw, .88rem);
  font-weight: 800;
  letter-spacing: .025em;
  white-space: nowrap;
}

.wordmark { gap: .7rem; }

.document-icon {
  width: 1.1rem;
  height: 1.35rem;
  display: inline-block;
  position: relative;
  border: 2px solid var(--ink);
  border-radius: 2px;
  background: #ff8064;
  box-shadow: 2px 2px var(--ink);
  transform: rotate(-12deg);
}

.document-icon::after {
  content: '';
  position: absolute;
  width: .46rem;
  height: 2px;
  background: var(--ink);
  box-shadow: 0 4px var(--ink);
  top: .32rem;
  left: .18rem;
}

.site-status {
  gap: .5rem;
  padding: .5rem .7rem;
  border: 1.5px solid var(--ink);
  border-radius: 99px;
  background: var(--cream);
}

.site-status > span, .on-air > span {
  width: .56rem;
  height: .56rem;
  border-radius: 50%;
  background: #d44730;
}

.hero {
  display: grid;
  grid-template-areas: 'intro comic' 'controls comic';
  grid-template-columns: minmax(0, .82fr) minmax(0, 1.18fr);
  grid-template-rows: 1fr auto;
  column-gap: clamp(1.5rem, 4vw, 3.6rem);
  row-gap: 1.25rem;
  align-items: center;
  padding-block: clamp(2rem, 5vw, 4.5rem);
}

.intro { grid-area: intro; align-self: end; }

.name {
  margin: 0 0 .75rem;
  font: 800 clamp(.72rem, 1.3vw, .9rem)/1.2 var(--mono);
  letter-spacing: .19em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: Impact, 'Avenir Next Condensed', 'Arial Narrow', system-ui, sans-serif;
  font-weight: 900;
  font-size: clamp(3rem, 6.7vw, 6rem);
  letter-spacing: -.037em;
  line-height: .91;
  text-transform: uppercase;
}

h1 span { display: block; }
.headline-punch { color: var(--tomato); }

.setup {
  max-width: 25rem;
  margin: 1.2rem 0 0;
  font-size: clamp(1rem, 1.5vw, 1.14rem);
  font-weight: 550;
  line-height: 1.55;
  text-wrap: pretty;
}

.comic {
  grid-area: comic;
  margin: 0 7px 7px 0;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: var(--card);
  box-shadow: 7px 7px var(--ink);
  overflow: hidden;
}

.comic-top, figcaption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .85rem clamp(.7rem, 2.1vw, 1.3rem);
}

.comic-top {
  min-height: 2.75rem;
  background: var(--ink);
  color: var(--cream);
  font: 800 clamp(.62rem, 1vw, .78rem)/1.1 var(--mono);
  letter-spacing: .08em;
  text-transform: uppercase;
}

.on-air { display: inline-flex; align-items: center; gap: .45rem; color: var(--mint); }
.on-air > span { background: var(--mint); animation: pulse 2.8s ease-in-out infinite; }

.scene {
  aspect-ratio: 1.28;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background: radial-gradient(ellipse at 56% 53%, #fff0b9 15%, #ffdc91 72%, #fac36b 100%);
}

.scene::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(#693d23 1px, transparent 1.3px) 0 0 / 7px 7px;
  opacity: .22;
  mask-image: radial-gradient(ellipse at center, transparent 22%, black 100%);
}

.cartoon {
  position: absolute;
  bottom: 1%;
  left: 2%;
  width: 96%;
  transform-origin: 50% 93%;
  user-select: none;
  filter: drop-shadow(1px 5px 0 #63381b38);
  animation: wait 7s ease-in-out infinite;
}

.cartoon img { display: block; width: 100%; height: auto; }

.screen-glow {
  position: absolute;
  left: 18%;
  top: 28%;
  width: 24%;
  height: 29%;
  background: radial-gradient(ellipse, #dffc9c40, transparent 68%);
  animation: pulse 3.4s ease-in-out infinite;
}

.bubble {
  position: absolute;
  top: 8%;
  left: 46%;
  max-width: 52%;
  z-index: 1;
  padding: .5em .83em;
  border: 2px solid var(--ink);
  border-radius: 44% 52% 43% 44% / 45% 40% 52% 46%;
  background: var(--cream);
  box-shadow: 2px 2px var(--ink);
  font-size: clamp(.78rem, 1.7vw, 1.26rem);
  font-weight: 850;
  text-align: center;
  line-height: 1.15;
  transform: rotate(-7deg);
  animation: float 4.5s ease-in-out infinite;
}

.bubble::after {
  content: '';
  position: absolute;
  bottom: -8px;
  right: 23%;
  width: 13px;
  height: 12px;
  background: var(--cream);
  border-right: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  transform: skew(16deg, 12deg) rotate(36deg);
}

.ellipsis { animation: pulse 2.8s ease-in-out infinite; }

.spark {
  position: absolute;
  z-index: 1;
  color: #89522a;
  font-size: clamp(.8rem, 2.2vw, 2rem);
  pointer-events: none;
  animation: twinkle 5s ease-in-out infinite;
}

.spark-one { left: 13%; top: 12%; }
.spark-two { left: 24%; top: 18%; animation-delay: -1.8s; }
.spark-three { right: 7%; top: 30%; animation-delay: -3.2s; }

.incoming {
  position: absolute;
  opacity: 0;
  top: 28%;
  left: 30%;
  color: var(--ink);
  background: var(--mint);
  border: 2px solid currentColor;
  border-radius: .18rem;
  width: 1.35em;
  text-align: center;
  font: 900 clamp(1rem, 3vw, 1.8rem)/1.5 var(--mono);
}

figcaption {
  border-top: 2px solid var(--ink);
  background: var(--cream);
  min-height: 3.55rem;
  flex-wrap: wrap;
  gap: .25em 1em;
}

.caption-label {
  font: 800 clamp(.62rem, 1vw, .78rem)/1.1 var(--mono);
  letter-spacing: .06em;
  text-transform: uppercase;
}

figcaption strong { font-size: clamp(.8rem, 1.5vw, 1.05rem); }

.controls { grid-area: controls; align-self: start; }

.check-button {
  min-width: 12rem;
  min-height: 3.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .65rem;
  padding: .6rem 1rem;
  background: var(--mint);
  border: 2px solid var(--ink);
  border-radius: 6px;
  box-shadow: 3px 3px var(--ink);
  font-size: 1rem;
  font-weight: 850;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, background-color .15s ease;
}

.check-button:hover { background: #eeffbb; transform: translate(-1px, -1px); box-shadow: 4px 4px var(--ink); }
.check-button:active { transform: translate(2px, 2px); box-shadow: 1px 1px var(--ink); }
.check-button[aria-disabled='true'] { cursor: wait; }
.refresh-icon { font-size: 1.35em; line-height: 1; }
.check-button[aria-disabled='true'] .refresh-icon { animation: spin .55s linear infinite; }

.inbox-result {
  min-height: 2.65em;
  max-width: 37ch;
  margin: .9rem 0 0;
  font: 700 .77rem/1.45 var(--mono);
  color: #533f62;
}

.footer {
  border-top: 1px solid #211a2860;
  min-height: 3.4rem;
  padding-block: .25rem;
  font-size: .75rem;
  color: #533f62;
}

.footer p { margin: .45rem 0; }

.motion-toggle {
  display: inline-flex;
  align-items: center;
  gap: .38rem;
  padding: .4rem .12rem;
  min-height: 2.75rem;
  border: 0;
  background: none;
  cursor: pointer;
  white-space: nowrap;
}

.motion-toggle:hover { text-decoration: underline; text-underline-offset: .2em; }

.comic.is-checking .cartoon { animation: lean-in .55s ease-in-out; }
.comic.is-checking .incoming { animation: false-alarm .55s ease-in-out; }

@keyframes pulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
@keyframes twinkle { 0%, 100% { opacity: .15; transform: scale(.72) rotate(-12deg); } 50% { opacity: .9; transform: scale(1) rotate(12deg); } }
@keyframes float { 0%, 100% { transform: translateY(0) rotate(-7deg); } 50% { transform: translateY(-6px) rotate(-4deg); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes wait { 0%, 100% { transform: rotate(0); } 50% { transform: translateY(-1px) rotate(-.45deg); } }
@keyframes lean-in { 0%, 100% { transform: rotate(0); } 40% { transform: rotate(-2deg) scale(1.018); } }
@keyframes false-alarm { 0%, 100% { opacity: 0; transform: translate(1.2rem, .6rem) rotate(12deg) scale(.5); } 45% { opacity: 1; transform: translate(-.2rem, -.85rem) rotate(-13deg) scale(1); } }

:root[data-motion='off'] *, :root[data-motion='off'] *::before, :root[data-motion='off'] *::after {
  animation: none !important;
  transition: none !important;
}

@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion='on']) *,
  :root:not([data-motion='on']) *::before,
  :root:not([data-motion='on']) *::after {
    animation: none !important;
    transition: none !important;
  }
}

@media (max-width: 740px) {
  .page { width: min(100% - 2rem, 37rem); }
  .masthead { min-height: 3.7rem; }
  .hero {
    grid-template-areas: 'intro' 'comic' 'controls';
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    gap: 1.3rem;
    padding-block: 1.55rem 1.5rem;
  }
  h1 { font-size: clamp(3rem, 11vw, 5.5rem); }
  .setup { margin-top: .85rem; }
  .bubble { font-size: clamp(.75rem, 3vw, 1.15rem); }
  .scene { aspect-ratio: 1.35; }
  .spark { font-size: clamp(.9rem, 4vw, 1.6rem); }
  .comic-top, figcaption { min-height: 2.45rem; padding-block: .62rem; }
  .inbox-result { min-height: 2.4em; }
}

@media (max-width: 350px) {
  .masthead { gap: .45rem; }
  .wordmark { gap: .45rem; }
  .site-status { padding: .45rem .5rem; }
}
