/* ============================================================
   Scuba — "Abyss" theme
   Deep-water mood: dark slate, abyssal teal, dive-flag accent.
   Display serif Fraunces + body Nunito.
   Fully self-contained (local fonts, no CDN calls).
   Default: dark mode.
   ============================================================ */

@font-face { font-family: "Fraunces"; font-weight: 600; font-display: swap;
  src: url("/static/fonts/fraunces-600.woff2") format("woff2"); }
@font-face { font-family: "Fraunces"; font-weight: 700; font-display: swap;
  src: url("/static/fonts/fraunces-700.woff2") format("woff2"); }
@font-face { font-family: "Fraunces"; font-weight: 900; font-display: swap;
  src: url("/static/fonts/fraunces-900.woff2") format("woff2"); }
@font-face { font-family: "Nunito"; font-weight: 400; font-display: swap;
  src: url("/static/fonts/nunito-400.woff2") format("woff2"); }
@font-face { font-family: "Nunito"; font-weight: 600; font-display: swap;
  src: url("/static/fonts/nunito-600.woff2") format("woff2"); }
@font-face { font-family: "Nunito"; font-weight: 700; font-display: swap;
  src: url("/static/fonts/nunito-700.woff2") format("woff2"); }
@font-face { font-family: "Nunito"; font-weight: 800; font-display: swap;
  src: url("/static/fonts/nunito-800.woff2") format("woff2"); }

/* ── Dark tokens (default) ────────────────────────────────────────────────── */
:root {
  color-scheme: dark;

  /* Backgrounds */
  --paper:    #0d1b2a;   /* deep abyss */
  --paper-2:  #132336;   /* slightly lighter depth */
  --paper-3:  #1a2f47;   /* card level */
  --card:     #162d43;   /* elevated surface */
  --topbar-bg: linear-gradient(180deg, rgba(13,27,42,.96), rgba(13,27,42,.88));

  /* Text */
  --ink:       #e8f4f8;  /* near-white, slight cool tint */
  --ink-soft:  #9bbfce;
  --ink-faint: #6a9aac;
  --ink-label: #7dafc0;

  /* Primary accent — abyssal teal */
  --sea:       #29a0b8;
  --sea-deep:  #1d7d90;
  --sea-soft:  #0d3b4a;

  /* Action accent — dive-flag / tank orange */
  --coral:     #f07c4a;  /* renamed from coral to keep token names */
  --coral-deep:#d05d2a;
  --coral-soft:#3a2010;

  /* Warning / due-soon — amber bioluminescence */
  --gold:      #f5c842;
  --gold-soft: #2e2600;

  /* Separator */
  --line: #1e3a52;

  /* Extended tokens */
  --mint:       #2a6b5c;  /* badge secondary */
  --sand-deep:  rgba(245, 200, 66, .15);
  --sand-dark:  #f5c842;

  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --body: "Nunito", ui-rounded, "Segoe UI", system-ui, sans-serif;

  --r-lg: 20px;
  --r-md: 13px;
  --r-sm: 8px;
  --r-pill: 999px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .4);
  --shadow:    0 6px 20px -6px rgba(0, 0, 0, .6), 0 2px 6px rgba(0, 0, 0, .3);
  --shadow-lg: 0 18px 40px -12px rgba(0, 0, 0, .7);

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
}

/* ── Light override ───────────────────────────────────────────────────────── */
[data-theme="light"] {
  color-scheme: light;
  --paper:    #f0f8fc;
  --paper-2:  #deeef5;
  --paper-3:  #cde3ee;
  --card:     #ffffff;
  --topbar-bg: linear-gradient(180deg, rgba(240,248,252,.96), rgba(222,238,245,.88));
  --ink:       #0d2233;
  --ink-soft:  #3a6070;
  --ink-faint: #5a8090;
  --ink-label: #4a7080;
  --sea:       #1a7a94;
  --sea-deep:  #0d5a6e;
  --sea-soft:  #c8e8f0;
  --coral:     #e05a20;
  --coral-deep:#b83d08;
  --coral-soft:#fde4d0;
  --gold:      #c89000;
  --gold-soft: #fef3c0;
  --line:      #b8d8e8;
  --shadow-sm: 0 1px 2px rgba(0, 50, 80, .08);
  --shadow:    0 6px 18px -8px rgba(0, 50, 80, .2), 0 2px 5px rgba(0, 50, 80, .06);
  --shadow-lg: 0 18px 38px -14px rgba(0, 50, 80, .28);
}

/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background-color: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 1rem;
  line-height: 1.55;
  /* Subtle depth background */
  background-image:
    radial-gradient(ellipse at 30% 0%, rgba(41,160,184,.12) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 100%, rgba(29,125,144,.08) 0%, transparent 50%);
  background-attachment: fixed;
}

/* Depth-grain overlay */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .03;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
}

