@import url('brand-tokens.css');

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.4;
  color: var(--pc-text);
  background:
    linear-gradient(165deg, var(--club-aquablue-soft) 0%, var(--pc-bg) 38%, var(--club-cerbere-soft) 100%);
}

/* --- Layout portail --- */

.portal {
  min-height: 100dvh;
  padding: calc(1rem + var(--safe-top)) 1rem calc(1.25rem + var(--safe-bottom));
  max-width: 28rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.portal__top {
  margin-bottom: 1.5rem;
}

.portal__club-strip {
  display: flex;
  gap: 5px;
  margin-bottom: 0.65rem;
  border-radius: 6px;
  overflow: hidden;
}

.portal__club-strip span {
  flex: 1;
  height: 4px;
}

.portal__club-strip span:nth-child(1) { background: var(--club-aquablue); }
.portal__club-strip span:nth-child(2) { background: var(--club-rederis); }
.portal__club-strip span:nth-child(3) { background: var(--club-cerbere-accent); }

.portal__club-logos {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
  padding: 0;
  list-style: none;
}

.portal__club-logos li {
  flex: 1;
  display: flex;
  justify-content: center;
}

.portal__club-logo {
  width: 100%;
  height: 3rem;
  object-fit: contain;
  object-position: center;
  filter: drop-shadow(0 1px 2px rgba(19, 37, 52, 0.08));
}

.portal__eyebrow {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--pc-accent);
}

.portal__title {
  margin: 0.15rem 0 0;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.15;
}

/* --- Grille apps --- */

.apps {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  align-content: start;
}

.app-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  min-height: 9.5rem;
  padding: 1.25rem 0.75rem;
  border-radius: 20px;
  background: var(--pc-surface);
  border: 2px solid var(--pc-border);
  box-shadow: var(--pc-shadow);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, transform 0.1s;
}

.app-tile:active {
  transform: scale(0.98);
  border-color: var(--pc-accent);
  background: var(--pc-accent-soft);
}

.app-tile__icon {
  width: 4.5rem;
  height: 4.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  background: var(--pc-accent-soft);
  color: var(--pc-accent);
}

.app-tile__icon svg {
  width: 2.75rem;
  height: 2.75rem;
}

.app-tile__label {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.2;
}

.app-tile--solo {
  grid-column: 1 / -1;
  min-height: 10.5rem;
}

.app-tile--solo .app-tile__icon {
  width: 5.5rem;
  height: 5.5rem;
}

.app-tile--solo .app-tile__icon svg {
  width: 3.25rem;
  height: 3.25rem;
}

.app-tile--solo .app-tile__label {
  font-size: 1.15rem;
}

.app-tile__external,
.app-tile__env {
  position: absolute;
  top: 0.65rem;
  right: 0.75rem;
  width: 0.85rem;
  height: 0.85rem;
  pointer-events: none;
}

.app-tile__external {
  color: var(--pc-muted);
}

.app-tile__env {
  display: block;
}

.app-tile__env--prod {
  color: #2e7d32;
}

.app-tile__env--test {
  color: #b86e00;
}

.app-tile__icon--mabadive {
  background: #e8f3f7;
  color: #197297;
}

.app-tile--mabadive:active {
  border-color: #197297;
  background: #e8f3f7;
}

.app-tile__icon--cover {
  padding: 0;
  overflow: hidden;
  background: #0d3a6e;
}

.app-tile__icon--cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.app-tile--ffessm-carnet:active {
  border-color: #0c9aa7;
  background: #e8f4f8;
}

/* --- Pied de page --- */

.portal__footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--pc-border);
  font-size: 0.8rem;
  color: var(--pc-muted);
  text-align: center;
}

.portal__footer a {
  color: var(--pc-accent);
  text-decoration: none;
  padding: 0.5rem;
  display: inline-block;
  min-height: var(--pc-tap-min);
  line-height: calc(var(--pc-tap-min) - 1rem);
}

/* --- Page install + QR --- */

.install-page {
  min-height: 100dvh;
  padding: calc(1rem + var(--safe-top)) 1.25rem calc(1.5rem + var(--safe-bottom));
  max-width: 28rem;
  margin: 0 auto;
}

.install-page__back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: var(--pc-tap-min);
  margin-bottom: 1rem;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--pc-accent);
  text-decoration: none;
}

.install-page__back:active {
  opacity: 0.7;
}

.install-page h1 {
  margin: 0 0 0.5rem;
  font-size: 1.6rem;
  font-weight: 700;
}

.install-page__lead {
  margin: 0 0 1.5rem;
  color: var(--pc-muted);
  font-size: 1rem;
}

/* --- Page connexion --- */

