/* crossword.css - Styles pour le jeu de mots fléchés */

/* ---- Layout principal ---- */
.cw-container {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100dvh;
  font-family: Arial, sans-serif;
  overflow: hidden;
  --cw-toolbar-bg: #e5e5e5;
  --cw-toolbar-fg: #333333;
}

.cw-container.cw-fullscreen {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 2147483647;
  background: #fff;
}

/* ---- Top bar (clavier toggle) ---- */
.cw-top-bar {
  display: flex;
  align-items: center;
  padding: 2px 6px;
  background: var(--cw-toolbar-bg);
  border-radius: 4px 4px 0 0;
  flex-shrink: 0;
}

.cw-kb-toggle {
  background: none;
  border: 1px solid color-mix(in srgb, var(--cw-toolbar-fg) 30%, transparent);
  color: var(--cw-toolbar-fg);
  border-radius: 3px;
  padding: 4px 10px;
  font-size: 16px;
  cursor: pointer;
}

.cw-kb-toggle:hover {
  background: color-mix(in srgb, var(--cw-toolbar-fg) 12%, transparent);
}

/* ---- Bannière définition ---- */
.cw-banner-slot {
  flex-shrink: 0;
}

.cw-banner {
  display: flex;
  align-items: center;
  background: var(--cw-def-bg, #f6f5f4);
  color: var(--cw-def-fg, #000000);
  padding: 4px 6px;
  gap: 6px;
  border-radius: 4px 4px 0 0;
  min-height: 28px;
}

.cw-banner-btn {
  background: none;
  border: none;
  color: var(--cw-def-fg, #000000);
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
  flex-shrink: 0;
}

.cw-banner-text {
  flex: 1;
  text-align: center;
  font-size: 13px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- Zone puzzle ---- */
.cw-puzzle-wrapper {
  position: relative;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}

.cw-puzzle-wrapper canvas {
  margin: auto;
  display: block;
}

/* ---- Top bar (tous les contrôles) ---- */
.cw-top-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  background: var(--cw-toolbar-bg);
  color: var(--cw-toolbar-fg);
  border-radius: 4px 4px 0 0;
  flex-shrink: 0;
  min-height: 36px;
}

.cw-kb-toggle {
  background: none;
  border: 1px solid color-mix(in srgb, var(--cw-toolbar-fg) 30%, transparent);
  color: var(--cw-toolbar-fg);
  border-radius: 3px;
  padding: 4px 10px;
  font-size: 16px;
  cursor: pointer;
}

.cw-kb-toggle:hover {
  background: color-mix(in srgb, var(--cw-toolbar-fg) 12%, transparent);
}

.cw-top-bar input[type="range"] {
  width: 70px;
  height: 22px;
  margin: 0 2px;
}

.cw-top-bar .cw-title {
  flex: 1;
  min-width: 0;
  text-align: left;
  font-size: 14px;
  font-weight: 600;
  color: var(--cw-toolbar-fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 8px;
}

.cw-top-bar .cw-zoom-value {
  font-size: 12px;
  min-width: 34px;
  text-align: right;
}

.cw-top-bar button {
  background: none;
  border: 1px solid color-mix(in srgb, var(--cw-toolbar-fg) 30%, transparent);
  color: var(--cw-toolbar-fg);
  border-radius: 3px;
  padding: 4px 8px;
  font-size: 14px;
  min-height: 32px;
  cursor: pointer;
  flex-shrink: 0;
}

.cw-top-bar button:hover {
  background: color-mix(in srgb, var(--cw-toolbar-fg) 12%, transparent);
}

/* ---- Bottom bar (décorative) ---- */
.cw-bottom-bar {
  height: 6px;
  background: var(--cw-toolbar-bg);
  border-radius: 0 0 4px 4px;
  flex-shrink: 0;
}

/* ---- Menu aide (popup) ---- */
.cw-help-wrap {
  position: relative;
  display: inline-flex;
  flex: 1;
}

.cw-help-wrap .cw-kb-key {
  width: 100%;
}

.cw-help-popup {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  color: #333;
  border: 1px solid #ccc;
  border-radius: 6px;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.2);
  z-index: 100;
  padding: 4px 0;
  min-width: 180px;
  margin-bottom: 4px;
}

.cw-help-popup.cw-open {
  display: block;
}

.cw-top-bar .cw-help-popup {
  bottom: auto;
  top: 100%;
  margin-bottom: 0;
  margin-top: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.cw-top-bar .cw-help-wrap {
  flex: none;
}

.cw-help-sep {
  border-top: 1px solid #ddd;
  margin: 4px 0;
}

.cw-help-item {
  padding: 8px 16px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
}

.cw-help-item:hover {
  background: #f0f0f0;
}

/* ---- Clavier virtuel ---- */
.cw-kb-panel {
  background: #d1d5db;
  border-top: 2px solid #9ca3af;
  padding: 6px 8px 10px;
  display: none;
  user-select: none;
  -webkit-user-select: none;
  flex-shrink: 0;
}

.cw-kb-panel.cw-open {
  display: block;
}

.cw-kb-row {
  display: flex;
  gap: 3px;
  margin-bottom: 3px;
}

.cw-kb-row.cw-kb-centered {
  justify-content: center;
}

.cw-kb-key {
  height: 46px;
  border: none;
  border-radius: 5px;
  background: #fff;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
  flex: 1;
}

.cw-kb-key.cw-kb-wide {
  flex: 1;
}

.cw-kb-key[data-letter] {
  flex: 1;
}

.cw-kb-key[data-action="backspace"] {
  background: #9ca3af;
  color: #fff;
}

.cw-kb-key[data-action="close-keyboard"] {
  background: #9ca3af;
  color: #fff;
  font-size: 12px;
  font-weight: normal;
  flex: 1;
}

.cw-kb-key[data-action="help"] {
  font-size: 12px;
  font-weight: normal;
  flex: 1;
}

/* ---- Dialogue de victoire ---- */
.cw-solve-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  z-index: 2147483647;
  overscroll-behavior: contain;
}

.cw-solve-modal {
  background: #fff;
  color: #333;
  border-radius: 10px;
  padding: 26px 28px;
  max-width: 320px;
  width: 88%;
  text-align: center;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
  animation: cw-solve-pop 0.25s ease-out;
}

.cw-solve-title {
  font-size: 22px;
  font-weight: 700;
  color: #1a7f37;
  margin-bottom: 8px;
}

.cw-solve-text {
  font-size: 15px;
  line-height: 1.4;
  color: #444;
  margin: 0 0 18px;
}

.cw-solve-ok {
  min-width: 96px;
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: 6px;
  background: #1a7f37;
  color: #fff;
  cursor: pointer;
}

.cw-solve-ok:hover {
  background: #14642b;
}

.cw-solve-ok:focus {
  outline: 2px solid #1a7f37;
  outline-offset: 2px;
}

@keyframes cw-solve-pop {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ---- Impression ---- */
@media print {
  .cw-top-bar { display: none !important; }
  .cw-bottom-bar { display: none !important; }
  .cw-banner-slot  { display: none !important; }
  .cw-puzzle-wrapper { border: none; overflow: visible; }
  .cw-banner { border-radius: 0; }
  .cw-solve-overlay { display: none !important; }
}
