/* ===== 1. Design tokens ===== */
:root {
  --ocp-bg:        linear-gradient(155deg, #d5e9ee, #f9e8d3 65%, #eadcf0);
  --ocp-surface:   #fffdf8;
  --ocp-surface-2: #f3e1c9;
  --ocp-text:      #253b48;
  --ocp-muted:     #4f6270;
  --ocp-navy:      #20384d;
  --ocp-accent:    #ef9d56;
  --ocp-accent-bg: #ffe2a4;
  --ocp-accent-bd: #d8a15b;
  --ocp-line:      #bfd4d7;
  --ocp-focus:     #0a6fa0;
  --ocp-danger:    #b3261e;
  --ocp-radius:    20px;
  --ocp-shadow:    0 6px 0 #bfcfd0aa;
  --ocp-transition: 0.18s ease;
}

/* ===== 2. Thème sombre (suit le système, sauf choix explicite) ===== */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ocp-bg: linear-gradient(155deg, #14232f, #2a2433 70%, #1b2a2b);
    --ocp-surface: #1f3141; --ocp-surface-2: #2c4458;
    --ocp-text: #eef4f6; --ocp-muted: #b9c8d0; --ocp-navy: #eef4f6;
    --ocp-accent-bg: #7a5a22; --ocp-accent-bd: #e0b45e; --ocp-line: #43606f;
    --ocp-focus: #7fd0f5; --ocp-danger: #ff8a80; --ocp-shadow: 0 6px 0 #0006;
  }
}

/* ===== 3. Layout : plein écran, la page ne défile jamais ===== */
html, body { height: 100%; overflow: hidden; background: #e8eef0; }
.ocp-app {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; gap: 8px;
  max-width: 1100px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 8px) 12px calc(env(safe-area-inset-bottom) + 10px);
  background: var(--ocp-bg); color: var(--ocp-text);
  font-family: Nunito, 'Trebuchet MS', Verdana, system-ui, sans-serif;
  line-height: 1.35;
}
@media (min-width: 1100px) { .ocp-app { box-shadow: 0 0 40px #0002; } }

/* ===== 4. Zone A : barre du haut ===== */
.ocp-top { flex: none; display: flex; align-items: center; gap: 8px; }
.ocp-meter { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; font-weight: 900; color: var(--ocp-navy); }
.ocp-meter-keys { white-space: nowrap; font-size: clamp(.9rem, 2.2vw, 1.05rem); }
.ocp-bar { flex: 1; height: 12px; max-width: 280px; border-radius: 30px; background: #dce7e9; border: 1px solid #b6c7cc; overflow: hidden; }
.ocp-bar i { display: block; height: 100%; width: 0; background: #e7ac57; transition: width .5s ease; }

/* ===== 5. Zone B : scène (illustration + texte + actions) ===== */
.ocp-stage { flex: 1; min-height: 0; display: flex; flex-direction: column; outline: none; }
.ocp-scene {
  flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px;
  background: var(--ocp-surface); border: 2px solid var(--ocp-surface-2);
  border-radius: 26px; box-shadow: var(--ocp-shadow); overflow: hidden;
  animation: ocp-in .3s cubic-bezier(.2,.75,.2,1) both;
}
.ocp-art {
  flex: 0 1 25dvh; min-height: 0; position: relative; overflow: hidden;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--ocp-scene, #a6cdda), #fdf2d2);
}
.ocp-art::before, .ocp-art::after { content: ''; position: absolute; border: 3px solid #ffffff7a; border-radius: 50%; }
.ocp-art::before { width: 300px; height: 300px; left: -90px; top: 40%; }
.ocp-art::after  { width: 350px; height: 350px; right: -70px; top: -150px; }
.ocp-art-icon { position: relative; z-index: 1; font-size: min(17dvh, 30vw); line-height: 1; filter: drop-shadow(0 8px 3px #1b3d402e); animation: ocp-bob 4s ease-in-out infinite; }
.ocp-body { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; padding: 0 clamp(14px, 3vw, 30px); }
.ocp-eyebrow { flex: none; font-size: clamp(.65rem, 1.4dvh + .6vw, .8rem); letter-spacing: .12em; font-weight: 900; text-transform: uppercase; color: var(--ocp-muted); }
.ocp-h { flex: none; font-family: inherit; font-weight: 900; font-size: clamp(1.2rem, 1.6vw + 2.6dvh, 2.2rem); line-height: 1.12; color: var(--ocp-navy); margin: 2px 0 6px; }
.ocp-text { flex: 1 1 0; min-height: 0; overflow: hidden; font-size: var(--ocp-fs, 20px); line-height: 1.5; }
.ocp-text p + p { margin-top: .55em; }
.ocp-hint { margin-top: .6em; padding: .4em .8em; font-size: .72em; background: #f7f0ff; color: #3d3566; border-left: 6px solid #a69acf; border-radius: 10px; }
.ocp-actions { flex: none; display: grid; gap: clamp(6px, 1.2dvh, 12px); padding: 0 clamp(14px, 3vw, 30px) clamp(10px, 2dvh, 20px); }

/* ===== 6. Zone C : la maison des portes ===== */
.ocp-hub { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; padding: clamp(10px, 2dvh, 22px) clamp(12px, 3vw, 28px); background: var(--ocp-surface); border: 2px solid var(--ocp-surface-2); border-radius: 26px; box-shadow: var(--ocp-shadow); animation: ocp-in .3s both; }
.ocp-hub-sub { flex: none; font-size: clamp(.9rem, 1.2vw + 1.6dvh, 1.2rem); color: var(--ocp-muted); }
.ocp-portals { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); gap: clamp(6px, 1.4vw, 14px); }

/* ===== 7. Écrans larges : illustration à gauche, texte à droite ===== */
@media (min-aspect-ratio: 5/4) and (min-width: 760px) {
  .ocp-scene { display: grid; grid-template-columns: 38% minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; gap: 0 10px; }
  .ocp-art { grid-row: 1 / 3; flex: none; }
  .ocp-art-icon { font-size: min(32dvh, 22vw); }
  .ocp-body { padding-top: clamp(10px, 3dvh, 28px); }
  .ocp-portals { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ===== 8. Paysage très bas (téléphone couché) ===== */
@media (max-height: 480px) {
  .ocp-app { gap: 4px; padding-top: calc(env(safe-area-inset-top) + 4px); padding-bottom: calc(env(safe-area-inset-bottom) + 4px); }
  .ocp-hub-sub { display: none; }
  .ocp-portals { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .ocp-eyebrow, .ocp-hint { display: none; }
  .ocp-text { line-height: 1.3; }
  .ocp-text p + p { margin-top: .3em; }
  .ocp-h { margin: 0 0 2px; }
  .ocp-actions { grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); padding-bottom: 8px; }
  .ocp-actions .ocp-btn { min-height: 40px; padding: 4px 10px; font-size: .9rem; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@keyframes ocp-in  { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes ocp-bob { 50% { transform: translateY(-6px) rotate(2deg); } }

/* ===== 9. Mode compact : le texte ne tient pas avec l'illustration → on la masque ===== */
.ocp-compact .ocp-art { display: none; }
.ocp-compact.ocp-scene { grid-template-columns: minmax(0, 1fr); }
