/* Shared components. Screen-specific parts live in screens.css, the response table in grid.css */

.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: var(--space-5) var(--space-4) var(--space-6);
}

@media (min-width: 1024px) {
  .container {
    max-width: var(--container-max-wide);
  }
}

/* Grid children don't shrink below their content by default; cap the column so long URLs don't overflow */
.stack,
.stack-sm,
.card {
  grid-template-columns: minmax(0, 1fr);
}

.stack {
  display: grid;
  gap: var(--space-4);
}

.stack-sm {
  display: grid;
  gap: var(--space-2);
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: end;
}

.row > label {
  flex: 1 1 160px;
}

/* Header */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-block: var(--space-4) 0;
}

.site-footer {
  padding-block: var(--space-6) var(--space-5);
  font-size: 0.8125rem;
  color: var(--color-muted);
}

.site-footer h2 {
  font-size: 0.8125rem;
  margin-block-end: var(--space-2);
}

.site-footer ul {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-3);
  padding: 0;
  margin: 0;
  list-style: none;
}

.site-footer-legal {
  margin-block-start: var(--space-4);
}

.site-footer a {
  color: inherit;
  display: inline-block;
  padding-block: var(--space-1);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.site-header a {
  text-decoration: none;
  font-size: 0.875rem;
  padding: var(--space-3) var(--space-1);
}

/* The panel hangs from the header, not the bell, so it stays on screen at phone width. */
.site-header {
  position: relative;
}

.announcements-bell {
  position: relative;
  display: inline-flex;
  padding: var(--space-2);
  border-radius: var(--radius-button);
  color: var(--color-text);
  cursor: pointer;
  list-style: none;
}

.announcements-bell::-webkit-details-marker {
  display: none;
}

.announcements-dot {
  position: absolute;
  inset-block-start: 6px;
  inset-inline-end: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-primary);
}

.announcements-panel {
  position: absolute;
  inset-block-start: 100%;
  inset-inline-end: var(--space-4);
  z-index: 10;
  width: min(320px, calc(100% - 2 * var(--space-4)));
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.12);
}

.announcements-panel h2 {
  margin: 0 0 var(--space-2);
  font-size: 0.875rem;
}

.announcements-panel ul {
  display: grid;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.announcements-panel time {
  display: block;
  font-size: 0.75rem;
  color: var(--color-muted);
}

.announcements-panel p,
.site-header .announcements-panel a {
  margin: 0;
  padding: 0;
  font-size: 0.875rem;
}

.site-header .logo {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0;
  color: var(--color-text);
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.logo-mark {
  width: 32px;
  height: 32px;
}

/* Headings */
.page-head {
  position: relative;
  display: grid;
  gap: 6px;
  padding: 0 var(--space-1);
}

.page-head .lead {
  font-size: 0.875rem;
  line-height: 1.7;
  color: var(--color-muted);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  padding: var(--space-1) 10px;
  border-radius: 999px;
  background: var(--color-surface);
  font-size: 0.75rem;
  font-weight: 700;
}

.chip-muted {
  color: var(--color-muted);
}

.chip-soft {
  background: var(--color-soft);
}

.chip-strong {
  background: var(--color-text);
  color: var(--color-bg);
}

/* Cards */
.card {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.card-flush {
  padding-inline: 0;
}

.card-flush > :not(.grid-scroll) {
  padding-inline: var(--space-4);
}

.card-warning {
  background: var(--color-warn-bg);
  border: 1.5px solid var(--color-warn-border);
  color: var(--color-warn-text);
}

.card-soft {
  background: var(--color-soft);
  border-color: transparent;
}

.card-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
}

.muted {
  color: var(--color-muted);
  font-weight: 400;
}

.note {
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--color-muted);
  text-align: center;
}

.notice {
  padding: var(--space-3) var(--space-4);
  background: var(--color-soft);
  border-radius: var(--radius-md);
}

/* Buttons (a.button shares the look) */
button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0 var(--space-5);
  border: 0;
  border-radius: var(--radius-button);
  background: var(--color-primary);
  color: var(--color-primary-contrast);
  font-size: 0.9375rem;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition:
    transform var(--transition-fast),
    filter var(--transition-fast);
}

button:hover,
.button:hover {
  filter: brightness(1.05);
  color: var(--color-primary-contrast);
}

button:active,
.button:active {
  transform: translateY(1px);
}

.button-lg {
  min-height: var(--control-height-lg);
  font-size: 1.0625rem;
}

.button-block {
  width: 100%;
}

button.secondary,
.button.secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1.5px solid var(--color-border);
  font-weight: 700;
}

button.ghost,
.button.ghost {
  background: transparent;
  color: var(--color-muted);
  font-weight: 700;
}

button.ghost.danger {
  color: var(--color-no);
}

.button-line {
  background: var(--color-line);
}

.button-x {
  background: var(--color-x);
}

.button-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: var(--space-2);
}

.button-grid > * {
  min-height: 52px;
}

/* URL copy box */
.url-box {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--control-height);
  padding: 0 6px 0 14px;
  background: var(--color-soft);
  border-radius: var(--radius-sm);
  color: var(--color-text);
}

.url-box a {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: inherit;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  text-decoration: none;
  overflow-wrap: normal;
}

.url-box button {
  min-height: 44px;
  padding: 0 14px;
  border-radius: 10px;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.875rem;
  font-weight: 700;
}

.card-warning .url-box {
  background: var(--color-surface);
}

.card-warning .url-box button {
  background: var(--color-soft);
}

/* Hidden without JS; share.js removes `hidden` */
[data-copy][hidden],
[data-share][hidden],
[data-push] button[hidden],
[data-passkey][hidden] {
  display: none;
}

/* passkey.js fills the status line; empty, it would only add a gap. */
[data-passkey-status]:empty {
  display: none;
}

