/* ============================================================
   NORTHWAKE PANEL — Design System
   Marine minimaliste · lumineux · kid-friendly + pro-efficiency
   Palette (charte stricte) :
     #E6E6E6 Alabaster · #A8DADC Frosted · #457B9D Cerulean
     #1D3557 Oxford Navy · #E63946 Punch Red
   3 directions visuelles via [data-direction]: tide / harbor / current
   ============================================================ */

:root {
  /* --- Palette charte --- */
  --alabaster: #E6E6E6;
  --frosted:   #A8DADC;
  --cerulean:  #457B9D;
  --navy:      #1D3557;
  --punch:     #E63946;

  /* --- Dérivés lumineux (oklch, faible saturation pour les blancs) --- */
  --surface:        #ffffff;
  --surface-2:      #f4f7f8;
  --surface-3:      #eaeff1;
  --bg:             oklch(0.965 0.006 220);
  --frosted-tint:   oklch(0.95 0.03 200);
  --frosted-soft:   oklch(0.97 0.018 200);

  --ink:        var(--navy);
  --ink-soft:   oklch(0.42 0.04 245);
  --ink-mute:   oklch(0.58 0.03 240);
  --line:       oklch(0.9 0.012 230);
  --line-soft:  oklch(0.94 0.01 230);

  /* --- Type --- */
  --font: "Helvetica Neue", Helvetica, "Inter", system-ui, Arial, sans-serif;
  --fs-display: clamp(28px, 3.2vw, 40px);
  --fs-h1: 27px;
  --fs-h2: 20px;
  --fs-body: 15px;
  --fs-sm: 13px;
  --fs-xs: 11.5px;

  /* --- Forme (tone ~30 → friendly, radius généreux) --- */
  --r-sm: 9px;
  --r:    14px;
  --r-lg: 20px;
  --r-pill: 999px;

  /* --- Profondeur --- */
  --shadow-sm: 0 1px 2px rgba(29,53,87,.06), 0 1px 3px rgba(29,53,87,.05);
  --shadow:    0 4px 14px rgba(29,53,87,.08), 0 1px 3px rgba(29,53,87,.06);
  --shadow-lg: 0 18px 50px rgba(29,53,87,.16), 0 6px 16px rgba(29,53,87,.08);
  --ring: 0 0 0 3px color-mix(in srgb, var(--cerulean) 28%, transparent);

  /* --- Surfaces de carte (overridées par direction) --- */
  --card-bg: var(--surface);
  --card-border: 1px solid var(--line);
  --card-shadow: var(--shadow);
  --card-blur: none;

  /* --- Sidebar --- */
  --sidebar-bg: linear-gradient(180deg, var(--cerulean) 0%, var(--navy) 100%);
  --sidebar-ink: #eaf2f6;
  --sidebar-active-bg: rgba(255,255,255,.16);
  --sidebar-w: 256px;

  --speed: .22s;
  --ease: cubic-bezier(.32,.72,.31,1);
}

/* ============ DIRECTION : HARBOR (éditorial, flat, bordures nettes) ============ */
[data-direction="harbor"] {
  --bg: #eef1f2;
  --r-sm: 4px; --r: 6px; --r-lg: 8px;
  --card-bg: var(--surface);
  --card-border: 1.5px solid var(--navy);
  --card-shadow: none;
  --shadow: none; --shadow-sm: none;
  --shadow-lg: 0 12px 40px rgba(29,53,87,.18);
  --sidebar-bg: var(--navy);
}
[data-direction="harbor"] .nw-card { border-bottom-width: 3px; }
[data-direction="harbor"] .btn { border-radius: var(--r-sm); }

