/* ===== FONTS ===== */
@font-face {
  font-family: arkhip;
  font-style: normal;
  font-weight: 400;
  src:
    local("Arkhip"),
    url("/assets/fonts/arkhip.woff") format("woff");
  font-display: swap;
}

/* ===== VARIABLES ===== */
:root {
  /* Core palette */
  --color1: #151c53;
  --color2: #1c567d;
  --color3: #0e2843;
  --color4: #097788;
  --color5: #bc1c20;
  --color6: #cf0d0f;
  --color7: #fe9400;
  --color8: #4a4a4a;
  /* Extended palette */
  --color9: #209098;
  --color10: #126e7a;
  --color11: #2a3c7d;
  --color12: #ff7b00;
  --color13: #e74c3c;
  --color14: #084c61;
  --color15: #647c90;
  --color16: #d46a00;
  /* Grayscale */
  --gray-100: #f9f9f9;
  --gray-200: #ebebeb;
  --gray-300: #d9d9d9;
  --gray-400: #c4c4c4;
  --gray-500: #a0a0a0;
  --gray-600: #7d7d7d;
  --gray-700: #555555;
  --gray-800: #373737;
  --gray-900: #1a1a1a;
  /* Semantic colors */
  --color-primary: var(--color4);
  --color-secondary: var(--color2);
  --color-tertiary: var(--color1);
  --color-primary-dark: var(--color10);
  --color-secondary-dark: var(--color14);
  --color-tertiary-dark: var(--color11);
  --error: var(--color6);
  /* UI Elements */
  --progress-width: 0;
  --progress-opacity: 0;
  --show-back-button: none;
  --show-drawer-button: none;

  /* Survivant Theme Toggle */
  --survivant-mode: 0;
  --theme-toggle-translate: calc(1.8rem);
  --survivant-toggle-translate: calc(1.8rem);
  --survivant-toggle-color: var(--gray-700);
  --survivant-toggle-icon: url("/assets/img/icons/tree.svg");
  --survivant-toggle-icon-color: var(--gray-100);

  --show-install: none;
  --show-install-banner: none;
  --show-install-iphone: none;
}

/* ===== THEMES ===== */
:root[data-theme="light"],
:root:not([data-theme]) {
  --bg: url(/assets/img/bg/light-bg.webp);
  --bg-primary: var(--gray-100);
  --bg-secondary: var(--gray-200);
  --bg-tertiary: var(--gray-300);
  --text-primary: var(--gray-900);
  --border-color: var(--gray-500);
  --text-secondary: var(--gray-700);
  --bg-transparent-primary: rgba(249, 249, 249, 0.6);
  --bg-transparent-secondary: rgba(249, 249, 249, 0.5);
  --button-bg: var(--bg-primary);
  --button-border: var(--border-color);
  --button-text: var(--text-primary);
  --invert: invert(100%);
  /* Theme toggle - Light mode */
  --theme-toggle-position: 0;
  --theme-toggle-translate: 0rem;
  --theme-toggle-color: var(--color7);
  --theme-toggle-icon: url("/assets/img/icons/sun.svg");
  --theme-toggle-icon-color: var(--gray-900);
}

:root[data-theme="dark"] {
  --bg: url(/assets/img/bg/dark-bg.webp);
  --bg-primary: var(--gray-900);
  --bg-secondary: var(--gray-800);
  --bg-tertiary: var(--gray-700);
  --text-primary: var(--gray-100);
  --border-color: var(--gray-500);
  --text-secondary: var(--gray-200);
  --bg-transparent-primary: rgba(26, 26, 26, 0.8);
  --bg-transparent-secondary: rgba(26, 26, 26, 0.5);

  --button-bg: var(--bg-primary);
  --button-border: var(--border-color);
  --button-text: var(--text-primary);
  --invert: invert(0%);
  /* Theme toggle - Dark mode */
  --theme-toggle-position: 1;
  --theme-toggle-translate: calc(1.8rem);
  --theme-toggle-color: var(--gray-700);
  --theme-toggle-icon: url("/assets/img/icons/moon.svg");
  --theme-toggle-icon-color: var(--gray-200);
}

:root[data-survivant="true"] {
  --bg: url(/assets/img/bg/jungle.webp);
  --survivant-mode: 1;
  --survivant-toggle-translate: calc(0rem);
  --survivant-toggle-color: var(--color4);
  --survivant-toggle-icon: url("/assets/img/icons/tree.svg");

  .big-container {
    border: none !important;
    width: calc(100% - 1.5rem + 4px) !important;
  }
}

