/* ===== Grammar.css — v1.0
   Teal theme + suggestions + exercise UI + modal + CSS loader
============================================================== */

*,
*::before,
*::after { box-sizing: border-box; }

:root{
  --brand-900:#034769;
  --brand-700:#086FA1;
  --brand-400:#3CA0D0;
  --accent:#FF8900;

  --teal:#559088;
  --teal-16:rgba(85,144,136,.16);
  --teal-22:rgba(85,144,136,.22);
  --teal-28:rgba(85,144,136,.28);
  --teal-35:rgba(85,144,136,.35);

  --ok:#21a366;
  --bad:#d9534f;

  --text:#16232a;
  --muted:#5f7784;
  --card:#ffffff;

  --r-xl:20px; --r-lg:14px; --pill:999px;
  --shadow-md:0 8px 24px rgba(0,0,0,.12);
  --ring:0 0 0 3px rgba(60,160,208,.35);

  --speed-fast:180ms; --speed-med:360ms; --speed-slow:700ms;
  --max:900px;

  /* side menu helpers */
  --menuTop:12px;
  --menuSearchH:46px;
  --menuGap:6px;
  --menuLogoutH:48px;
  --menuHeaderH: calc(var(--menuTop) + var(--menuSearchH) + var(--menuGap) + var(--menuLogoutH) + var(--menuTop));
  --hamburgerSafe:78px;
}

/* ---------- Background ---------- */
html, body{
  margin:0; padding:0; min-height:100vh; width:100%;
  color:var(--text);
  font-family: Inter, "Noto Sans", system-ui, -apple-system, "Segoe UI",
               Roboto, "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(135deg, #034769 0%, #086FA1 45%, #3CA0D0 100%);
  background-size:180% 180%;
  animation:bgShift 90s ease infinite;
  overflow-x:hidden; font-size:16px;
}
@keyframes bgShift{0%{background-position:0% 50%}50%{background-position:100% 50%}100%{background-position:0% 50%}}

/* Particles */
.particle-container{ position:fixed; inset:0; z-index:0; pointer-events:none; overflow:hidden; }
.bubble{ position:absolute; bottom:-100px; background:rgba(255,255,255,.22); border-radius:50%; opacity:.6; animation:float 40s ease-in-out infinite; }
.bubble.small{width:30px;height:30px} .bubble.medium{width:60px;height:60px} .bubble.large{width:100px;height:100px}
@keyframes float{0%{transform:translateY(0)}50%{transform:translateY(-50vh)}100%{transform:translateY(0)}}
.particle-container .bubble:nth-child(1){left:20%; animation-duration:40s}
.particle-container .bubble:nth-child(2){left:40%; animation-duration:45s}
.particle-container .bubble:nth-child(3){left:60%; animation-duration:50s}
.particle-container .bubble:nth-child(4){left:80%; animation-duration:55s}
.particle-container .bubble:nth-child(5){left:10%; animation-duration:35s}

/* ---------- Shell ---------- */
.blur-layer{ position:relative; z-index:1; width:100%; padding:20px; transition:filter var(--speed-slow) ease; }
body.menu-open .blur-layer{ filter:blur(4px); }
body.menu-open::after{ content:""; position:fixed; inset:0; background:rgba(0,0,0,.35); z-index:1001; }

.content{ display:flex; flex-direction:column; align-items:center; padding:20px; }

.stylized-background{
  width:100%; max-width:var(--max); margin:0 auto;
  background:var(--card);
  border-radius:var(--r-xl);
  box-shadow:var(--shadow-md);
  padding:26px; line-height:1.85; position:relative;
  border:1px solid transparent;
  background:
    linear-gradient(#fff,#fff) padding-box,
    linear-gradient(90deg, var(--teal), var(--brand-400)) border-box;
}
.stylized-background::after{
  content:''; position:absolute; inset:0;
  background-image:url('https://www.transparenttextures.com/patterns/diagonal-noise.png');
  opacity:.05; border-radius:inherit; pointer-events:none;
}

/* Headings */
.stylized-background h1{ color:var(--brand-900); font-weight:800; font-size:1.9rem; line-height:1.25; margin:0 0 6px; text-align:center; }
.note{ margin:0 0 16px; text-align:center; color:var(--muted); }

/* ---------- Topic + suggestions ---------- */
.topic-display{
  display:flex; flex-direction:column; gap:8px; max-width:680px; margin:0 auto 14px;
}
.topic-display label{ font-weight:800; color:var(--brand-900); }
#grammar-area{
  width:100%; height:46px; padding:0 14px; border-radius:12px;
  border:1px solid var(--teal-22); outline:none;
  font-size:16px; background:#ffffff;
  box-shadow:inset 0 0 0 2px rgba(60,160,208,.06);
  transition:border-color var(--speed-fast), box-shadow var(--speed-fast), background var(--speed-fast);
}
#grammar-area:focus{ border-color:var(--brand-400); box-shadow:var(--ring); background:#F7FBFF; }

