/* SketchPhone Shared Design System — Cobalt Drafting Desk & Drawing Paper */

:root {
  --desk-bg: #13203b;
  --desk-surface: #1b2c4e;
  --desk-elevated: #233862;
  --desk-border: #314b7d;

  --paper: #fffdf7;
  --paper-tint: #f5efe0;
  --ink: #141b2d;
  --ink-muted: #4b5874;
  --text-light: #f8fafc;
  --text-dim: #a9bbd8;

  --sun: #ffb703;
  --sun-hover: #ffc738;
  --sun-ink: #141b2d;
  --coral: #fb5607;
  --coral-hover: #ff6e2b;
  --mint: #06d6a0;
  --mint-dark: #059669;
  --sky: #1982c4;
  --danger: #e63946;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-hard: 0 4px 0 #0b1426;
  --shadow-hard-lg: 0 6px 0 #0b1426;
  --border-ink: 3px solid var(--ink);

  --font-display: "Fredoka", ui-rounded, "Nunito", system-ui, -apple-system, sans-serif;
  --font-sans: "Plus Jakarta Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --target-size: 28px;
}

@media (pointer: coarse) {
  :root {
    --target-size: 44px;
  }
}

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

html {
  font-size: 16px;
  scroll-padding-bottom: calc(4rem + env(safe-area-inset-bottom, 0px));
}

body {
  margin: 0;
  min-block-size: 100dvh;
  font-family: var(--font-sans);
  color: var(--text-light);
  background-color: var(--desk-bg);
  background-image: radial-gradient(rgba(255, 255, 255, 0.08) 1.5px, transparent 1.5px);
  background-size: 24px 24px;
  line-height: 1.5;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-display);
  margin: 0;
  line-height: 1.15;
  text-wrap: balance;
}

p, li {
  text-wrap: pretty;
}

img, video, svg {
  max-inline-size: 100%;
  display: block;
}

:where(a, code) {
  overflow-wrap: anywhere;
}

:where(button, select, textarea, input:not([type="checkbox"], [type="radio"]), [role="button"], nav a) {
  min-block-size: var(--target-size);
  min-inline-size: var(--target-size);
  font-family: inherit;
}

:where(button, a, input, select, textarea, [tabindex]):focus-visible {
  outline: 3px solid var(--sun);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden {
  display: none !important;
}

/* Brand mark */
.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--paper);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--sun);
  border: 3px solid var(--ink);
  box-shadow: 0 3px 0 var(--ink);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

/* Paper Cards */
.paper-card {
  background: var(--paper);
  color: var(--ink);
  border: var(--border-ink);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-hard-lg);
}

.desk-card {
  background: var(--desk-surface);
  color: var(--text-light);
  border: 2px solid var(--desk-border);
  border-radius: var(--radius-md);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  border: var(--border-ink);
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.1;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 4px 0 var(--ink);
  transition: transform 80ms ease, box-shadow 80ms ease, background-color 120ms ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 5px 0 var(--ink);
}

.btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--ink);
}

.btn:disabled {
  opacity: 0.52;
  cursor: not-allowed;
  box-shadow: 0 2px 0 var(--ink);
}

.btn-primary {
  background: var(--sun);
  color: var(--sun-ink);
}
.btn-primary:hover:not(:disabled) {
  background: var(--sun-hover);
}

.btn-success {
  background: var(--mint);
  color: var(--ink);
}

.btn-danger {
  background: var(--danger);
  color: #ffffff;
}

.btn-secondary {
  background: var(--paper);
  color: var(--ink);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--paper-tint);
}

.btn-ghost {
  background: var(--desk-elevated);
  color: var(--text-light);
  border-color: var(--desk-border);
  box-shadow: 0 3px 0 #0b1426;
}
.btn-ghost:hover:not(:disabled) {
  background: #2c4678;
}