/* ===== COMBINED MODES ===== */
/* Survivant + Dark Mode */
:root[data-theme="dark"][data-survivant="true"] {
  --bg-primary: var(--gray-900);
  --bg-secondary: var(--gray-800);
  --bg-tertiary: var(--gray-700);
  --text-primary: var(--gray-100);
  --border-color: var(--gray-500);
  --text-secondary: var(--gray-200);
  --bg-transparent-primary: rgba(26, 26, 26, 0.8);
  --bg-transparent-secondary: rgba(26, 26, 26, 0.5);
  --invert: invert(0%);

  --button-bg: var(--bg-primary);
  --button-border: var(--border-color);
  --button-text: var(--text-primary);
}

/* Survivant + Light Mode */
:root[data-theme="light"][data-survivant="true"] {
  --bg-primary: var(--gray-100);
  --bg-secondary: var(--gray-200);
  --bg-tertiary: var(--gray-300);
  --text-primary: var(--gray-900);
  --border-color: var(--gray-500);
  --text-secondary: var(--gray-700);
  --bg-transparent-primary: rgba(249, 249, 249, 0.8);
  --bg-transparent-secondary: rgba(249, 249, 249, 0.6);

  --button-bg: var(--bg-secondary);
  --button-border: var(--text-primary);
  --button-text: var(--text-primary);

  .big-container {
    border: none !important;
  }
}

* {
  min-width: 0;
  -webkit-tap-highlight-color: transparent;
}

/* ===== BASE ELEMENTS ===== */
body {
  padding: 0;
  margin: 0;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  font-family: "Dosis", sans-serif;
  font-optical-sizing: auto;
  font-weight: 400;
  font-style: normal;
  min-height: calc(100vh);
}

h1 {
  font-size: 2.5rem;
  line-height: 1;
  color: var(--text-primary);
  margin: 0;
  font-family: "Bebas Neue", sans-serif;
  font-weight: 400;
  padding-top: 2.5rem;
  padding-bottom: 1.5rem;
  transform: translateY(0.5rem);
  text-align: center;
}
h2 {
  font-family: "Bebas Neue", sans-serif;
  font-weight: 400;
  width: 100%;
  font-size: 2rem;
  color: var(--text-primary);
  max-width: 36rem;
  margin: 0;
}

h3 {
  font-family: "Dosis", sans-serif;
  font-weight: 700;
  width: 100%;
  font-size: 1rem;
  color: var(--text-primary);
  max-width: 36rem;
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

.fineprint {
  font-family: "Dosis", sans-serif;
  font-weight: 400;
  font-size: 0.875rem;
  line-height: 1.25rem;
  color: var(--text-secondary);
  max-width: 36rem;
  width: 100%;
  margin-top: 0.25rem;
  margin-bottom: 0.25rem;
}

.box-references {
  font-family: "Dosis", sans-serif;
  font-weight: 400;
  font-size: 0.875rem;
  line-height: 1.25rem;
  color: var(--text-secondary);
  max-width: 36rem;
  width: 100%;
  margin-top: 0.25rem;
  margin-bottom: 0.25rem;
  margin-left: 1rem;
  text-decoration-line: underline;
  cursor: pointer;
}

p-footer {
  color: var(--text-primary);
}

a[hx-get] {
  color: inherit;
  text-decoration: none;
  text-decoration-line: underline;
  font-weight: 400;
  font-family: "Dosis", sans-serif;
}

a[hx-get]:hover {
  cursor: pointer;
}

.small-error-text {
  color: var(--error, red);
  font-size: 0.875rem;
}

.big-error-text {
  color: var(--error, red);
  font-size: 1rem;
  text-align: center;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

.big-success-text {
  color: var(--color9, green);
  font-size: 1rem;
  text-align: center;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

/* ===== LAYOUT & CONTAINERS ===== */
#content {
  min-height: calc(100vh);
  margin-left: auto;
  margin-right: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
  gap: 0.5rem;
}

#background {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  background-size: cover;
  background-position: right center;
  background-repeat: no-repeat;
  transition: background 0.3s ease;
  height: 100vh;
  width: 100vw;
  z-index: -1;
}

.small-container {
  background-color: var(--bg-transparent-primary);
  border: 2px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 1.5rem;
  max-width: 36rem;
}

.big-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  background-color: var(--bg-transparent-primary);
  border: 2px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 0.5rem;
  min-height: calc(100vh - 2rem - 4px);
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
  width: calc(100% - 1.5rem);
}

