/* Socle visuel commun a tous les prototypes. Grayscale volontaire (voir cahier des charges, section A.10). */

:root {
  --bg: #e9e9e9;
  --ink: #111;
  --paper: #fff;
  --line: #333;
  --muted: #777;
  --panel-bg: #f4f4f4;
  --panel-border: #ccc;
  --ok: #1a7a1a;
  --bad: #a11;
  --phone-w: 390px;
  --phone-h: 844px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
}

.top-bar {
  width: 100%;
  max-width: 900px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.back-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}
.back-link:hover { color: var(--ink); }

.page-title {
  font-size: 15px;
  color: var(--muted);
  margin: 0;
}

.layout {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  justify-content: center;
  align-items: flex-start;
  width: 100%;
  max-width: 900px;
}

/* ---------- Faux telephone ---------- */

.phone-wrap {
  width: min(390px, 100%);
  flex-shrink: 0;
}

.phone-frame {
  width: var(--phone-w);
  height: var(--phone-h);
  transform-origin: top left;
  background: #000;
  border-radius: 34px;
  padding: 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.25);
}

.phone-screen {
  width: 100%;
  height: 100%;
  background: var(--paper);
  border-radius: 24px;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  display: flex;
  flex-direction: column;
}

.phone-header {
  padding: 16px 16px 8px;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
}

.phone-header h1 {
  font-size: 17px;
  margin: 0 0 4px;
}

.instruction {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

.game-area {
  position: relative;
  flex: 1 1 auto;
  overflow: hidden;
  touch-action: none;
  user-select: none;
}

.phone-footer {
  flex-shrink: 0;
  padding: 10px 16px 16px;
  border-top: 1px solid #eee;
}

.footer-row {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
}

.hint-text {
  min-height: 16px;
  font-size: 12px;
  color: var(--muted);
  margin: 4px 0;
}

.code-entry {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.code-digit {
  width: 34px;
  height: 40px;
  text-align: center;
  font-size: 18px;
  border: 1px solid #999;
  border-radius: 6px;
  background: #fafafa;
}

.code-feedback {
  min-height: 14px;
  font-size: 12px;
  margin: 4px 0 0;
}
.code-feedback.ok { color: var(--ok); }
.code-feedback.bad { color: var(--bad); }

/* ---------- Panneau de test (hors telephone) ---------- */

.test-panel {
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel-block {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 12px;
}

.panel-block h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 0 0 10px;
}

.control-row {
  margin-bottom: 10px;
}
.control-row:last-child { margin-bottom: 0; }

.control-row label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 4px;
}

.control-row input[type="range"] {
  width: 100%;
}

.button-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ---------- Boutons ---------- */

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  min-height: 40px;
  min-width: 44px;
  cursor: pointer;
}
.btn:hover { background: #f0f0f0; }
.btn:active { background: #e4e4e4; }

.btn-sm { padding: 8px 10px; font-size: 12px; min-height: 36px; }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { background: #000; }
.btn-outline { background: transparent; }
.btn-block { width: 100%; }
.btn.toggled { background: var(--ink); color: var(--paper); }

/* ---------- Debug panel ---------- */

.debug-panel {
  display: none;
  margin-top: 10px;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
  max-height: 220px;
  overflow-y: auto;
  border-top: 1px dashed var(--panel-border);
  padding-top: 8px;
}
.debug-panel.open { display: block; }

.debug-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 0;
  border-bottom: 1px dotted #ddd;
}
.debug-row span:first-child { color: var(--muted); }

@media (max-width: 760px) {
  .test-panel { width: 100%; max-width: 390px; }
}

/* ---------- Plein ecran mobile reel ---------- */
/* En dessous de 600px (toujours du mobile), plus d'interface de test/nav :
   le telephone occupe tout l'ecran, sans bordure ni coin arrondi. La regle
   de mise a l'echelle (fitPhoneFrame, shared/harness.js) bascule alors sur
   un mode "remplir l'ecran" (peut depasser scale=1, contrairement au mode
   desktop qui plafonne a 1) et centre le cadre — si le ratio de l'ecran ne
   correspond pas exactement au format logique du puzzle, des bandes noires
   apparaissent sur l'axe non contraignant plutot que de deformer/rogner. */
@media (max-width: 599px) {
  .app {
    padding: 0;
    min-height: 100dvh;
  }
  .top-bar,
  .test-panel {
    display: none;
  }
  .layout {
    max-width: none;
    width: 100%;
    gap: 0;
  }
  .phone-wrap {
    width: 100vw;
    height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    overflow: hidden;
  }
  .phone-frame {
    transform-origin: center;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
  }
  .phone-screen {
    border-radius: 0;
  }
}
