/* The controls: buttons, fields, segmented tabs, dialogs and sheets, menus and snacks. */

/* ---------- Buttons ---------- */

.button {
  --button-bg: var(--ink-3);
  --button-fg: var(--bone);
  --button-border: var(--line-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 22px;
  border-radius: var(--r-1);
  border: 1px solid var(--button-border);
  background: var(--button-bg);
  color: var(--button-fg);
  font-weight: 650;
  font-size: 16px;
  letter-spacing: -0.005em;
  text-decoration: none;
  white-space: nowrap;
  transition:
    transform 0.15s var(--ease-out),
    background 0.2s,
    border-color 0.2s,
    box-shadow 0.25s,
    opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.button:hover {
  --button-bg: var(--ink-4);
  --button-border: var(--line-3);
}
.button:active {
  transform: scale(0.97);
}
.button[disabled],
.button[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}
.button-acid {
  --button-bg: var(--acid);
  --button-fg: var(--acid-ink);
  --button-border: transparent;
  box-shadow: 0 0 0 0 var(--acid-glow);
}
.button-acid:hover {
  --button-bg: #e1ff5c;
  --button-border: transparent;
  box-shadow: 0 0 32px var(--acid-glow);
}
.button-ghost {
  --button-bg: transparent;
  --button-border: var(--line-2);
}
.button-danger {
  --button-bg: rgba(255, 90, 79, 0.12);
  --button-fg: #ffb3ad;
  --button-border: rgba(255, 90, 79, 0.4);
}
.button-danger:hover {
  --button-bg: rgba(255, 90, 79, 0.2);
  --button-border: rgba(255, 90, 79, 0.7);
}
.button-small {
  min-height: 40px;
  padding: 0 16px;
  font-size: 14px;
}
.button-block {
  width: 100%;
}
.button .spinner {
  width: 18px;
  height: 18px;
}

.spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.7s linear infinite;
  flex: none;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.link-button {
  display: inline-block;
  border: 0;
  background: none;
  padding: 12px 0;
  margin: -12px 0;
  color: var(--acid);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

/* ---------- Fields ---------- */

.field {
  display: grid;
  gap: 8px;
}
.field-label {
  font: 600 12px/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--mute);
}
.input {
  width: 100%;
  min-height: 52px;
  padding: 14px 16px;
  border-radius: var(--radius-small);
  border: 1px solid var(--line-2);
  background: var(--ink-2);
  color: var(--bone);
  font-size: 17px;
  transition:
    border-color 0.2s,
    box-shadow 0.2s,
    background 0.2s;
  -webkit-appearance: none;
  appearance: none;
}
textarea.input {
  resize: vertical;
  min-height: 96px;
  line-height: 1.45;
}
.input::placeholder {
  color: var(--dim);
}
.input:hover {
  border-color: var(--line-3);
}
.input:focus {
  outline: none;
  border-color: var(--acid);
  box-shadow: 0 0 0 4px rgba(210, 255, 31, 0.14);
  background: var(--ink-3);
}
.input[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px rgba(255, 90, 79, 0.14);
}
.field-note {
  font-size: 13px;
  color: var(--mute);
  min-height: 1.3em;
}
.field-note.is-bad {
  color: #ffb3ad;
}
.field-note.is-good {
  color: var(--acid);
}
.input-prefix {
  position: relative;
}
.input-prefix > span {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--mute);
  font-weight: 600;
  pointer-events: none;
}
.input-prefix > .input {
  padding-left: 34px;
}
select.input {
  background-image:
    linear-gradient(45deg, transparent 50%, var(--mute) 50%), linear-gradient(135deg, var(--mute) 50%, transparent 50%);
  background-position:
    calc(100% - 22px) 50%,
    calc(100% - 16px) 50%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
  padding-right: 40px;
}

/* ---------- Dialogs and sheets ---------- */

dialog.sheet {
  width: min(560px, calc(100vw - 24px));
  max-height: min(88dvh, 860px);
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: var(--r-3);
  background:
    radial-gradient(600px 300px at 100% 0%, rgba(255, 61, 127, 0.1), transparent 60%),
    radial-gradient(500px 300px at 0% 100%, rgba(210, 255, 31, 0.07), transparent 60%), var(--ink-2);
  color: var(--bone);
  box-shadow:
    0 40px 120px rgba(0, 0, 0, 0.7),
    0 0 0 1px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}
dialog.sheet[open] {
  animation: sheet-in 0.42s var(--ease-out);
  display: flex;
  flex-direction: column;
}
dialog.sheet.is-closing {
  animation: sheet-out 0.22s ease-in forwards;
}
dialog.sheet::backdrop {
  background: rgba(4, 3, 6, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fade-in 0.3s ease;
}
.sheet-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 22px 22px 6px;
}
.sheet-title {
  margin: 0;
  font-size: clamp(26px, 6vw, 34px);
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.sheet-title em {
  font-family: var(--serif);
  font-weight: 500;
  font-size-adjust: 0.47;
  font-weight: 400;
  font-style: italic;
  letter-spacing: 0;
}
.sheet-close {
  margin-left: auto;
  flex: none;
}
.sheet-body {
  padding: 12px 22px 22px;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: grid;
  gap: 18px;
}
.sheet-lede {
  font-family: var(--read);
  font-weight: 400;
  font-optical-sizing: auto;
  margin: 0;
  color: var(--bone-2);
  font-size: 16px;
}
.sheet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.sheet-actions .button {
  flex: 1 1 auto;
}
.fine {
  margin: 0;
  color: var(--mute);
  font-size: 13px;
  line-height: 1.5;
}

@keyframes sheet-in {
  from {
    opacity: 0;
    transform: translateY(28px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes sheet-out {
  to {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
}
@keyframes pop {
  0% {
    transform: scale(0.4);
  }
  60% {
    transform: scale(1.15);
  }
  100% {
    transform: scale(1);
  }
}

.segmented {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  border-radius: var(--r-1);
  background: var(--ink-3);
  border: 1px solid var(--line);
}
.segmented button,
.segmented a {
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--r-1);
  border: 0;
  background: transparent;
  color: var(--mute);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  transition:
    background 0.2s,
    color 0.2s;
  white-space: nowrap;
}
.segmented button:hover,
.segmented a:hover {
  color: var(--bone);
}
.segmented [aria-selected="true"],
.segmented [aria-current="true"] {
  background: var(--bone);
  color: var(--ink);
}

/* ---------- Menus ---------- */

.menu {
  position: fixed;
  z-index: 120;
  min-width: 220px;
  padding: 6px;
  border-radius: var(--r-3);
  border: 1px solid var(--line-2);
  background: rgba(22, 19, 29, 0.97);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
  animation: menu-in 0.18s var(--ease-out);
  transform-origin: top right;
}
.menu button {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--r-2);
  background: transparent;
  text-align: left;
  font-size: 15px;
  color: var(--bone-2);
}
.menu button:hover,
.menu button:focus-visible {
  background: var(--ink-4);
  color: var(--bone);
  outline: none;
}
.menu .menu-danger {
  color: #ffb3ad;
}
.menu hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 6px 4px;
}
@keyframes menu-in {
  from {
    opacity: 0;
    transform: scale(0.94) translateY(-4px);
  }
}

/* ---------- Snacks ---------- */

.snacks {
  position: fixed;
  left: 50%;
  bottom: calc(20px + var(--dock-height) + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 150;
  display: grid;
  gap: 8px;
  width: min(460px, calc(100vw - 32px));
  pointer-events: none;
}
.snack {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--r-3);
  background: var(--bone);
  color: var(--ink);
  font-weight: 600;
  font-size: 15px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  animation: snack-in 0.4s var(--ease-spring);
}
.snack.is-bad {
  background: #2a0f12;
  color: #ffd2ce;
  border: 1px solid rgba(255, 90, 79, 0.5);
}
.snack.is-gold {
  background: linear-gradient(120deg, #ffe27f, var(--gold));
}
.snack.is-leaving {
  animation: snack-out 0.25s ease-in forwards;
}
.snack button {
  margin-left: auto;
  border: 0;
  background: none;
  font-weight: 800;
  color: inherit;
  text-decoration: underline;
  padding: 4px;
}
@keyframes snack-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.96);
  }
}
@keyframes snack-out {
  to {
    opacity: 0;
    transform: translateY(10px);
  }
}

.offline {
  position: sticky;
  top: 0;
  z-index: 60;
  padding: 10px var(--gutter);
  background: var(--hot);
  color: #fff;
  text-align: center;
  font-weight: 700;
  font-size: 14px;
}