.big-container > * {
  width: 100%;
  max-width: 36rem;
}

.transparent-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
  max-width: 36rem;
}

/* ===== UI COMPONENTS ===== */
.separator {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 20px 0;
  width: 100%;
  color: var(--text-secondary) !important;
  max-width: 36rem;
}

.separator > * {
  color: var(--text-secondary) !important;
}

.separator::before,
.separator::after {
  content: "";
  flex: 1;
  border-bottom: 1px solid var(--text-secondary);
}

.separator span {
  padding: 0 10px;
  color: #888;
}

.icon {
  margin-right: 10px;
}

/* ===== FORM ELEMENTS ===== */
input,
select,
textarea {
  width: 100%;
  max-width: 36rem;
  margin-top: 0.25rem;
  margin-bottom: 0.25rem;
  box-sizing: border-box;
  border-radius: 0.375rem;
  border-width: 2px;
  border-style: solid;
  outline: 2px solid transparent;
  outline-offset: 2px;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
  padding-left: 0.75rem;
  padding-right: 0.75rem;
  background-color: var(--bg-secondary, white);
  color: var(--text-primary, black);
  border-color: var(--border-color, black);
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  box-shadow: none;
  font-family: inherit;
  font-size: inherit;
}

select {
  cursor: pointer;
}

input[type="password"] {
  padding-right: 2.5rem;
}

input:focus,
select:focus {
  border-style: dashed;
}

input[type="radio"],
input[type="checkbox"] {
  /* Remove custom styles to revert to default */
  -webkit-appearance: auto;
  -moz-appearance: auto;
  appearance: auto;
  width: auto;
  height: auto;
  border: none;
  border-radius: 0;
  outline: none;
  cursor: pointer;
  background-color: transparent;
  margin: 0;
  vertical-align: middle;
  margin-right: 0.25rem;
}

input[type="radio"],
input[type="checkbox"]:checked {
  background-color: transparent;
  border-color: inherit;
}

input[type="radio"],
input[type="checkbox"]:focus {
  box-shadow: none;
}

input:disabled {
  background-color: var(--bg-tertiary, gray);
  color: var(--text-secondary, gray);
  border-color: var(--border-color, gray);
  cursor: not-allowed;
}

button[type="submit"],
button[hx-get],
button.submit,
button[onclick] {
  max-width: 36rem;
  position: relative;
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
  width: 100%;
  color: var(--gray-100, white);
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.5;
  border-radius: 0.375rem;
  height: 40px;
  padding: 0 0.5rem;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button.primary {
  background: linear-gradient(
    to right,
    var(--color-primary, black),
    var(--color-primary-dark, black)
  );
  border: 2px solid var(--color-primary-dark, white);
}
button.secondary {
  background: linear-gradient(
    to right,
    var(--color-secondary, black),
    var(--color-secondary-dark, black)
  );
  border: 2px solid var(--color-secondary-dark, white);
}
button.tertiary {
  background: linear-gradient(
    to right,
    var(--color-tertiary, black),
    var(--color-tertiary-dark, black)
  );
  border: 2px solid var(--color-tertiary-dark, white);
}
button.accept {
  background: linear-gradient(
    to right,
    var(--color4, black),
    var(--color9, black)
  );
  border: 2px solid var(--color9, white);
}
button.deny {
  background: linear-gradient(
    to right,
    var(--color5, black),
    var(--color13, black)
  );
  border: 2px solid var(--color13, white);
}

button.big-button {
  width: 100%;
  max-width: 36rem;
  border: none;
  box-shadow:
    0 20px 25px -5px rgb(0 0 0 / 0.1),
    0 8px 10px -6px rgb(0 0 0 / 0.1);
}

li.fiche-link {
  line-height: 2;
  text-decoration-line: none;
  cursor: pointer;
  font-size: 1.25rem;
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

/* ===== UTILITY CLASSES ===== */
[x-cloak] {
  display: none !important;
}

p-guide-title {
  min-height: 135px;
}

.box-title[hx-get] {
  font-family: "Bebas Neue", sans-serif;
  font-weight: 400;
  width: 100%;
  font-size: 2.5rem;
  /* color: var(--text-primary); */
  max-width: 36rem;
  margin: 0;
  cursor: pointer;
}

.box-title[hx-get="/guide/viewer#sep_vitales"] {
  color: var(--color11);
}

.box-title[hx-get="/guide/viewer#sep_legale"] {
  color: var(--color15);
}

.box-title[hx-get^="/guide/viewer#orthoinf"],
.box-title[hx-get^="/guide/viewer#traumato"] {
  color: var(--color5);
}

.box-title[hx-get^="/guide/viewer#orl"],
.box-title[hx-get^="/guide/viewer#chirthor"],
.box-title[hx-get^="/guide/viewer#uro"],
.box-title[hx-get^="/guide/viewer#chirgen"] {
  color: var(--color4);
}

.box-title[hx-get^="/guide/viewer#cardio"],
.box-title[hx-get^="/guide/viewer#dermato"],
.box-title[hx-get^="/guide/viewer#endocrino"],
.box-title[hx-get^="/guide/viewer#hemato"],
.box-title[hx-get^="/guide/viewer#infectieux"],
.box-title[hx-get^="/guide/viewer#medint"],
.box-title[hx-get^="/guide/viewer#nephro"],
.box-title[hx-get^="/guide/viewer#neuro"],
.box-title[hx-get^="/guide/viewer#pneumo"],
.box-title[hx-get^="/guide/viewer#rhumato"],
.box-title[hx-get^="/guide/viewer#gastro"] {
  color: var(--color2);
}

.box-title[hx-get^="/guide/viewer#psy"] {
  color: var(--color4);
}

.box-title[hx-get^="/guide/viewer#pedopsy"] {
  color: var(--color7);
}

.conclusion {
  margin-top: 1rem;
}

input[type="radio"],
input[type="checkbox"]:has(> label) {
  margin-bottom: 0.5rem;
}

div.score {
  line-height: 1.75;
}

/* ===== TABLE STYLES ===== */
.styled-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 1rem;
  text-align: left;
  background-color: var(--bg-transparent-primary);
  border: 2px solid var(--border-color);
  border-radius: 0.75rem;
  overflow: hidden;
}

.styled-table th,
.styled-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
}