.form-error {
  margin: 0;
  color: var(--color-no);
  font-weight: 700;
}

.form-error:empty {
  display: none;
}

/* In a flex form row the message takes a line of its own above the controls */
form > .form-error {
  flex-basis: 100%;
}

.plain-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Chip-shaped toggle button; aria-pressed shows the selected state */
.toggle-chip {
  min-height: 36px;
  padding: 0 var(--space-3);
  border: 1.5px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.8125rem;
  font-weight: 700;
}

.toggle-chip[aria-pressed="true"] {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: #ffffff;
}

/* Preference chips: checkbox or radio inside a pill-shaped label */
.pref-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.pref-chip {
  position: relative;
  display: inline-flex;
  cursor: pointer;
}

.pref-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.pref-chip span {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 var(--space-3);
  border: 1.5px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-surface);
  font-size: 0.8125rem;
  font-weight: 700;
}

.pref-chip input:checked + span {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: #ffffff;
}

.pref-chip input:focus-visible + span {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
}

.prefs legend,
.pref-topic-label {
  font-size: 0.9375rem;
  font-weight: 800;
}

.prefs-ask summary {
  cursor: pointer;
  font-weight: 700;
}

.prefs-ask[open] summary {
  margin-bottom: var(--space-2);
}

.pref-summary {
  display: grid;
  gap: var(--space-1);
}

/* Loading: ○△× chatting around an irori; shown by public/js/loading.js only when a request is slow */
.loading {
  position: fixed;
  inset-inline: 0;
  bottom: calc(var(--space-4) + env(safe-area-inset-bottom));
  z-index: 50;
  width: min(300px, calc(100% - 2 * var(--space-4)));
  margin-inline: auto;
  padding: var(--space-3) var(--space-4) var(--space-2);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px rgb(45 42 50 / 0.14);
  text-align: center;
  /* Never blocks the page it sits over */
  pointer-events: none;
  animation: lr-in 200ms ease-out;
}

.loading[hidden] {
  display: none;
}

.loading-scene {
  display: block;
  width: 100%;
  height: auto;
}

.lr-bubble-fill {
  fill: #fff;
  stroke: #d8cfc4;
  stroke-width: 1.5;
}

.loading-caption {
  position: relative;
  height: 1.5em;
  margin: var(--space-1) 0 0;
  color: var(--color-muted);
  font-size: 0.875rem;
  font-weight: 700;
}

.loading-caption span {
  position: absolute;
  inset: 0;
  opacity: 0;
}

/* Without motion the first caption stays and every bubble shows at once */
.loading-caption .lr-turn-1 {
  opacity: 1;
}

.lr-char,
.lr-bubble,
.lr-flame,
.lr-eyes {
  transform-box: fill-box;
  transform-origin: center bottom;
}

.lr-eyes {
  transform-origin: center;
  animation: lr-blink 3.6s infinite;
}

.lr-char {
  animation: lr-talk 4.5s infinite both;
}

.lr-bubble,
.loading-caption span {
  animation: lr-say 4.5s infinite both;
}

.loading-caption span {
  animation-name: lr-caption;
}

.lr-turn-2,
.lr-turn-2 .lr-bubble,
.loading-caption .lr-turn-2 {
  animation-delay: 1.5s;
}

.lr-turn-3,
.lr-turn-3 .lr-bubble,
.loading-caption .lr-turn-3 {
  animation-delay: 3s;
}

.lr-flame {
  animation: lr-flicker 0.5s ease-in-out infinite alternate;
}

.lr-spark {
  animation: lr-spark 1.8s ease-out infinite;
}

.lr-glow {
  transform-box: fill-box;
  transform-origin: center;
  animation: lr-glow 2.4s ease-in-out infinite alternate;
}

@keyframes lr-glow {
  to {
    opacity: 0.55;
    transform: scale(1.08);
  }
}

.lr-spark-late {
  animation-delay: 0.9s;
}

@keyframes lr-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@keyframes lr-talk {
  0%,
  12%,
  24%,
  100% {
    transform: translateY(0);
  }
  6% {
    transform: translateY(-5px);
  }
  18% {
    transform: translateY(-3px);
  }
}

@keyframes lr-say {
  0% {
    opacity: 0;
    transform: scale(0.6);
  }
  5%,
  28% {
    opacity: 1;
    transform: scale(1);
  }
  33%,
  100% {
    opacity: 0;
    transform: scale(1);
  }
}

@keyframes lr-caption {
  0%,
  33.4%,
  100% {
    opacity: 0;
  }
  2%,
  30% {
    opacity: 1;
  }
}

@keyframes lr-blink {
  0%,
  92%,
  100% {
    transform: scaleY(1);
  }
  95% {
    transform: scaleY(0.1);
  }
}

@keyframes lr-flicker {
  from {
    transform: scale(1, 1);
  }
  to {
    transform: scale(0.9, 1.1);
  }
}

@keyframes lr-spark {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-20px);
  }
}

/* Review stars: radios in ascending order, so a star fills when it or a later one is checked. */
.stars {
  display: flex;
  gap: var(--space-1);
  border: 0;
  padding: 0;
  margin: 0;
}

.stars legend {
  margin-bottom: var(--space-1);
}

.star {
  position: relative;
  font-size: 2.25rem;
  line-height: 1;
  cursor: pointer;
  color: var(--color-border);
  -webkit-text-stroke: 1px var(--color-maybe);
}

.star:has(input:checked),
.star:has(~ .star input:checked),
.stars:hover .star:hover,
.stars:hover .star:has(~ .star:hover) {
  color: var(--color-maybe-bar);
}

.stars:hover .star:hover ~ .star {
  color: var(--color-border);
}

.star:has(input:focus-visible) {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
