/* =========================================================
   CALOTTE — DESIGN SYSTEM
   Éditorial / terminal. Sombre par défaut, thème clair en option.
   Signature : lie-de-vin (remplissages) + or (texte / accents).
   ========================================================= */

:root {
  --black: #0a0a0a;
  --white: #f5f5f0;
  --grey: #a8a29c;
  --mid: #1a1a1a;
  --line: #333333;
  --wine: #641835;
  --wine-light: #7a1d40;
  --gold: #EFBF04;
  --danger: #f87171;
  --success: #4ade80;
  --t: .13s ease;

  --radius: 2px;
  --radius-round: 999px;
  --font-display: 'Bebas Neue', sans-serif;
  --font-body: 'DM Sans', sans-serif;
}

/* Dark is the default regardless of OS preference; light is opt-in only via [data-theme="light"]. */
:root[data-theme="light"] {
  --black: #f0efe9;
  --white: #1c1b18;
  --grey: #706b64;
  --mid: #e5e3dc;
  --line: #ccc9c0;
  --gold: #7a6200;
}

/* ---------------------------------------------------------
   RESET / BASE
   --------------------------------------------------------- */

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

html, body { min-height: 100%; }

body {
  background: var(--black);
  color: var(--white);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; }

button { font-family: inherit; }

.song-toggle {
  background: transparent;
  border: none;
  color: var(--white);
  text-align: left;
  cursor: pointer;
}
.song-toggle:hover { background: rgba(245, 245, 240, .03); }

/* ---------------------------------------------------------
   TYPOGRAPHY
   --------------------------------------------------------- */

h1, h2,
.title-xl, .title-lg {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: .1em;
  text-transform: uppercase;
  line-height: 1.05;
  color: var(--white);
}

h1, .title-xl { font-size: clamp(2rem, 5vw, 3rem); }
h2, .title-lg { font-size: clamp(1.5rem, 3.5vw, 2.1rem); }

h3, .label {
  font-family: var(--font-body);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--grey);
}

h4 {
  font-family: var(--font-body);
  font-size: .95rem;
  font-weight: 700;
  color: var(--white);
}

.stat {
  font-family: var(--font-display);
  font-size: 3rem;
  line-height: 1;
  letter-spacing: .04em;
  color: var(--white);
}
.stat.is-gold { color: var(--gold); }

.muted { color: var(--grey); }
.text-gold { color: var(--gold); }

table, th, td, thead, .data { font-family: var(--font-body); }

a {
  color: var(--gold);
  text-decoration: none;
  transition: color var(--t);
}
a:hover { color: var(--white); }

hr, .divider {
  border: none;
  border-top: 1px solid var(--line);
}

/* ---------------------------------------------------------
   LAYOUT SHELL
   --------------------------------------------------------- */

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.content {
  flex: 1;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.25rem 6rem;
}

@media (min-width: 721px) {
  .content { padding: 3rem 2rem 4rem; }
}

.page-header {
  border-bottom: 1px solid var(--line);
  padding-bottom: 1.25rem;
  margin-bottom: 2rem;
}
.page-header .label { margin-bottom: .5rem; display: block; }
.page-header p { color: var(--grey); margin-top: .6rem; }

/* ---------------------------------------------------------
   NAV — sticky top (desktop), bottom tab bar (mobile)
   --------------------------------------------------------- */

.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--black);
  border-bottom: 1px solid var(--line);
}

.nav-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  height: 56px;
}

.nav-brand {
  font-family: var(--font-display);
  font-size: 1.2rem;
  letter-spacing: .12em;
  color: var(--gold) !important;
  flex-shrink: 0;
}
.nav-brand:hover { color: var(--white) !important; }

.nav-links {
  display: flex;
  align-items: center;
  gap: .25rem;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-links::-webkit-scrollbar { display: none; }

.nav-link {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .4rem .1rem;
  font-size: .78rem;
  font-weight: 500;
  color: var(--grey) !important;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: color var(--t), border-color var(--t);
}
.nav-link + .nav-link { margin-left: 1.1rem; }
.nav-link i { width: 15px; height: 15px; flex-shrink: 0; }
.nav-link:hover { color: var(--white) !important; }
.nav-link.is-active { color: var(--white) !important; border-bottom-color: var(--wine); }

.theme-toggle {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--grey);
  cursor: pointer;
  transition: border-color var(--t), color var(--t);
}
.theme-toggle:hover { border-color: var(--gold); color: var(--gold); }
.theme-toggle i { width: 16px; height: 16px; }

.tabbar { display: none; }

@media (max-width: 720px) {
  .nav-links { display: none; }

  .tabbar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    background: var(--black);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar-link {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .2rem;
    padding: .55rem .2rem;
    font-size: .6rem;
    font-weight: 500;
    letter-spacing: .02em;
    color: var(--grey) !important;
    text-align: center;
  }
  .tabbar-link i { width: 18px; height: 18px; }
  .tabbar-link span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .tabbar-link.is-active { color: var(--gold) !important; }

  .content { padding-bottom: 5.5rem; }
}

/* ---------------------------------------------------------
   CARDS
   --------------------------------------------------------- */

.card {
  background: var(--mid);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
  color: var(--white);
}

.card--hover {
  transition: border-color var(--t);
}
.card--hover:hover { border-color: var(--gold); }

.card--wine {
  background: var(--wine);
  color: var(--gold);
  border: none;
}
.card--wine p, .card--wine a { color: var(--gold); }

