/* =====================================================================
   S T Y L E S – Slovianski Translator UI
   z niezależną konfiguracją czcionek dla ŁACINY, CYRYLICY i RZEZAWICY
   ===================================================================== */
/* ===================== KONFIGURACJA ALFABETÓW ===================== */
:root{
  /* ŁACINA */
  --latin-font-family: "Noto Sans","DejaVu Sans","Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  --latin-font-size: 16px;
  --latin-font-weight: 600;
  --latin-line-height: 1.6;
  --latin-letter-spacing: .01em;
  --latin-word-spacing: .04em;
  /* CYRYLICA */
  --cyr-font-family: "Noto Sans","DejaVu Sans","Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  --cyr-font-size: 16px;
  --cyr-font-weight: 600;
  --cyr-line-height: 1.6;
  --cyr-letter-spacing: .01em;
  --cyr-word-spacing: .04em;
  /* RZEZAWICA (CRZ) – metryka pomocnicza (spacje, interpunkcja) */
  --crz-font-family: "Atkinson Hyperlegible","IBM Plex Sans","Inter",
                     "Noto Sans",system-ui,-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  --crz-font-size: 16px;
  --crz-font-weight: 600;
  --crz-line-height: 1.6;
  /* odstęp liter regulujemy marginesem SVG */
  --crz-letter-spacing: -0.08em;
  /* wyraźniejsza przerwa między WYRAZAMI */
  --crz-word-spacing: 0.60em;
  /* luz między glifami CRZ */
  --crz-glyph-gap: -0.01em;
  /* cieńsza kreska przy zacieśnieniu */
  --crz-stroke: .105em;
  --crz-baseline-shift: 0em;
}
/* ---------- RESET ---------- */
*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0; padding:24px;
  background:#ffffff; color:#1f2328;
  font-family:var(--latin-font-family);
  font-size:16px; line-height:1.5;
  -webkit-font-smoothing:antialiased; -moz-osx-font-smoothing:grayscale;
  text-rendering:optimizeLegibility;
}
main{ max-width:1200px; margin:0 auto; }
/* ---------- MODAL ---------- */
#language-modal-backdrop{ position:fixed; inset:0; background:rgba(0,0,0,.45); display:flex; align-items:flex-start; justify-content:center; z-index:1000; }
#language-modal-backdrop.hidden{ display:none; }
#language-modal{
  position:relative; width:min(640px,92vw); height:min(80vh,640px);
  background:#fff; border-radius:5px;
  border-top-left-radius:0; border-top-right-radius:0;
  box-shadow:0 12px 50px rgba(0,0,0,.25);
  display:flex; flex-direction:column; overflow:hidden;
}
.modal-header{ display:flex; align-items:center; justify-content:space-between; padding:14px 18px; border-bottom:1px solid #d0d7de; }
#language-modal-close-btn{
  position:absolute; top:8px; right:8px; width:36px; height:36px;
  display:flex; align-items:center; justify-content:center;
  border:0; border-radius:5px;
  background:#d32f2f; color:#fff; font-size:20px; font-weight:700; line-height:1;
  cursor:pointer; box-shadow:0 2px 10px rgba(0,0,0,.12);
  transition: transform .12s ease, box-shadow .12s ease, background-color .12s ease, opacity .12s ease;
}
#language-modal-close-btn:hover{ background:#b32626; transform:scale(1.04); box-shadow:0 4px 14px rgba(0,0,0,.18); }
#language-modal-close-btn:active{ transform:scale(0.98); box-shadow:0 2px 8px rgba(0,0,0,.14); }
#language-modal-close-btn:focus-visible{ outline:3px solid rgba(211,47,47,.35); outline-offset:2px; }
.modal-header .close-slot{ display:none; }
.modal-search{ padding:14px 18px; border-bottom:1px solid #d0d7de; }
#language-search-input{ width:100%; padding:10px 12px; border:1px solid #d0d7de; border-radius:5px; font-family:var(--latin-font-family); }
.modal-body{ flex:1; overflow:auto; }
.language-option{ padding:12px 18px; cursor:pointer; border-bottom:1px solid #f1f3f5; font-family:var(--latin-font-family); }
.language-option:hover{ background:#f6f8fa; }
.language-option.selected{ background:#eef3ff; color:#0b57d0; font-weight:600; }
/* ---------- PASEK JĘZYKÓW ---------- */
.lang-row{ display:grid; grid-template-columns:1fr auto 1fr; gap:14px; margin-bottom:18px; align-items:center; }
.langbar{
  height:60px; width:100%;
  display:flex; align-items:center; justify-content:space-between;
  padding:0 14px; background:#fff; color:#0b57d0; font-weight:700;
  border:1px solid #d0d7de; border-radius:5px;
  cursor:pointer; transition:background-color .15s ease, border-color .15s ease, box-shadow .15s ease, color .15s ease;
  font-family:var(--latin-font-family);
}
.langbar:hover{ background:#fff; border-color:#d0d7de; color:#0b57d0; box-shadow:none; }
#srcBtn.langbar:hover{ background:#e9f1ff; border-color:#0b57d0; color:#0a49b3; box-shadow:0 0 0 3px rgba(11,87,208,.08); }
#tgtBtn.langbar.disabled{ cursor: default !important; }
#tgtBtn.langbar.disabled:hover{ background:#fff !important; border-color:#d0d7de !important; color:#0b57d0 !important; box-shadow:none !important; }
.caret{ display:none !important; }
/* ---------- PRZYCISK ZAMIANY ---------- */
.swap-round{
  width:48px; height:60px; display:inline-flex; align-items:center; justify-content:center;
  border:1px solid #d0d7de; border-radius:5px; background:#fff; color:#0b57d0; cursor:pointer;
  transition:background-color .15s ease, border-color .15s ease, box-shadow .15s ease, color .15s ease;
}
.swap-round svg,.swap-round img,.swap-round .material-icons,.swap-round .material-symbols-outlined,.swap-round .icon,.swap-round i,.swap-round span.icon{
  width:48px !important; height:48px !important; font-size:48px !important; line-height:1 !important;
}
.swap-round:hover,.swap-round:active,.swap-round:focus{
  background:#e9f1ff !important; border-color:#0b57d0 !important; color:#0a49b3 !important;
  box-shadow:0 0 0 3px rgba(11,87,208,.08) !important; transform:none !important; outline:none !important;
}
/* ---------- SIATKA + PANELE ---------- */
.io-grid{ display:grid; grid-template-columns:1fr; gap:18px; }
.io-pane{ padding:0; background:transparent; border:0; }
.io-separator{ height:1px; width:100%; background:#d0d7de; border:0; margin:0; }
/* -----------------------------------------------------------------
   INPUT – typografia
   ----------------------------------------------------------------- */
textarea#inputSentence{
  width:100%;
  min-height:280px; max-height:280px;
  padding:14px;
  border:1px solid #d0d7de; border-radius:5px;
  background:#fff; color:#1f2328;
  font-family:var(--latin-font-family);
  font-size:16px;
  font-weight:600;
  line-height:1.6;
  letter-spacing:.01em;
  word-spacing:.04em;
  text-decoration:none;
  font-kerning:auto; font-variant-ligatures:none;
  text-rendering:optimizeLegibility; -webkit-text-size-adjust:100%;
  tab-size:4;
  overflow:auto; resize:none;
}
/* -----------------------------------------------------------------
   OUTPUT – baza
   ----------------------------------------------------------------- */
#output{
  width:100%;
  min-height:280px; max-height:280px;
  padding:14px;
  border:1px solid #d0d7de; border-radius:5px;
  background:#fff; color:#1f2328;
  white-space:pre-wrap; overflow-wrap:break-word; hyphens:auto;
  display:block; overflow:auto; resize:none;
}
/* Uniwersalne dziedziczenie metryki */
#output *{
  font-family:inherit;
  font-size:inherit;
  font-weight:inherit;
  line-height:inherit;
  letter-spacing:inherit;
  word-spacing:inherit;
  text-decoration:inherit;
  font-kerning:inherit;
  font-variant-ligatures:inherit;
  text-underline-offset:0;
}
/* Linki / tooltipy */
#output a, #output .case-tip{ color:inherit; text-decoration:none; }
/* ================== TRYBY ALFABETÓW ================== */
#output.output-latin{
  font-family: var(--latin-font-family) !important;
  font-size: var(--latin-font-size) !important;
  font-weight: var(--latin-font-weight) !important;
  line-height: var(--latin-line-height) !important;
  letter-spacing: var(--latin-letter-spacing) !important;
  word-spacing: var(--latin-word-spacing) !important;
}
#output.output-cyrillic{
  font-family: var(--cyr-font-family) !important;
  font-size: var(--cyr-font-size) !important;
  font-weight: var(--cyr-font-weight) !important;
  line-height: var(--cyr-line-height) !important;
  letter-spacing: var(--cyr-letter-spacing) !important;
  word-spacing: var(--cyr-word-spacing) !important;
}
/* RZEZAWICA – metryka (spacje itp.) */
#output.output-crz{
  font-family: var(--crz-font-family) !important;
  font-size: var(--crz-font-size) !important;
  font-weight: var(--crz-font-weight) !important;
  line-height: var(--crz-line-height) !important;
  letter-spacing: var(--crz-letter-spacing) !important;
  word-spacing: var(--crz-word-spacing) !important;
}
/* ===================== Glify CRZ (SVG) ===================== */
#output.output-crz .crz-text svg{
  display:inline-block;
  width:.96em;
  height:1em;
  vertical-align: var(--crz-baseline-shift);
  margin: 0 var(--crz-glyph-gap);
  line-height:1;
  shape-rendering:geometricPrecision;
}
#output.output-crz .crz-text .sp{
  display:inline-block;
  width: var(--crz-word-spacing);
}
#output.output-crz .crz-text svg path,
#output.output-crz .crz-text path{
  stroke: currentColor;
  stroke-width: var(--crz-stroke);
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  vector-effect: non-scaling-stroke;
}
.output-crz .crz-caps{ font:inherit; letter-spacing:inherit; word-spacing:inherit; line-height:inherit; }
@supports(-webkit-touch-callout: none){
  #output.output-crz .crz-text svg path{ stroke-width: calc(var(--crz-stroke) + 0.01em); }
}
/* info/błędy */
.missing{ font-size:13px; color:#5f6b7a; margin-top:10px; }
.untranslated{ color:#d32f2f; font-weight:700; background:#ffe7e7; padding:1px 3px; border-radius:5px; }
.warn{ color:#d32f2f; font-size:13px; }
/* akcje – desktop */
.alphabet-options{ display:flex; gap:16px; align-items:center; color:#5f6b7a; font-size:14px; font-family:var(--latin-font-family); }
.actions-row{ display:flex; gap:12px; align-items:center; justify-content:space-between; margin-top:10px; }
/* przyciski */
button{
  appearance:none; border:0; cursor:pointer; border-radius:5px;
  background:#0b57d0; color:#fff; padding:10px 16px; font-weight:600; font-family:var(--latin-font-family);
  transition: background-color .15s ease, box-shadow .15s ease, transform .12s ease;
}
button.secondary{ background:#eef2f6; color:#1f2328; border:1px solid #d0d7de; }
button:hover{ background:#0a49b3; }
button.secondary:hover{ background:#e6ebf1; }
#resetButton.secondary{
  border:0; background:#d32f2f; color:#fff; font-weight:700;
  box-shadow:0 2px 10px rgba(0,0,0,.12); border-radius:5px; margin-top:0px;
}
#resetButton.secondary:hover{ background:#b32626; transform:translateY(-1px); box-shadow:0 4px 14px rgba(0,0,0,.18); }
#resetButton.secondary:active{ transform:translateY(0); box-shadow:0 2px 8px rgba(0,0,0,.14); }
#resetButton.secondary:focus-visible{ outline:3px solid rgba(211,47,47,.35); outline-offset:2px; }
/* ukryty translate */
#translateButton{ display:none !important; }
/* kopiuj (desktop) */
.copy-button{ margin-top:16px; margin-bottom:0px; width:100%; background:#0b57d0; font-family:var(--latin-font-family); border-radius:5px; }
.copy-button:hover{ background:#0a49b3; }
/* ---------- DESKTOP: 2 kolumny ---------- */
@media (min-width:1280px){
  .io-grid{ grid-template-columns:1fr 1fr; gap:24px; align-items:start; }
  .io-separator{ display:none; }
}
/* focus-ring */
.langbar:focus-visible, button:focus-visible, .output:focus-visible{
  outline:3px solid rgba(11,87,208,.35); outline-offset:2px; border-color:#0b57d0;
}
/* textarea bez poświaty */
textarea#inputSentence:focus, textarea#inputSentence:focus-visible{
  outline:none !important; box-shadow:none !important; border-color:#d0d7de !important;
}

/* ===================== TABLET + TELEFON ===================== */
@media (max-width:1024px){
  body{ padding:18px; }
  .io-grid{ grid-template-columns:1fr; gap:0; }
  .io-separator{ display:none; }

  textarea#inputSentence{
    min-height:40px; max-height:none; height:auto;
    overflow:hidden; margin:0;
  }
  #output{
    min-height:40px; max-height:none; height:auto;
    overflow:auto; display:block; margin:0;
  }
  #output:empty{ display:none; }

  .io-pane:has(#output:not(:empty)) textarea#inputSentence{
    border-bottom-left-radius:0;
    border-bottom-right-radius:0;
  }
  .io-pane:has(#output:not(:empty)) #output{
    border-top:0;
    border-top-left-radius:0;
    border-top-right-radius:0;
  }
  textarea#inputSentence,
  #output{
    box-shadow:0 1px 0 rgba(0,0,0,0.02);
  }

  /* POD POLAMI – zawsze 16px */
  .copy-button{
    margin-top:16px;
    margin-bottom:16px !important;
  }

  .alphabet-options{
    order:1 !important;
    float:none !important;
    gap:16px !important;
    white-space:nowrap !important;
    margin-top:0;
    margin-bottom:16px;   /* od alfabetów do Wyczyść: 16px */
  }

  /* gdy NIE ma outputu (brak copy-button) – alfabet startuje 16px pod polami */
  .io-pane:has(#output:empty) .alphabet-options{
    margin-top:16px;
  }

  .actions-row{
    display:flex !important;
    align-items:center !important;
    justify-content:flex-start !important;
    gap:12px !important;
    width:auto !important;
    margin-top:0 !important;  /* odstęp robi alphabet-options */
  }

  /* na tabletach Wyczyść nadal może być pierwszy w rzędzie, ale bez dodatkowego marginesu */
  #resetButton.secondary{
    order:-1 !important;
    margin-top:0 !important;
  }
}

/* ======== TELEFONY (≤640px) – korzystają z tych samych odstępów ======== */
@media (max-width:640px){
  .langbar{ padding:0 12px; }
}

/* ===================== MAŁE TELEFONY (≤420px) ===================== */
@media (max-width:420px){
  .langbar{ padding:0 12px; }

  .actions-row{
    display:flex !important;
    flex-direction:column !important;
    align-items:stretch !important;
    gap:12px !important;      /* równy odstęp między przyciskami */
    width:100% !important;
    margin-top:0 !important;
  }

  #resetButton.secondary{
    order:2 !important;
    float:none !important;
    width:100% !important;
  }

  .alphabet-options{
    padding-bottom:14px;
    font-family:var(--latin-font-family);
  }
}

/* kopiuj tylko gdy jest wynik – logika widoczności */
.copy-button{ display:none;}
#output:not(:empty) + .copy-button,
#output:not(:empty) ~ .copy-button{ display:block; }
.io-pane:has(#output:not(:empty)) .copy-button{ display:block; }
#output:empty ~ .copy-button{ display:none; }
.io-pane::after{ content:""; display:block; clear:both; }

/* =================== Efekt Najazdu na Słowa (HOVER) =================== */

/* Definiuje domyślne zachowanie elementu, który ma atrybut data-tooltip-content */
[data-tooltip-content] {
    /* Ustawia kursor na 'palec', aby wizualnie zasugerować interakcję */
    cursor: pointer; 
    
    /* Dodaje płynne przejście, by zmiana koloru nie była nagła */
    transition: color 0.2s ease-in-out;
    
    /* Zapewnia, że kolor domyślny jest dziedziczony z rodzica */
    color: inherit; 
}

/* Właściwa reguła: Zmień kolor tekstu, gdy kursor znajduje się nad elementem */
[data-tooltip-content]:hover {
    /* Ustawia kolor tekstu na niebieski (np. standardowy kolor webowy) */
    color: #007bff; 
}