.login-page {
  min-height: 100dvh;
  padding: calc(1.5rem + var(--safe-top)) 1.25rem calc(1.5rem + var(--safe-bottom));
  max-width: 28rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-page__brand {
  margin-bottom: 1.5rem;
}

.login-page__title {
  margin: 0.15rem 0 0.5rem;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.15;
}

.login-page__lead {
  margin: 0;
  color: var(--pc-muted);
  font-size: 0.95rem;
  line-height: 1.45;
}

.login-card {
  padding: 1.25rem;
  border-radius: 20px;
  background: var(--pc-surface);
  border: 2px solid var(--pc-border);
  box-shadow: var(--pc-shadow);
}

.login-card__label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.login-card__input {
  width: 100%;
  min-height: 3rem;
  padding: 0.65rem 0.85rem;
  border: 2px solid var(--pc-border);
  border-radius: 14px;
  font: inherit;
  font-size: 1rem;
  color: var(--pc-text);
  background: var(--pc-bg);
}

.login-card__input:focus {
  outline: none;
  border-color: var(--pc-accent);
  box-shadow: 0 0 0 3px var(--pc-accent-soft);
}

.login-card__input[aria-invalid="true"] {
  border-color: #c0392b;
}

.login-card__error {
  margin: 0.65rem 0 0;
  font-size: 0.9rem;
  color: #c0392b;
}

.login-card__submit {
  width: 100%;
  min-height: var(--pc-tap-min);
  margin-top: 1rem;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--club-aquablue) 0%, var(--pc-accent) 50%, var(--club-cerbere) 100%);
  color: #fff;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.login-card__submit:active {
  transform: scale(0.98);
  opacity: 0.92;
}

.install-card {
  padding: 1.5rem;
  border-radius: 20px;
  background: var(--pc-surface);
  border: 2px solid var(--pc-border);
  box-shadow: var(--pc-shadow);
  text-align: center;
  margin-bottom: 1.25rem;
}

.install-card__qr {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
}

.install-card__qr canvas,
.install-card__qr img {
  border-radius: 12px;
}

.install-card__url {
  margin: 0;
  font-size: 0.85rem;
  color: var(--pc-muted);
  word-break: break-all;
}

.install-card__url strong {
  color: var(--pc-text);
  font-weight: 600;
}

.install-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 3.5rem;
  margin-bottom: 1rem;
  padding: 0.75rem 1.25rem;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--club-aquablue) 0%, var(--pc-accent) 50%, var(--club-cerbere) 100%);
  border: none;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: var(--pc-shadow);
}

.install-btn:active {
  transform: scale(0.98);
  filter: brightness(1.05);
}

.install-btn:disabled,
.install-btn--hidden {
  display: none;
}

.install-steps {
  padding: 1.25rem;
  border-radius: 16px;
  background: var(--pc-accent-soft);
  border: 1px solid var(--pc-border);
}

.install-steps h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 600;
}

.install-steps ol {
  margin: 0;
  padding-left: 1.25rem;
  color: var(--pc-muted);
  font-size: 0.95rem;
}

.install-steps li {
  margin-bottom: 0.5rem;
}

.install-steps li:last-child {
  margin-bottom: 0;
}

/* --- Stub app --- */

.app-shell {
  min-height: 100dvh;
  padding: calc(1rem + var(--safe-top)) 1rem calc(1.25rem + var(--safe-bottom));
  max-width: 28rem;
  margin: 0 auto;
}

.app-shell__back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: var(--pc-tap-min);
  margin-bottom: 1.25rem;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--pc-accent);
  text-decoration: none;
}

.app-shell__header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.app-shell__icon {
  width: 4rem;
  height: 4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  background: var(--pc-accent-soft);
  color: var(--pc-accent);
}

.app-shell__icon svg {
  width: 2.5rem;
  height: 2.5rem;
}

.app-shell__title {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 700;
}

.app-shell__stub {
  padding: 1.5rem;
  border-radius: 16px;
  background: var(--pc-surface);
  border: 2px solid var(--pc-border);
  color: var(--pc-muted);
  text-align: center;
  font-size: 1rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (min-width: 400px) {
  .apps {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* --- Bannière mise à jour (app-update.js) --- */

.pc-update-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
  padding: 0.85rem 1rem calc(0.85rem + var(--safe-bottom));
  background: var(--pc-text);
  color: #fff;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.2);
}

.pc-update-banner__text {
  margin: 0;
  flex: 1 1 12rem;
  font-size: 0.9rem;
  line-height: 1.35;
}

.pc-update-banner__meta {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.78rem;
  font-weight: 500;
  opacity: 0.75;
}

.pc-update-banner__actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.pc-update-banner__btn {
  min-height: 2.5rem;
  padding: 0.45rem 0.85rem;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: transparent;
  color: #fff;
  cursor: pointer;
}

.pc-update-banner__btn--primary {
  background: var(--pc-accent);
  border-color: var(--pc-accent);
}

/* --- Page migration PWA (update.html) --- */

.update-page {
  max-width: 28rem;
  margin: 0 auto;
  text-align: center;
}

.update-page__status {
  text-align: center;
  padding: 2rem 1rem;
}

.update-page__lead {
  text-align: left;
}

.update-page__actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.update-page__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  width: 100%;
  box-sizing: border-box;
}

.update-page__continue {
  min-height: 2.75rem;
  padding: 0.5rem 1rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--pc-muted, #5a6b7a);
  background: transparent;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
