/* ============= WISIELEC – FRONT END ============= */
/* (c) 2025 edu-portal */
/* Ten plik jest ładowany wyłącznie na single-wisielec. */

#wisielec-game{
  --font-main: Arial, sans-serif;
  --bg-body:   #f6f6f6;
  --c-wood:    #8d6e63;
  --c-rope:    #d7ccc8;
  --c-figure:  #212121;
  --c-hit:     #2e7d32;
  --c-miss:    #c62828;
  --c-vowel:   #FFCDD2;
  --c-cons:    #BBDEFB;
  --c-inactive:#9e9e9e;
  --c-btn-bg:  #1976d2;
  --c-btn-bg-h:#1565c0;
}

/* ---------- global ---------- */
#wisielec-game{
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-body);
  font-family: var(--font-main);
  margin: 0;                /* nadpisuje Divi-padding w entry-content */
}
#wisielec-game *{ box-sizing: border-box; }

/* ---------- header ---------- */
#wisielec-game #header{
  position: sticky; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 20px; font-size: clamp(18px,6vw,24px);
  user-select: none; z-index: 99999; flex-wrap: wrap; gap: 16px;
  background: var(--bg-body); box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
#wisielec-game #timer{min-width:70px;text-align:center;}

/* ---------- main wrapper ---------- */
#wisielec-game #wrapper{
  flex:1; display:flex; flex-direction:column; justify-content:flex-start; align-items:center;
  gap: 15px; width:100%; padding-top: 10px; padding-bottom: 20px;
}

#wisielec-game .wisielec-round-message{
  min-height: 44px;
  width: min(560px, 95%);
  margin: 4px auto 0;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 160ms ease, transform 160ms ease;
  background: #f1f5f9;
  color: #0f172a;
  pointer-events: none;
}

#wisielec-game .wisielec-round-message.is-visible{
  opacity: 1;
  transform: translateY(0);
}

#wisielec-game .wisielec-round-message.success{
  background: #d4edda;
  color: #155724;
}

#wisielec-game .wisielec-round-message.error{
  background: #f8d7da;
  color: #721c24;
}

/* ---------- gallows ---------- */
#wisielec-game #gallows{ width:200px; height:260px; margin-top: 0; margin-bottom: 5px; }
#wisielec-game .wood  {stroke:var(--c-wood);  stroke-width:10;stroke-linecap:round;}
#wisielec-game .rope  {stroke:var(--c-rope);  stroke-width:6; stroke-linecap:round;}
#wisielec-game .figure{stroke:var(--c-figure);stroke-width:4; stroke-linecap:round;fill:none;}

/* ---------- word display ---------- */
#wisielec-game #word{
  font-size: clamp(32px,7vw,56px); letter-spacing:8px; font-weight:bold; text-align:center; margin: 0 0 5px 0;
}

/* ---------- keyboard ---------- */
#wisielec-game #keyboard{ display:grid; grid-template-columns:repeat(auto-fit,minmax(52px,1fr)); gap:8px; width:95%; max-width:550px; margin: 0 auto; padding: 5px 0; }
#wisielec-game .key{ padding:12px 0; border:none; border-radius:10px; font-size:22px; cursor:pointer; user-select:none; transition:background .2s,color .2s; color:var(--c-figure); font-weight:bold; }
#wisielec-game .vowel{background:var(--c-vowel);} 
#wisielec-game .consonant{background:var(--c-cons);} 
#wisielec-game .key:disabled{background:var(--c-inactive);color:#fff;cursor:default;}
#wisielec-game .hit{background:var(--c-hit)!important;color:#fff!important;}
#wisielec-game .miss{background:var(--c-miss)!important;color:#fff!important;}

/* ---------- popup (legacy + core) ---------- */
/* style both legacy #popup and core #omni-popup identically */
#wisielec-game #popup,
#omni-popup{
  position:fixed; top:50%; left:50%; transform:translate(-50%,-50%);
  background:#fff; padding:40px 60px; border-radius:20px; font-size:32px;
  box-shadow:0 8px 20px rgba(0,0,0,.2); opacity:0; pointer-events:none; transition:opacity .3s ease-out;
  white-space:pre-line; text-align:center; z-index: 999999; /* above header */
}
#wisielec-game #popup.show,
#omni-popup.show{ opacity:1; pointer-events:auto; }

/* Again button styling */
#wisielec-game #againBtn,
#omni-popup #againBtn{
  margin-top:24px; padding:12px 28px; font-size:24px; border:none; border-radius:12px;
  background:var(--c-btn-bg); color:#fff; cursor:pointer; transition:background .2s;
}
#wisielec-game #againBtn:hover,
#omni-popup #againBtn:hover{ background:var(--c-btn-bg-h); }

/* ---------- new summary popup ---------- */
#wisielec-game .wis-popup {
  position: fixed;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9999;
  background: rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}