.styled-table th {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  font-weight: 700;
  text-align: center;
}

.styled-table tr:nth-child(even) {
  background-color: var(--bg-tertiary);
}

.styled-table tr:last-child td {
  border-bottom: none;
}

.styled-table td {
  color: var(--text-secondary);
  text-align: center;
}

/* ===== ADVERTISEMENT STYLES ===== */
.ad-rotator {
  position: relative;
  width: 100%;
  max-width: 36rem;
  /* Remove fixed aspect ratio so height is driven by the image */
  /* aspect-ratio: 640/144; */
  margin: 0 auto;
  background-color: #f9f9f9;
  border-radius: 0.5rem;
  overflow: hidden; /* keep if you want rounded corners to clip the image */
}

.ad-container {
  /* Let items participate in normal flow so height follows the visible image */
  position: relative;
  width: 100%;
  /* Remove opacity/absolute layering, we’ll rely on x-show to hide non-active items */
  /* height: 100%; */
  /* opacity: 0; */
  /* transition: opacity 1s ease-in-out; */
}

/* No need for .active opacity toggling anymore */
/* .ad-container.active {
  opacity: 1;
  z-index: 1;
} */

.ad-container img {
  display: block;
  width: 100%;
  height: auto; /* Let image height define the container height */
  object-fit: contain;
}

/* Popup Ad Styles */
#popup-ad-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.popup-ad {
  position: relative;
  max-width: 90%;
  max-height: 90%;
  background-color: var(--bg-primary);
  border-radius: 0.75rem;
  overflow: hidden;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.popup-ad img {
  display: block;
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
}

.popup-ad .close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background-color: rgba(0, 0, 0, 0.8);
  color: white;
  border: none;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0;
  z-index: 10;
}

.popup-ad .close-btn:hover {
  background-color: rgba(0, 0, 0, 0.9);
}

/* Lazy Image Container */
.lazy-image-container {
  display: block;
  aspect-ratio: 7 / 10;
  background-color: var(--bg-primary);
  margin-left: auto;
  margin-right: auto;
}

/* dev mode banner ribbon on the top right side */
#dev-mode-banner {
  position: fixed;
  top: 6rem;
  right: 0;
  padding: 0.5rem 6rem;
  background-color: var(--color5);
  color: var(--gray-100);
  font-weight: bold;
  font-size: 1rem;
  transform: rotate(45deg) translateY(1rem) translateX(4rem);
  transform-origin: top right;
  z-index: 20;
  /* shadow */
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
  border-radius: 0.5rem;
}

#dev-mode-banner span {
  display: inline-block;
  transform: rotate(-45deg);
}