a { color: var(--sea); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible { outline: 2px solid var(--sea); outline-offset: 2px; border-radius: 3px; }

h1, h2, h3, h4 { font-family: var(--display); font-weight: 700; margin: 0; }
p { margin: 0; }

/* ── Skip link ────────────────────────────────────────────────────────────── */
.skip-link {
  position: absolute; left: -9999px; top: auto;
  &:focus { position: static; }
}

/* ── Topbar ───────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--topbar-bg);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border-bottom: 1px solid var(--line);
  padding: 0 var(--space-4);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  max-width: 960px;
  margin: 0 auto;
  height: 56px;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--ink);
  text-decoration: none;
  flex-shrink: 0;
}
.brand h1 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -.01em;
}
.brand-emoji { font-size: 1.4rem; line-height: 1; }

.topbar-nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-left: auto;
  flex-wrap: wrap;
}
.nav-link {
  padding: var(--space-1) var(--space-3);
  border-radius: var(--r-pill);
  font-size: .875rem;
  font-weight: 600;
  color: var(--ink-soft);
  text-decoration: none;
  transition: background .15s, color .15s;
}
.nav-link:hover, .nav-link.active { background: var(--sea-soft); color: var(--sea); }
.nav-link:hover { text-decoration: none; }

/* ── Main container ───────────────────────────────────────────────────────── */
.main-content {
  max-width: 960px;
  margin: 0 auto;
  padding: var(--space-5) var(--space-4);
  position: relative;
  z-index: 1;
}

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-4);
}

/* ── Stat tiles (dashboard) ───────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}
.stat-tile {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--space-4);
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.stat-tile .stat-val {
  font-family: var(--display);
  font-size: 2rem;
  font-weight: 900;
  color: var(--sea);
  line-height: 1;
}
.stat-tile .stat-label {
  font-size: .75rem;
  color: var(--ink-faint);
  margin-top: var(--space-1);
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* ── Alert / due-now banner ───────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--r-md);
  font-size: .9rem;
  margin-bottom: var(--space-4);
}
.alert-warn {
  background: var(--gold-soft);
  border: 1px solid var(--gold);
  color: var(--gold);
}
.alert-danger {
  background: var(--coral-soft);
  border: 1px solid var(--coral);
  color: var(--coral);
}

/* ── Dive list item ───────────────────────────────────────────────────────── */
.dive-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.dive-item {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  text-decoration: none;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.dive-item:hover { border-color: var(--sea); box-shadow: var(--shadow); text-decoration: none; }
.dive-num {
  font-family: var(--display);
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--sea);
  min-width: 3rem;
  text-align: right;
  flex-shrink: 0;
}
.dive-meta { flex: 1; min-width: 0; }
.dive-meta strong { display: block; font-weight: 700; font-size: 1rem; }
.dive-meta span { font-size: .85rem; color: var(--ink-soft); }
.dive-depth { font-family: var(--display); font-weight: 700; font-size: 1.1rem; color: var(--sea-deep); margin-left: auto; }

/* Stars */
.stars { color: var(--gold); font-size: .85rem; letter-spacing: 1px; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-section { margin-bottom: var(--space-5); }
.form-section-title {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-faint);
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--line);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--space-4); }
@media (max-width: 600px) {
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
}
.form-group { display: flex; flex-direction: column; gap: var(--space-1); }
.form-label { font-size: .85rem; font-weight: 700; color: var(--ink-soft); }
.form-input, .form-select, .form-textarea {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--ink);
  font-family: var(--body);
  font-size: 1rem;
  padding: var(--space-2) var(--space-3);
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--sea);
  box-shadow: 0 0 0 3px rgba(41,160,184,.2);
}
.form-input::placeholder { color: var(--ink-faint); }
.form-hint { font-size: .78rem; color: var(--ink-faint); }
.form-textarea { min-height: 80px; resize: vertical; }
select.form-select option { background: var(--paper-2); color: var(--ink); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--r-pill);
  font-family: var(--body);
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: background .15s, box-shadow .15s, transform .1s;
  text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn:focus-visible { outline: 2px solid var(--sea); outline-offset: 2px; }

.btn-primary { background: var(--sea); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--sea-deep); text-decoration: none; color: #fff; }

.btn-secondary {
  background: var(--paper-3);
  color: var(--ink-soft);
  border: 1px solid var(--line);
}
.btn-secondary:hover { background: var(--sea-soft); color: var(--sea); text-decoration: none; }

