/* ============================================================
   BASE.CSS — Pirate Game  |  Dark Nautical Theme
   Mobile-first. CSS custom properties throughout.
   ============================================================ */

/* @import url("https://fonts.googleapis.com/css2?family=Cinzel:wght@600;700;900&family=DM+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap"); */

/* ── Design tokens  (Light tropical / beach palette) ─────── */
:root {
  /* Palette — drawn from background.png */
  --ink: #3a2e1e; /* dark bark text       */
  --deep: #2c2318;
  --surface: rgba(253, 248, 239, 0.82); /* frosted sand  */
  --raised: rgba(255, 253, 245, 0.92);
  --border: rgba(139, 99, 64, 0.18);
  --border-hi: rgba(139, 99, 64, 0.38);

  --gold: rgba(200, 134, 10, 1); /* warm amber-gold */
  --gold-dim: rgba(200, 134, 10, 0.82);
  --gold-hover: rgba(200, 134, 10, 0.72);
  --gold-dimmest: rgba(200, 134, 10, 0.32);
  --gold-glow: rgba(200, 134, 10, 0.22);
  --teal: #2e8b77; /* sea teal             */
  --teal-dim: rgba(46, 139, 119, 0.12);
  --crimson: #c0392b;
  --amber: #d4760a;
  --sky: rgba(41, 128, 185, 1);
  --sky-hover: rgba(41, 128, 185, 0.82);
  --sky-dimmest: rgba(41, 128, 185, 0.12);
  --muted: #8b7355; /* warm mid-brown muted */
  --text: #3a2e1e;
  --text-dim: #7a6040;

  /* Spacing / Shape */
  --nav-h: 56px;
  --bnav-h: 70px; /* mobile bottom nav height */
  --rail-w: 68px; /* desktop side-rail width  */
  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 24px;
  --r-pill: 100px;
  --max-w-toast: 240px;

  /* Typography */
  --font-display: "Cinzel", Georgia, serif;
  --font-body: "DM Sans", "Segoe UI", system-ui, sans-serif;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(139, 99, 64, 0.2);
  --shadow-md: 0 6px 24px rgba(139, 99, 64, 0.25);
  --shadow-lg: 0 16px 48px rgba(58, 46, 30, 0.35);

  /* Motion */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --t-fast: 0.14s var(--ease);
  --t-mid: 0.28s var(--ease);
  --t-slow: 0.45s var(--ease);
}

/* ── Reset ────────────────────────────────────────────────── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  /* Beach / tropical background image */
  background: url("/images/background-main.png") center center / cover fixed;
  background-color: #f4deb9; /* fallback while image loads */
  color: var(--text);
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}
img,
svg {
  display: block;
}
ul {
  list-style: none;
}
a {
  color: inherit;
  text-decoration: none;
}
button {
  font-family: inherit;
  cursor: pointer;
}

.header--hidden {
  display: none;
}

/* ── Top Navigation ───────────────────────────────────────── */
.logo-text {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--gold);
  letter-spacing: 0.1em;
}

@media (max-width: 480px) {
  .logo-text {
    display: none;
  }
}

.top-nav {
  position: fixed;
  display: flex;
  align-items: center;
  justify-content: space-between;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-h);
  background: rgba(253, 248, 239, 0.9);
  border-bottom: 1px solid var(--border-hi);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 1000;
  padding: 0 16px;
  gap: 10px;
  box-shadow: 0 2px 12px rgba(139, 99, 64, 0.1);
}

.top-nav__brand {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.07em;
  white-space: nowrap;
  flex-shrink: 0;
}

.top-nav__center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
}

.top-nav__right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.top-nav.top-nav--hidden {
  display: none;
}

/* nav badges */
.nav-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 3px 10px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot--on {
  background: var(--teal);
  box-shadow: 0 0 6px var(--teal);
}
.status-dot--off {
  background: var(--muted);
}
.status-dot--waiting {
  background: var(--amber);
  animation: blink 1.6s ease-in-out infinite alternate;
}
@keyframes blink {
  to {
    opacity: 0.15;
  }
}

.nav-username {
  font-size: 0.74rem;
  color: var(--text-dim);
  white-space: nowrap;
}

/* ── Page scaffold ────────────────────────────────────────── */
main {
  flex: 1;
  padding-top: var(--nav-h);
}

/* TODO: should this move to gameboard.css? 
It's only used on game pages, but it's also pretty specific to the 
layout of the game page, so maybe it belongs in a base css of some (other) sort?
 */