/* ============ DIRECTION : CURRENT (glassmorphism — "coucher de soleil marin") ============ */
[data-direction="current"] {
  /* Fond : voile rosé en haut-droite + voile bleu glacé en bas-gauche, sur un dégradé clair bleu→rosé */
  --bg:
    radial-gradient(115% 85% at 100% 0%, oklch(0.93 0.055 25 / .85) 0%, transparent 52%),
    radial-gradient(110% 80% at 0% 100%, oklch(0.93 0.05 215 / .85) 0%, transparent 50%),
    linear-gradient(135deg, oklch(0.965 0.025 215) 0%, oklch(0.955 0.03 250) 48%, oklch(0.955 0.035 18) 100%);
  --r-sm: 12px; --r: 20px; --r-lg: 28px;
  --card-bg: color-mix(in srgb, #ffffff 64%, transparent);
  --card-border: 1px solid rgba(255,255,255,.72);
  --card-shadow: 0 12px 42px rgba(29,53,87,.13), inset 0 1px 0 rgba(255,255,255,.85);
  --card-blur: blur(16px) saturate(1.35);
  /* Sidebar : océan profond + lueur rouge (punch) montant du bas */
  --sidebar-bg:
    radial-gradient(135% 58% at 50% 102%, color-mix(in srgb, var(--punch) 72%, transparent) 0%, transparent 62%),
    linear-gradient(166deg, color-mix(in srgb, var(--cerulean) 86%, transparent) 0%, color-mix(in srgb, var(--navy) 94%, transparent) 46%, color-mix(in srgb, var(--punch) 42%, var(--navy)) 100%);
}
[data-direction="current"] body { background-attachment: fixed; }
[data-direction="current"] .nw-sidebar { backdrop-filter: blur(20px) saturate(1.4); }
/* Cohérence : accents de la sidebar passent au rouge corail */
[data-direction="current"] .nw-nav-item.active::before { background: color-mix(in srgb, var(--punch) 80%, #fff); }
[data-direction="current"] .nw-nav-item.active { background: rgba(255,255,255,.18); }
[data-direction="current"] .nw-brand-mark { background: rgba(255,255,255,.18); box-shadow: inset 0 0 0 1px rgba(255,255,255,.3); }
[data-direction="current"] .nw-nav-badge { box-shadow: 0 2px 8px color-mix(in srgb, var(--punch) 55%, transparent); }

/* ============================= BASE ============================= */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: var(--fs-body);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
button, input, select, textarea { font-family: inherit; }
::selection { background: color-mix(in srgb, var(--frosted) 70%, transparent); }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb,var(--cerulean) 35%, transparent); border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb,var(--cerulean) 55%, transparent); background-clip: content-box; }

/* ============================= APP SHELL ============================= */
.nw-app { display: flex; min-height: 100vh; }

.nw-sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-ink);
  display: flex; flex-direction: column;
  padding: 18px 14px;
  position: sticky; top: 0; height: 100vh;
  transition: width var(--speed) var(--ease);
  z-index: 30;
}
.nw-brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 16px; }
.nw-brand-mark {
  width: 40px; height: 40px; border-radius: 12px; flex: 0 0 40px;
  background: rgba(255,255,255,.14);
  display: grid; place-items: center; font-size: 22px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.25);
}
.nw-brand-name { font-weight: 800; font-size: 17px; letter-spacing: .2px; line-height: 1; }
.nw-brand-sub { font-size: 11px; opacity: .7; letter-spacing: .12em; text-transform: uppercase; margin-top: 3px; }