.btn-sm {
  padding: 0.42rem 0.85rem;
  font-size: 0.9rem;
  border-width: 2.5px;
  box-shadow: 0 3px 0 var(--ink);
}

/* Inputs */
.field-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 0.35rem;
}

.field-input,
.field-select,
.field-textarea {
  width: 100%;
  padding: 0.72rem 0.95rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  background: #ffffff;
  border: 2.5px solid var(--ink);
  border-radius: var(--radius-sm);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.field-input:focus,
.field-select:focus,
.field-textarea:focus {
  border-color: var(--sky);
  box-shadow: 0 0 0 3px rgba(25, 130, 196, 0.25);
  outline: none;
}

/* Avatars */
.avatar-badge {
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  border: 2.5px solid var(--ink);
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 2px 0 rgba(11, 20, 38, 0.35);
}

/* Status pills */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.32rem 0.78rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  border: 2px solid var(--desk-border);
  background: var(--desk-surface);
  color: var(--text-light);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--mint);
  flex-shrink: 0;
}

.status-dot.offline {
  background: var(--coral);
}

.status-dot.idle {
  background: var(--text-dim);
}

/* Connection banner (spotty Wi-Fi feedback) */
.net-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 900;
  padding: 0.5rem 1rem;
  text-align: center;
  font-weight: 700;
  font-size: 0.9rem;
  background: var(--coral);
  color: #ffffff;
  border-bottom: 2px solid var(--ink);
}

/* Native <dialog> — per modern-web-guidance */
dialog.app-dialog {
  padding: 0;
  border: var(--border-ink);
  border-radius: var(--radius-lg);
  background: var(--paper);
  color: var(--ink);
  max-width: min(440px, calc(100vw - 2rem));
  width: 100%;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

dialog.app-dialog[open] {
  display: block;
}

dialog:modal {
  overscroll-behavior: contain;
}

dialog::backdrop {
  background: rgba(10, 18, 34, 0.72);
  backdrop-filter: blur(3px);
  overflow: hidden;
  overscroll-behavior: contain;
}

.dialog-inner {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.dialog-title {
  font-size: 1.35rem;
  color: var(--ink);
}

.dialog-body {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.98rem;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

/* Toasts */
.toast-region {
  position: fixed;
  bottom: max(1rem, env(safe-area-inset-bottom, 0px));
  right: 1rem;
  z-index: 950;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(360px, calc(100vw - 2rem));
  pointer-events: none;
}

.toast {
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
  border: 2.5px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.92rem;
  box-shadow: var(--shadow-hard);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast-error {
  background: #fee2e2;
  border-color: var(--danger);
  color: #7f1d1d;
}

.toast-success {
  background: #d1fae5;
  border-color: var(--mint-dark);
  color: #064e3b;
}

.toast-out {
  opacity: 0;
  transform: translateY(6px);
}

/* Album card styles shared by Host & Player */
.album-entry {
  background: var(--paper);
  color: var(--ink);
  border: var(--border-ink);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-hard);
  padding: 0.95rem 1.1rem;
  animation: cardPop 240ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.album-entry-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  margin-bottom: 0.6rem;
}

.album-author {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 700;
  font-size: 0.95rem;
}

.album-kind-tag {
  font-size: 0.78rem;
  font-weight: 800;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  border: 2px solid var(--ink);
}

.album-kind-tag.prompt {
  background: #ffe8cc;
  color: #9a3412;
}

.album-kind-tag.drawing {
  background: #dbeafe;
  color: #1e40af;
}

.album-kind-tag.guess {
  background: #d1fae5;
  color: #065f46;
}

.album-text {
  font-family: var(--font-display);
  font-size: clamp(1.15rem, 0.9rem + 1vw, 1.65rem);
  font-weight: 600;
  color: var(--ink);
  margin: 0.25rem 0;
}

.album-drawing-frame {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #ffffff;
  border: 2.5px solid var(--ink);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: grid;
  place-items: center;
}

.album-drawing-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

@keyframes cardPop {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