/* ---------------------------------------------------------
   TABLES
   --------------------------------------------------------- */

.data-wrap { overflow-x: auto; }

.data {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}
.data th {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--grey);
  text-align: left;
  padding: .65rem .8rem;
  border-bottom: 1px solid var(--line);
}
.data td {
  padding: .65rem .8rem;
  border-bottom: 1px solid var(--line);
  color: var(--white);
}
.data tbody tr:hover td { background: rgba(245, 245, 240, .02); }
.data td:first-child, .data th:first-child { color: var(--gold); }
.data th:first-child { color: var(--grey); }

/* ---------------------------------------------------------
   BADGES
   --------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .2rem .55rem;
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--mid);
  color: var(--grey);
}
.badge--pending { color: var(--gold); border-color: rgba(239, 191, 4, .35); background: rgba(239, 191, 4, .07); }
.badge--valid   { color: var(--success); border-color: rgba(74, 222, 128, .35); background: rgba(74, 222, 128, .07); }
.badge--refused { color: var(--danger); border-color: rgba(248, 113, 113, .35); background: rgba(248, 113, 113, .07); }

/* ---------------------------------------------------------
   BUTTONS
   --------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .55rem 1.1rem;
  font-family: var(--font-body);
  font-size: .85rem;
  font-weight: 600;
  background: var(--mid);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--white);
  cursor: pointer;
  transition: border-color var(--t), background var(--t), color var(--t);
}
.btn:hover { border-color: var(--gold); }

.btn-primary {
  background: var(--wine);
  border-color: var(--wine);
  color: var(--gold);
}
.btn-primary:hover { background: var(--wine-light); border-color: var(--gold); }

.btn-danger {
  background: var(--mid);
  border-color: var(--line);
  color: var(--danger);
}
.btn-danger:hover { border-color: var(--danger); }

@media (max-width: 720px) {
  .btn { padding: .7rem 1.3rem; font-size: .9rem; }
}

/* ---------------------------------------------------------
   FORM FIELDS
   --------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: .4rem; }

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  height: 44px;
  background: var(--black);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--white);
  font-family: var(--font-body);
  font-size: 16px;
  padding: 0 .9rem;
  outline: none;
  transition: border-color var(--t);
  width: 100%;
}
textarea { height: auto; padding: .7rem .9rem; min-height: 6rem; }

input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus,
textarea:focus {
  border-color: var(--gold);
  box-shadow: none;
}

input[type="file"] {
  height: 44px;
  display: flex;
  align-items: center;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a8a29c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .8rem center;
  padding-right: 2.2rem;
}

/* ---------------------------------------------------------
   CHIPS
   --------------------------------------------------------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .4rem .9rem;
  border-radius: var(--radius-round);
  background: var(--black);
  border: 1px solid var(--grey);
  color: var(--grey);
  font-size: .8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t), color var(--t), border-color var(--t);
}
.chip.is-on {
  background: var(--wine);
  border-color: var(--wine);
  color: var(--gold);
}

@media (max-width: 720px) {
  .chip { padding: .55rem 1.1rem; }
}

/* ---------------------------------------------------------
   AVATAR
   --------------------------------------------------------- */

.switch-track {
  width: 2.5rem;
  height: 1.5rem;
  background: var(--line);
  border-radius: var(--radius-round);
  transition: background var(--t);
}
.switch-track.is-on { background: var(--wine); }

.switch-dot {
  width: 1rem;
  height: 1rem;
  background: var(--white);
  border-radius: var(--radius-round);
  transition: transform var(--t), background var(--t);
}
.switch-dot.is-on { transform: translateX(1rem); background: var(--gold); }

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-round);
  background: var(--wine);
  color: var(--gold);
  font-family: var(--font-display);
  letter-spacing: .04em;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  font-size: .9rem;
}

/* ---------------------------------------------------------
   MISC
   --------------------------------------------------------- */

.border-top { border-top: 1px solid var(--line); }
.border-bottom { border-bottom: 1px solid var(--line); }

.timeline {
  border-left: 2px solid var(--line);
  margin-left: .2rem;
}
.timeline-item { position: relative; padding-left: 1.5rem; }
.timeline-dot {
  position: absolute;
  left: -5px;
  top: .35rem;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-round);
  background: var(--wine);
  border: 2px solid var(--gold);
}

.tile {
  display: block;
  background: var(--black);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  color: var(--white);
  transition: border-color var(--t);
}
.tile:hover { border-color: var(--gold); color: var(--white); }
.tile p:not(.font-semibold):not(.font-bold) { color: var(--grey); }

code, .mono {
  font-family: 'DM Mono', ui-monospace, monospace;
}
.mono-tag {
  display: block;
  font-family: 'DM Mono', ui-monospace, monospace;
  font-size: .72rem;
  line-height: 1.5;
  background: var(--black);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .35rem .6rem;
  color: var(--white);
}
.mono-tag.is-valid { color: var(--success); border-color: rgba(74, 222, 128, .3); }
.mono-tag.is-refused { color: var(--danger); border-color: rgba(248, 113, 113, .3); }
.mono-tag.is-pending { color: var(--gold); border-color: rgba(239, 191, 4, .3); }

.icon-tile {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  background: var(--wine);
  color: var(--gold);
  flex-shrink: 0;
}

/* Kept last so it always wins the cascade whether combined with .card or .tile. */
.card--accent { border-left: 3px solid var(--wine); }