#wisielec-game .wis-popup.is-visible {
  opacity: 1;
  pointer-events: auto;
}
#wisielec-game .wis-popup-inner {
  position: relative;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 6px 32px #2222;
  padding: 32px 30px 26px;
  min-width: 280px;
  max-width: 90vw;
  text-align: center;
  animation: wis-popup-in 0.5s cubic-bezier(.6,2,.4,1);
}
@keyframes wis-popup-in {
  0% { transform: scale(.85) translateY(32px); opacity:0; }
  100% { transform: scale(1) translateY(0); opacity:1; }
}
#wisielec-game .wis-popup-title {
  font-size: 2.1em;
  font-weight: 700;
  color: #4f883d;
  margin: 0 0 10px;
}
#wisielec-game .wis-popup-summary {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 22px;
  text-align: left;
}
#wisielec-game .wis-popup-summary-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 1.05em;
  color: #111827;
}
#wisielec-game .wis-popup-summary-label { font-weight: 600; }
#wisielec-game .wis-popup-summary-value { font-weight: 700; color: #4f883d; }
#wisielec-game .wis-popup-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#wisielec-game .wis-popup-btn {
  background: #4f883d;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 30px;
  font-size: 1.05em;
  cursor: pointer;
  box-shadow: 0 1px 4px #4f883d33;
  transition: background .2s;
}
#wisielec-game .wis-popup-btn:hover { background: #6bb94a; }
#wisielec-game .wis-popup-btn--outline {
  background: #fff;
  color: #4f883d;
  border: 2px solid #4f883d;
  box-shadow: none;
}
#wisielec-game .wis-popup-btn--outline:hover { background: #f1f5f9; }
#wisielec-game .wis-popup-close {
  position: absolute;
  top: 10px;
  right: 10px;
  border: 1px solid rgba(0,0,0,0.12);
  background: #fff;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  color: #4a4a4a;
  font-size: 18px;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  z-index: 3;
}
#wisielec-game .wis-popup-close:hover { background: rgba(255,255,255,0.9); }

 .omni-save-result-section {
   max-width: 400px;
   margin: 18px auto 0;
   padding: 20px;
   background: #fdfdfd;
   border: 1px solid #eee;
   border-radius: 12px;
   box-shadow: 0 4px 15px rgba(0,0,0,0.05);
   text-align: center;
 }

 .omni-save-checkbox-label {
   display: block;
   cursor: pointer;
   font-size: 1.1em;
   font-weight: 600;
   color: #4f883d;
 }

 .omni-save-checkbox-label input {
   margin-right: 8px;
   transform: scale(1.2);
   vertical-align: middle;
 }

 .omni-learner-name-field {
   margin-top: 15px;
   padding-top: 15px;
   border-top: 1px solid #e0e0e0;
 }

 .omni-learner-name-field > label {
   display: block;
   font-size: 13px;
   font-weight: 500;
   color: #555;
   margin-bottom: 8px;
   text-align: center;
 }

 .omni-learner-name-input {
   width: 100%;
   padding: 18px 20px;
   font-size: 16px;
   line-height: 1.45;
   border: 1px solid #ddd;
   border-radius: 8px;
   box-sizing: border-box;
   transition: border-color 0.2s, box-shadow 0.2s;
   min-height: 54px;
 }

 .omni-learner-name-input:focus {
   outline: none;
   border-color: #4f883d;
   box-shadow: 0 0 0 3px rgba(79, 136, 61, 0.15);
 }

 .omni-learner-name-input:read-only,
 .omni-learner-name-input:disabled {
   background: #f0f0f0;
   cursor: not-allowed;
 }

 .omni-save-result-btn {
   display: block;
   width: 100%;
   padding: 14px 24px;
   margin: 8px 0 12px;
   background: linear-gradient(135deg, #4f883d 0%, #3e6c31 100%);
   color: #fff;
   border: none;
   border-radius: 8px;
   font-size: 1.1em;
   font-weight: 600;
   cursor: pointer;
   transition: all 0.2s ease;
 }

 .omni-save-result-btn:hover {
   transform: translateY(-1px);
   box-shadow: 0 4px 12px rgba(79, 136, 61, 0.3);
 }

 .omni-save-result-btn.saved {
   background-color: #4f883d !important;
   cursor: default;
 }

 .omni-save-result-btn:disabled {
   opacity: 0.7;
 }

 .omni-privacy-note {
   margin: 0 0 10px;
   font-size: 12px;
   color: #1e1e1e;
   font-style: italic;
   text-align: center;
 }

 .omni-save-result-message {
   margin-top: 15px;
   padding: 12px 16px;
   border-radius: 6px;
   font-size: 0.9em;
   font-weight: 500;
   text-align: center;
 }

 .omni-save-result-message.success {
   background: #d4edda;
   color: #155724;
   border: 1px solid #c3e6cb;
 }

 .omni-save-result-message.error {
   background: #f8d7da;
   color: #721c24;
   border: 1px solid #f5c6cb;
 }

 @media (max-width: 600px) {
   .omni-save-result-section {
     max-width: 100%;
     padding: 15px;
   }
 }