/* Suggestions dropdown */
#suggestions{
  display:none; position:relative; z-index:2;
  width:100%; background:#fff; border:1px solid var(--teal-28);
  border-radius:12px; box-shadow:0 14px 30px rgba(0,0,0,.12); overflow:hidden;
}
.suggestion-item{
  padding:10px 12px; cursor:pointer; transition: background var(--speed-fast);
}
.suggestion-item:hover{ background:#EEF6FA; }

/* ---------- Buttons ---------- */
.difficulty-buttons{
  display:flex; flex-wrap:wrap; gap:10px; justify-content:center; margin:12px 0 4px;
}
.generate-button, .check-button{ display:flex; justify-content:center; margin-top:10px; }

/* Universal pill button (used for .button-29) */
.button-29{
  display:inline-flex; align-items:center; justify-content:center;
  height:46px; padding:0 18px; border-radius:var(--pill);
  border:2px solid var(--brand-900);
  background:#EEF3F6; color:var(--brand-900);
  font-weight:800; letter-spacing:.2px; text-decoration:none; cursor:pointer;
  transition: background var(--speed-slow), color var(--speed-slow), transform var(--speed-fast), box-shadow var(--speed-fast), border-color var(--speed-fast);
  box-shadow:inset 0 0 0 2px rgba(60,160,208,.16), 0 3px 10px rgba(0,0,0,.06);
}
.button-29:hover{ background:var(--accent); color:#fff; transform:translateY(-1px); }
.button-29:focus-visible{ outline:0; box-shadow:var(--ring); }
.button-29:active{ transform:translateY(0); }

/* Difficulty pills */
.difficulty-btn.button-29{ height:40px; padding:0 14px; }
.difficulty-btn.active,
.difficulty-btn.selected{
  background:var(--accent); color:#fff; border-color:var(--accent);
  box-shadow:0 6px 16px rgba(0,0,0,.14);
}

/* ---------- Exercise area ---------- */
#exercise{ margin-top:14px; display:flex; flex-direction:column; gap:12px; }

.sentence-container{
  background:#fff;
  border:1px solid var(--teal-22);
  border-radius:14px;
  padding:12px 14px;
  box-shadow:0 6px 14px rgba(0,0,0,.06);
  display:flex; align-items:center; flex-wrap:wrap; gap:8px;
  position:relative;
}

.exercise-input{
  min-width:180px; height:40px;
  padding:0 12px; border-radius:10px; outline:none;
  border:2px solid var(--teal-22); background:#FAFDFF;
  transition:border-color var(--speed-fast), box-shadow var(--speed-fast), background var(--speed-fast), transform var(--speed-fast);
  font-weight:700;
}
.exercise-input:focus{ border-color:var(--brand-400); box-shadow:var(--ring); background:#fff; }

/* Base form hint (např. infinitiv) */
.base-form{
  margin-left:auto; color:var(--muted); font-size:.9rem;
  background:#F2F7FA; border:1px solid var(--teal-22); padding:4px 8px; border-radius:999px;
}

/* Lightbulb icon (show answer) */
.lightbulb-icon{
  margin-left:6px; cursor:pointer; user-select:none; font-size:18px; line-height:1;
  transition: transform var(--speed-fast), filter var(--speed-fast), opacity var(--speed-fast);
}
.lightbulb-icon:hover{ transform:scale(1.07) rotate(-8deg); filter: drop-shadow(0 2px 6px rgba(255,200,0,.35)); }
.lightbulb-icon:active{ transform:scale(1.02) }

/* Tooltip (JS vkládá inline pozici; tady jen vzhled pro případné přebití) */
.tooltip{
  background:#fff; border:1px solid var(--teal-28); border-radius:10px;
  box-shadow:0 10px 28px rgba(0,0,0,.16); padding:6px 10px; font-weight:800; color:var(--brand-900);
}

/* Správně/špatně stavy pro input (doplněk k inline stylům z JS) */
.exercise-input.good{
  border-color:var(--ok) !important;
  box-shadow:0 0 0 3px rgba(33,163,102,.18) !important;
}
.exercise-input.bad{
  border-color:var(--bad) !important;
  box-shadow:0 0 0 3px rgba(217,83,79,.18) !important;
  animation:shake .28s ease;
}
@keyframes shake{
  0%,100%{transform:translateX(0)}
  25%{transform:translateX(-2px)}
  50%{transform:translateX(2px)}
  75%{transform:translateX(-1px)}
}

/* Malý chip se správnou odpovědí (když je špatně) */
.sentence-container .correct-answer-chip{
  display:inline-flex; align-items:center; gap:6px;
  padding:4px 10px; background:#eef6fa; border:1px solid var(--brand-400);
  border-radius:999px; font-weight:700; color:var(--brand-700);
}

/* ---------- Modal ---------- */
.modal{
  display:none; position:fixed; inset:0; z-index:10004;
  background: rgba(0,0,0,.35);
}
.modal-content{
  position:relative;
  width:min(92vw,560px); margin:10vh auto; padding:18px 18px 20px;
  background:#fff; border-radius:18px; border:1px solid var(--teal-22); box-shadow:var(--shadow-md);
}
.modal .close{
  position:absolute; right:12px; top:10px; font-size:24px; cursor:pointer; line-height:1;
  color:var(--muted); transition: transform var(--speed-fast), color var(--speed-fast);
}
.modal .close:hover{ color:#000; transform:rotate(90deg); }

/* ---------- Loader (pure CSS, ovládej .visible) ---------- */
.loading{
  position:fixed; inset:0; display:flex; justify-content:center; align-items:center;
  background: rgba(255,255,255,0.82); z-index:10003;
  visibility:hidden; opacity:0; transition: opacity var(--speed-fast), visibility var(--speed-fast);
}
.loading.visible{ visibility:visible; opacity:1; }

/* Spinner */
.loader{
  --size: 64px;
  width:var(--size); height:var(--size); position:relative;
  filter: drop-shadow(0 8px 18px rgba(0,0,0,.18));
}
.loader::before, .loader::after{
  content:""; position:absolute; inset:0; border-radius:50%;
  border:6px solid transparent; animation:spin 1s linear infinite;
}
.loader::before{ border-top-color:var(--brand-400); }
.loader::after { border-bottom-color:var(--accent); animation-duration:1.35s; }
@keyframes spin{ to{ transform: rotate(360deg) } }

/* ---------- Side Menu (stejné chování) ---------- */
#side-menu{
  position:fixed; top:0; left:0;
  width:min(92vw, 450px); height:100dvh;
  background:
    radial-gradient(500px 300px at 0 0, var(--teal-16), transparent 60%),
    #034769;
  box-shadow:6px 0 22px rgba(0,0,0,.32);
  transform:translateX(-100%); transition:transform var(--speed-slow) ease;
  z-index:1002; display:flex; flex-direction:column; overflow:hidden auto; -webkit-overflow-scrolling:touch;
  padding:78px 14px 18px;
}
#side-menu.open{ transform:translateX(0); }

#side-menu ul.menu{ list-style:none; margin:0; padding: calc(var(--hamburgerSafe) + var(--menuHeaderH)) 0 0; position:relative; }
.menu li{ width:100%; }

.search-container{
  position:fixed; left:14px; top: calc(var(--hamburgerSafe) + var(--menuTop));
  width: calc(min(92vw, 450px) - 28px); z-index:12;
  display:flex; align-items:center; gap:8px;
  height: var(--menuSearchH); padding:7px 12px; border-radius:23px; background:#fff;
  border:1px solid var(--teal-35); box-shadow:0 6px 18px rgba(0,0,0,.25);
}
.search-input{ background:transparent; border:none; outline:none; width:100%; font-size:16px; color:#333; padding-left:8px; }
.search-btn{ background:transparent; border:none; cursor:pointer; font-size:18px; color:#333; width:32px; height:32px; display:grid; place-items:center; }

.menu a.logout-button, .logout-button{
  position:fixed; left:14px;
  top: calc(var(--hamburgerSafe) + var(--menuTop) + var(--menuSearchH) + var(--menuGap));
  width: calc(min(92vw, 450px) - 28px);
  z-index:12; margin:0;
  border:1px solid var(--teal-28);
  background: rgba(255,255,255,0.08);
  display:flex; align-items:center; justify-content:center;
}

.menu a{
  display:flex; align-items:center; gap:10px; width:100%;
  color:#fff; text-decoration:none; font-size:1.03rem;
  padding:12px 16px; background: rgba(255,255,255,0.06);
  border:1px solid var(--teal-22); border-radius:12px;
  transition: background var(--speed-med), transform var(--speed-fast), box-shadow var(--speed-fast);
  margin:8px 0; white-space:normal; line-height:1.35; justify-content:flex-start;
}
.menu a:hover{
  background:#086FA1;
  box-shadow:inset 0 0 0 2px var(--teal-22), 0 6px 16px rgba(0,0,0,.14);
  transform: translateY(-1px);
}
.menu > li{ margin-bottom:14px; }
.menu > li > a{ font-weight:700; background: rgba(255,255,255,0.08); border:1px solid var(--teal-28); }

.menu > li > a + .submenu{
  margin-top:8px; padding:10px; border-radius:14px;
  background: rgba(8,111,161,0.18); border:1px solid var(--teal-22);
}
.submenu{ display:flex; flex-direction:column; overflow:hidden; border-radius:14px; background: rgba(8,111,161,0.18); border:1px solid var(--teal-22); }
.submenu a{
  display:flex; align-items:center; justify-content:flex-start;
  gap:12px; padding:12px 14px; margin:0; background: rgba(255,255,255,0.06);
  border:1px solid var(--teal-22); border-left:0; border-right:0; border-radius:0; position:relative;
}
.submenu a + a{ border-top:1px solid rgba(255,255,255,.08); }
.submenu a:first-child{ border-top-left-radius:14px; border-top-right-radius:14px; }
.submenu a:last-child { border-bottom-left-radius:14px; border-bottom-right-radius:14px; }
.submenu a::before{ content:''; width:8px; height:8px; border-radius:50%; background:var(--teal); flex:0 0 8px; margin-right:4px; }
.submenu a::after{ content:''; display:none; }

/* ---------- Hamburger ---------- */
.setting-btn{
  width:46px; height:46px; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:6px;
  background:var(--brand-700); border-radius:10px; cursor:pointer; border:none;
  box-shadow:0 0 0 2px var(--brand-400); z-index:1003; position:fixed; top:20px; left:20px;
}
.bar{ width:50%; height:2px; background:#e5e5e5; border-radius:2px; position:relative; }
.bar::before{
  content:""; position:absolute; top:50%; left:50%; transform:translate(-50%,-50%);
  width:6px; height:6px; border-radius:50%; background:#7e75ff; border:2px solid #fff;
  box-shadow:0 0 6px rgba(255,255,255,.95); transition:left var(--speed-fast) ease;
}
.bar1::before{ left:calc(50% - 6px); }
.bar2::before{ left:calc(50% + 6px); }
.setting-btn:hover .bar1::before{ left:calc(50% + 6px); }
.setting-btn:hover .bar2::before{ left:calc(50% - 6px); }

/* ---------- Admin/Teacher ---------- */
#teacher-button, #admin-button{ position:fixed; top:20px; right:20px; z-index:1003; padding:0 16px; height:42px; min-width:120px; }
#admin-button{ right: calc(20px + 130px); }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar{ width:12px }
::-webkit-scrollbar-track{ background: rgba(0,0,0,.06); border-radius:10px }
::-webkit-scrollbar-thumb{ background: rgba(3,71,105,.7); border-radius:10px; box-shadow: inset 0 0 6px rgba(0,0,0,.25) }
::-webkit-scrollbar-thumb:window-inactive{ background: rgba(3,71,105,.45) }

/* ---------- Mobile tweaks ---------- */
@media (max-width: 640px){
  .content{ padding:8px; }
  .stylized-background{ margin:6px; padding:14px; border-radius:14px; }
  .sentence-container{ gap:6px; }
  .exercise-input{ min-width:130px; flex:1 1 160px; }
  .base-form{ margin-left:0; }
  #teacher-button, #admin-button{ top:72px; }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce){
  *{ animation:none !important; transition:none !important; }
  .particle-container{ display:none; }
}