.btn-danger { background: var(--coral-soft); color: var(--coral); border: 1px solid var(--coral); }
.btn-danger:hover { background: var(--coral); color: #fff; text-decoration: none; }

.btn-sm { padding: var(--space-1) var(--space-3); font-size: .8rem; }
.btn-icon { padding: var(--space-2); border-radius: 50%; }

.btn-row { display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: center; }

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  border-radius: var(--r-pill);
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.badge-sea { background: var(--sea-soft); color: var(--sea); }
.badge-coral { background: var(--coral-soft); color: var(--coral); }
.badge-gold { background: var(--gold-soft); color: var(--gold); }
.badge-faint { background: var(--paper-3); color: var(--ink-faint); }

/* ── Page heading ─────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}
.page-title { font-size: 1.6rem; font-weight: 900; }

/* ── Detail page ──────────────────────────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-3);
  margin: var(--space-4) 0;
}
.detail-cell { }
.detail-cell .label { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); margin-bottom: 2px; }
.detail-cell .value { font-weight: 700; font-size: 1rem; }
.detail-cell .value.big { font-family: var(--display); font-size: 1.4rem; color: var(--sea); }

/* ── Image grid (photos, cert cards) ─────────────────────────────────────── */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: var(--space-3);
  margin: var(--space-4) 0;
}
.photo-item {
  position: relative;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--paper-2);
  aspect-ratio: 1;
}
.photo-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-item:hover .photo-overlay { opacity: 1; }
.photo-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .15s;
}

/* ── Gear category icon pill ──────────────────────────────────────────────── */
.gear-cat {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--r-pill);
  background: var(--sea-soft);
  color: var(--sea);
  font-size: .8rem;
  font-weight: 700;
}

/* ── Service due indicator ────────────────────────────────────────────────── */
.due-now { color: var(--coral); }
.due-soon { color: var(--gold); }

/* ── Cert card ────────────────────────────────────────────────────────────── */
.cert-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.cert-images {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.cert-img {
  flex: 1 1 180px;
  max-width: 260px;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--paper-2);
  border: 1px solid var(--line);
}
.cert-img img { width: 100%; display: block; }

/* ── SAC chip ─────────────────────────────────────────────────────────────── */
.sac-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--sea-soft);
  border: 1px solid var(--sea);
  border-radius: var(--r-md);
  padding: var(--space-2) var(--space-4);
  margin: var(--space-4) 0;
}
.sac-chip .sac-val { font-family: var(--display); font-size: 1.4rem; font-weight: 900; color: var(--sea); }
.sac-chip .sac-label { font-size: .75rem; color: var(--ink-soft); }

/* ── Table ────────────────────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.data-table th {
  text-align: left;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-faint);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--line);
}
.data-table td { padding: var(--space-3); border-bottom: 1px solid var(--line); vertical-align: top; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--paper-2); }

/* ── Login page ───────────────────────────────────────────────────────────── */
.login-page {
  min-height: calc(100dvh - 56px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5) var(--space-4);
}
.login-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--space-6);
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}
.login-heading { font-size: 1.6rem; text-align: center; margin-bottom: var(--space-5); }
.login-tabs {
  display: flex;
  gap: 2px;
  background: var(--paper-2);
  border-radius: var(--r-pill);
  padding: 3px;
  margin-bottom: var(--space-4);
}
.login-tab {
  flex: 1;
  padding: var(--space-2);
  border: none;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--body);
  font-weight: 600;
  font-size: .9rem;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.login-tab.active { background: var(--sea); color: #fff; }
.login-form { display: flex; flex-direction: column; gap: var(--space-4); }
.login-error { color: var(--coral); font-size: .85rem; text-align: center; }
.login-success { color: var(--sea); font-size: .85rem; text-align: center; }
.forgot-link { font-size: .8rem; color: var(--ink-faint); align-self: flex-end; }
.login-divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--ink-faint);
  font-size: .85rem;
  margin: var(--space-4) 0;
}
.login-divider::before, .login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
.google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3);
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  font-family: var(--body);
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, border-color .15s;
}
.google-btn:hover { background: var(--paper-3); border-color: var(--sea); text-decoration: none; color: var(--ink); }
.primary-btn {
  width: 100%;
  padding: var(--space-3);
  border-radius: var(--r-pill);
  border: none;
  background: var(--sea);
  color: #fff;
  font-family: var(--body);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s;
}
.primary-btn:hover { background: var(--sea-deep); }
.primary-btn:disabled { opacity: .6; cursor: not-allowed; }

/* ── Empty state ──────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: var(--space-6) var(--space-4);
  color: var(--ink-soft);
}
.empty-state .empty-icon { font-size: 3rem; display: block; margin-bottom: var(--space-3); }
.empty-state h3 { font-size: 1.1rem; margin-bottom: var(--space-2); }
.empty-state p { font-size: .9rem; color: var(--ink-faint); }

/* ── Toast ────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: var(--space-5);
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: var(--sea);
  color: #fff;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-lg);
  font-weight: 700;
  font-size: .9rem;
  z-index: 1000;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  pointer-events: none;
}
.toast.show { opacity: 1; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .topbar-nav .nav-link { font-size: .78rem; padding: var(--space-1) var(--space-2); }
  .page-title { font-size: 1.3rem; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Accessibility ────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