.nw-nav { display: flex; flex-direction: column; gap: 3px; margin-top: 8px; overflow-y: auto; }
.nw-nav-label { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; opacity: .55; padding: 14px 12px 6px; font-weight: 700; }
.nw-nav-item {
  display: flex; align-items: center; gap: 13px;
  padding: 12px 14px; border-radius: var(--r-sm);
  color: var(--sidebar-ink); background: transparent; border: 0;
  font-size: 15px; font-weight: 600; cursor: pointer; text-align: left; width: 100%;
  position: relative; transition: background var(--speed) var(--ease);
}
.nw-nav-item:hover { background: rgba(255,255,255,.12); }
.nw-nav-item.active { background: var(--sidebar-active-bg); }
.nw-nav-item.active::before {
  content: ""; position: absolute; left: -14px; top: 50%; transform: translateY(-50%);
  width: 4px; height: 60%; border-radius: 0 4px 4px 0; background: var(--frosted);
}
.nw-nav-item .nw-ic { font-size: 20px; width: 24px; text-align: center; }
.nw-nav-badge { margin-left: auto; background: var(--punch); color:#fff; font-size: 10.5px; font-weight: 800; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 99px; display:grid; place-items:center; }
.nw-sidebar-foot { margin-top: auto; padding-top: 12px; }

/* ============================= MAIN ============================= */
.nw-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.nw-topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 26px; background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.nw-search {
  display: flex; align-items: center; gap: 9px; flex: 1; max-width: 420px;
  background: var(--surface-2); border: 1px solid var(--line);
  padding: 8px 14px; border-radius: var(--r-pill); color: var(--ink-mute);
  transition: box-shadow var(--speed), border-color var(--speed);
}
.nw-search:focus-within { border-color: var(--cerulean); box-shadow: var(--ring); }
.nw-search input { border: 0; background: transparent; outline: 0; flex: 1; color: var(--ink); font-size: 14px; }
.nw-top-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

/* Role switcher (segmented) */
.nw-roles { display: flex; gap: 3px; background: var(--surface-2); border: 1px solid var(--line); padding: 3px; border-radius: var(--r-pill); }
.nw-role {
  border: 0; background: transparent; cursor: pointer; padding: 7px 14px; border-radius: var(--r-pill);
  font-size: 13px; font-weight: 700; color: var(--ink-mute); display: flex; align-items: center; gap: 6px;
  transition: all var(--speed) var(--ease);
}
.nw-role:hover { color: var(--ink); }
.nw-role.active { background: var(--cerulean); color: #fff; box-shadow: var(--shadow-sm); }

.nw-iconbtn {
  width: 40px; height: 40px; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; display: grid; place-items: center; font-size: 18px;
  color: var(--ink-soft); position: relative; transition: all var(--speed) var(--ease);
}
.nw-iconbtn:hover { border-color: var(--cerulean); color: var(--cerulean); transform: translateY(-1px); }
.nw-iconbtn .dot { position: absolute; top: 8px; right: 9px; width: 8px; height: 8px; border-radius: 99px; background: var(--punch); box-shadow: 0 0 0 2px var(--surface); }

.nw-avatar {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; color: #fff; font-size: 14px; flex: 0 0 auto;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.4);
}

/* Page content */
.nw-content { padding: 28px 30px 60px; max-width: 1240px; width: 100%; margin: 0 auto; animation: viewIn .34s var(--ease); }
@keyframes viewIn { from { transform: translateY(12px); } to { transform: none; } }

.nw-pagehead { margin-bottom: 22px; display: flex; align-items: flex-start; gap: 14px; }
.nw-pagehead-main { flex: 1; min-width: 0; }
.nw-title { font-size: var(--fs-h1); font-weight: 800; letter-spacing: -.5px; margin: 0; line-height: 1.1; display:flex; align-items:center; gap:10px; }
.nw-desc { margin: 7px 0 0; color: var(--ink-mute); font-size: 14.5px; max-width: 70ch; }
.nw-pagehead-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ============================= COMPONENTS ============================= */
.nw-card {
  background: var(--card-bg); border: var(--card-border); border-radius: var(--r);
  box-shadow: var(--card-shadow); backdrop-filter: var(--card-blur);
  padding: 20px; transition: transform var(--speed) var(--ease), box-shadow var(--speed) var(--ease), border-color var(--speed);
}
.nw-card.hoverable:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--cerulean) 45%, var(--line)); }
.nw-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.nw-card-title { font-weight: 800; font-size: var(--fs-h2); margin: 0; }
.nw-card-sub { color: var(--ink-mute); font-size: var(--fs-sm); margin: 2px 0 0; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1080px) { .grid-3, .grid-4 { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 720px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  padding: 10px 18px; border-radius: var(--r-sm); border: 1px solid transparent;
  font-size: 14px; font-weight: 700; cursor: pointer; line-height: 1;
  transition: all var(--speed) var(--ease); white-space: nowrap;
}
.btn:active { transform: translateY(1px) scale(.985); }
.btn-primary { background: var(--cerulean); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: color-mix(in srgb, var(--cerulean) 88%, var(--navy)); box-shadow: var(--shadow); transform: translateY(-1px); }
.btn-danger { background: var(--punch); color: #fff; box-shadow: var(--shadow-sm); }
.btn-danger:hover { background: color-mix(in srgb, var(--punch) 90%, #000); transform: translateY(-1px); }
.btn-ghost { background: var(--surface); color: var(--ink-soft); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--cerulean); color: var(--cerulean); }
.btn-soft { background: var(--frosted-tint); color: var(--navy); }
.btn-soft:hover { background: color-mix(in srgb, var(--frosted) 60%, #fff); }
.btn-sm { padding: 7px 12px; font-size: 12.5px; }
.btn-lg { padding: 14px 24px; font-size: 15.5px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn:focus-visible, .nw-nav-item:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; box-shadow: var(--ring); }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 800; letter-spacing: .02em; }
.badge-ok { background: oklch(0.93 0.08 160); color: oklch(0.42 0.12 160); }
.badge-warn { background: oklch(0.94 0.09 80); color: oklch(0.47 0.12 70); }
.badge-danger { background: color-mix(in srgb, var(--punch) 16%, #fff); color: var(--punch); }
.badge-info { background: var(--frosted-tint); color: var(--cerulean); }
.badge-navy { background: color-mix(in srgb, var(--navy) 12%, #fff); color: var(--navy); }
.badge-dot::before { content:""; width:6px; height:6px; border-radius:99px; background: currentColor; }

/* Pills / chips */
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px; border-radius: var(--r-pill); background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; font-weight: 600; color: var(--ink-soft); cursor: pointer; transition: all var(--speed) var(--ease); }
.chip:hover { border-color: var(--cerulean); color: var(--cerulean); }
.chip.active { background: var(--cerulean); color: #fff; border-color: var(--cerulean); }
.chip.active .nw-ic { filter: none; }

/* Fields */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 700; color: var(--ink-soft); display:flex; align-items:center; gap:6px; }
.field .hint { font-size: 12px; color: var(--ink-mute); }
.input, .select, .textarea {
  width: 100%; padding: 11px 13px; border-radius: var(--r-sm); border: 1.5px solid var(--line);
  background: var(--surface); color: var(--ink); font-size: 14px; transition: all var(--speed) var(--ease);
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--cerulean); box-shadow: var(--ring); }
.textarea { resize: vertical; min-height: 92px; line-height: 1.5; }
.input.invalid { border-color: var(--punch); }

/* Tables */
.nw-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.nw-table th { text-align: left; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-mute); font-weight: 800; padding: 0 14px 11px; }
.nw-table td { padding: 13px 14px; border-top: 1px solid var(--line-soft); }
.nw-row { cursor: pointer; transition: background var(--speed); }
.nw-row:hover td { background: var(--frosted-soft); }

/* Stat tiles */
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat-val { font-size: 30px; font-weight: 800; letter-spacing: -1px; line-height: 1; }
.stat-label { font-size: 12.5px; color: var(--ink-mute); font-weight: 600; }
.stat-trend { font-size: 12px; font-weight: 800; }
.up { color: oklch(0.55 0.14 160); } .down { color: var(--punch); }

/* ============================= TOOLTIPS ============================= */
.tip { position: relative; }
.tip-bubble {
  position: absolute; z-index: 80; left: 50%; bottom: calc(100% + 9px);
  transform: translateX(-50%) translateY(6px) scale(.96);
  background: var(--navy); color: #eaf2f6; padding: 9px 12px; border-radius: 10px;
  font-size: 12.5px; font-weight: 600; line-height: 1.35; width: max-content; max-width: 240px;
  box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none;
  transition: opacity .18s var(--ease), transform .18s var(--ease); text-align: left;
}
.tip-bubble::after { content:""; position: absolute; top: 100%; left: 50%; transform: translateX(-50%); border: 6px solid transparent; border-top-color: var(--navy); }
.tip-bubble .tip-title { display:block; font-weight: 800; margin-bottom: 2px; color: #fff; }
.tip:hover > .tip-bubble, .tip:focus-visible > .tip-bubble { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
.tip-bubble.bottom { bottom: auto; top: calc(100% + 9px); transform: translateX(-50%) translateY(-6px) scale(.96); }
.tip-bubble.bottom::after { top: auto; bottom: 100%; border-top-color: transparent; border-bottom-color: var(--navy); }
.tip:hover > .tip-bubble.bottom { transform: translateX(-50%) translateY(0) scale(1); }

/* Help button */
.help-btn {
  width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid currentColor; color: var(--cerulean);
  background: transparent; font-size: 12px; font-weight: 800; cursor: pointer; display: inline-grid; place-items: center;
  line-height: 1; transition: all var(--speed) var(--ease); flex: 0 0 auto;
}
.help-btn:hover { background: var(--cerulean); color: #fff; transform: scale(1.12); }

/* ============================= MODAL ============================= */
.nw-overlay {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: color-mix(in srgb, var(--navy) 42%, transparent); backdrop-filter: blur(5px);
  padding: 24px; animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.nw-modal {
  background: var(--surface); border-radius: var(--r-lg); width: 100%; max-width: 560px;
  box-shadow: var(--shadow-lg); max-height: 90vh; overflow: auto; animation: modalIn .3s var(--ease);
  border: 1px solid var(--line);
}
.nw-modal.wide { max-width: 760px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(20px) scale(.97); } to { opacity: 1; transform: none; } }
.nw-modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 22px 24px 14px; }
.nw-modal-head .nw-title { font-size: 21px; }
.nw-modal-body { padding: 6px 24px 8px; }
.nw-modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 16px 24px 22px; flex-wrap: wrap; }
.nw-modal-close { margin-left: auto; }

/* Toast */
.nw-toasts { position: fixed; right: 22px; bottom: 22px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.nw-toast {
  background: var(--navy); color: #eaf2f6; padding: 13px 16px; border-radius: var(--r); min-width: 280px; max-width: 380px;
  box-shadow: var(--shadow-lg); display: flex; gap: 11px; align-items: flex-start; animation: toastIn .32s var(--ease);
  border-left: 4px solid var(--frosted);
}
.nw-toast.danger { border-left-color: var(--punch); }
.nw-toast.ok { border-left-color: oklch(0.7 0.14 160); }
.nw-toast b { color: #fff; }
@keyframes toastIn { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }

/* Icon component */
.nw-ic { display: inline-block; line-height: 1; font-style: normal; }
img.custom-icon { width: 1em; height: 1em; object-fit: contain; vertical-align: -.12em; }

/* Game logo tile */
.game-logo { width: 100%; aspect-ratio: 1; border-radius: var(--r); display: grid; place-items: center; font-size: 34px; position: relative; overflow: hidden; }
.game-logo::after { content:""; position:absolute; inset:0; background: linear-gradient(135deg, rgba(255,255,255,.25), transparent 60%); }

/* Placeholder media (striped) */
.ph {
  border-radius: var(--r); background:
    repeating-linear-gradient(45deg, var(--frosted-soft) 0 12px, color-mix(in srgb,var(--frosted) 22%, #fff) 12px 24px);
  display: grid; place-items: center; color: var(--cerulean); font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; letter-spacing: .04em;
  border: 1px dashed color-mix(in srgb,var(--cerulean) 40%, transparent);
}

/* Divider */
.hr { height: 1px; background: var(--line); border: 0; margin: 18px 0; }
.muted { color: var(--ink-mute); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; }

/* progress / availability slots */
.slotgrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.slot { padding: 9px 4px; border-radius: var(--r-sm); text-align: center; font-size: 12px; font-weight: 700; cursor: pointer; border: 1.5px solid var(--line); background: var(--surface); transition: all var(--speed) var(--ease); }
.slot:hover { border-color: var(--cerulean); }
.slot.avail { background: oklch(0.93 0.08 160); border-color: oklch(0.75 0.1 160); color: oklch(0.4 0.12 160); }
.slot.conflict { background: color-mix(in srgb,var(--punch) 14%, #fff); border-color: var(--punch); color: var(--punch); }

/* responsive sidebar collapse */
@media (max-width: 860px) {
  :root { --sidebar-w: 68px; }
  .nw-brand-name, .nw-brand-sub, .nw-nav-item span.lbl, .nw-nav-label, .nw-nav-badge { display: none; }
  .nw-nav-item { justify-content: center; }
  .nw-roles .lbl { display: none; }
}

/* fade-up util for list items (transform-only so it's never stuck invisible) */
.fade-up { animation: fadeUp .4s var(--ease) backwards; }
@keyframes fadeUp { from { transform: translateY(8px); } to { transform: none; } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