main.game-main {
  padding-bottom: 0; /* gs-wrap accounts for bnav-h itself */
  display: flex;
  flex-direction: column;
  padding-top: 0;
}

/* TODO: refactor positioning */
.site-footer {
  padding: 5px 20px;
  text-align: center;
  font-size: 0.74rem;
  color: var(--muted);
  position: fixed;
  bottom: 5px;
  width: 100%;
  margin: 0 auto;
  /* border-top: 1px solid var(--border); */
}
.game-page .site-footer,
.solo-host-game-page .site-footer {
  display: none;
}

/* ── Container ────────────────────────────────────────────── */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1rem;
}
.container--center {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100svh - var(--nav-h));
  padding: 2rem 1rem;
}

.card {
  background: white;
  border-radius: 8px;
  padding: 25px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  margin-bottom: 30px;
}

.card h2 {
  margin-top: 0;
  color: #333;
  border-bottom: 1px solid #eee;
  padding-bottom: 15px;
}

/* ── Typography ───────────────────────────────────────────── */
h1 {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 5vw, 2.2rem);
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.03em;
}

h2 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
}
h3 {
  font-size: 0.95rem;
  font-weight: 700;
}
h4 {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.subtitle {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0.42rem 1rem;
  font-size: 0.8rem;
  font-weight: 700;
  font-family: var(--font-body);
  border: none;
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: all var(--t-fast);
  text-decoration: none;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  line-height: 1.4;
  letter-spacing: 0.02em;
}
.btn-sm {
  padding: 0.25rem 0.7rem;
  font-size: 0.72rem;
}
.btn-lg {
  padding: 0.65rem 1.5rem;
  font-size: 0.9rem;
}

.btn-primary {
  background: var(--teal);
  color: var(--ink);
}
.btn-secondary {
  background: var(--sky);
  color: var(--ink);
}
.btn-warning {
  background: var(--amber);
  color: var(--ink);
}
.btn-danger {
  background: var(--crimson);
  color: #fff;
}
.btn-info {
  background: #1db8c4;
  color: var(--ink);
}
.btn-gold {
  background: var(--gold);
  color: var(--ink);
}
.btn-ghost {
  background: rgba(255, 255, 255, 0.2);
  color: var(--text);
  border: 1px solid var(--border-hi);
  box-shadow: none;
  backdrop-filter: blur(4px);
}

.btn-primary:hover:not(:disabled) {
  background: #38dbbe;
  box-shadow: 0 0 16px rgba(41, 196, 169, 0.4);
}
.btn-secondary:hover:not(:disabled) {
  background: #6db6ff;
}
.btn-warning:hover:not(:disabled) {
  background: #f5a84e;
}
.btn-danger:hover:not(:disabled) {
  background: #f05252;
}
.btn-info:hover:not(:disabled) {
  background: #23ccd8;
}
.btn-gold:hover:not(:disabled) {
  background: #f0ca5e;
  box-shadow: 0 0 16px var(--gold-glow);
}
.btn-ghost:hover:not(:disabled) {
  background: rgba(166, 164, 164, 0.26);
  transform: scale(0.97);
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}
.btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}
.btn.hide {
  display: none;
}

/* ── Form ─────────────────────────────────────────────────── */
.form {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 2rem;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 420px;
}
input,
select,
textarea {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-hi);
  border-radius: var(--r-sm);
  color: var(--text);
  padding: 10px 14px;
  font-size: 0.88rem;
  font-family: var(--font-body);
  width: 100%;
  transition:
    border-color var(--t-fast),
    background var(--t-fast);
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--teal);
  background: rgba(41, 196, 169, 0.06);
}

dialog {
  border: 1px solid var(--border);
  padding: 0 2rem;
  background: rgba(255, 252, 242, 0.98);
  border-radius: var(--r-md);
  color: var(--text);
  position: fixed;
  inset: 0;
  margin: auto;
  height: fit-content;
  width: min(92svw, 20rem);
  box-shadow: var(--shadow-lg);
  font-family: var(--font-body);
}

.dialog-body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  font-size: 0.9rem;
  min-height: 5svh;
  width: 100%;
  color: var(--text);
  word-break: break-word;
  gap: 14px;
}

dialog::backdrop {
  background: rgba(58, 46, 30, 0.4);
  backdrop-filter: blur(4px);
}

/* ── Helpers ──────────────────────────────────────────────── */
.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;
}

@media (max-width: 600px) {
  body {
    background-image: url("/images/background-mobile.png");
  }

  .top-nav {
    padding: 0 1rem;
    gap: 4px;
  }
}
