/* style.css — תשבץ (Hebrew Word Search) */
:root{
  --bg: #0e1016;
  --bg2: #151823;
  --panel: #1b1f2c;
  --panel2: #232838;
  --text: #e9ecf5;
  --muted: #8b93a8;
  --accent: #6ee7b7;
  --accent2: #60a5fa;
  --sel: #fbbf24;
  --sel-text: #1a1206;
  --found: rgba(110,231,183,.32);
  --found-bd: rgba(110,231,183,.55);
  --border: #2a3041;
  --cell-bg: #242a3b;
  --cell-bg-alt: #2b3245;
  --miss: #ef4444;
  --shadow: 0 10px 40px rgba(0,0,0,.4);
}

@media (prefers-color-scheme: light){
  :root:not([data-theme]){
    --bg: #eef1f8;
    --bg2: #e4e9f3;
    --panel: #ffffff;
    --panel2: #f5f7fc;
    --text: #1a2030;
    --muted: #5a657d;
    --border: #dde3f0;
    --cell-bg: #eef2fa;
    --cell-bg-alt: #e6ecf6;
    --found: rgba(16,150,90,.18);
    --found-bd: rgba(16,150,90,.5);
    --sel: #f59e0b;
    --sel-text: #1a1206;
    --shadow: 0 10px 30px rgba(30,40,70,.12);
  }
}

:root[data-theme="light"]{
  --bg: #eef1f8;
  --bg2: #e4e9f3;
  --panel: #ffffff;
  --panel2: #f5f7fc;
  --text: #1a2030;
  --muted: #5a657d;
  --border: #dde3f0;
  --cell-bg: #eef2fa;
  --cell-bg-alt: #e6ecf6;
  --found: rgba(16,150,90,.18);
  --found-bd: rgba(16,150,90,.5);
  --sel: #f59e0b;
  --sel-text: #1a1206;
  --shadow: 0 10px 30px rgba(30,40,70,.12);
}

:root[data-theme="dark"]{
  --bg: #0e1016;
  --bg2: #151823;
  --panel: #1b1f2c;
  --panel2: #232838;
  --text: #e9ecf5;
  --muted: #8b93a8;
  --border: #2a3041;
  --cell-bg: #242a3b;
  --cell-bg-alt: #2b3245;
  --found: rgba(110,231,183,.32);
  --found-bd: rgba(110,231,183,.55);
  --sel: #fbbf24;
  --sel-text: #1a1206;
  --shadow: 0 10px 40px rgba(0,0,0,.4);
}

*{ box-sizing: border-box; }

html,
body{
  margin: 0;
  padding: 0;
  overflow: hidden;
  height: 100%;
}

body{
  font-family: 'Rubik', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(96,165,250,.10), transparent 60%),
    radial-gradient(900px 500px at 10% 110%, rgba(110,231,183,.08), transparent 60%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

body.modal-open{
  overflow: hidden;
}

button{
  font: inherit;
}

main{
  max-width: 1100px;
  margin: 0 auto;
  padding: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

header{
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 4px;
  flex: 0 0 auto;
}

.brand h1{
  margin: 0;
  font-size: clamp(22px, 5vw, 34px);
  font-weight: 900;
  letter-spacing: -0.01em;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand .sub{
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.stats{
  display: flex;
  gap: 10px;
  align-items: center;
}

.stat{
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 14px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  min-width: 64px;
  text-align: center;
}

#timer{
  color: var(--accent2);
}

.howto{
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.4;
  margin: 6px 0 8px;
  max-width: 760px;
  flex: 0 0 auto;
}

.layout{
  display: flex;
  gap: 4px;
  align-items: stretch;
  flex-wrap: nowrap;
  justify-content: center;
  flex: 1 1 auto;
  min-height: 0;
}

.board-wrap{
  flex: 3 1 0; /* 3/4 of the row */
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: auto;
}

@media (max-width: 620px){
  .board-wrap{
    flex: 3 1 0;
  }
  .words{
    flex: 1 1 0;
    min-width: 0;
    max-width: 25%;
    padding: 6px 3px;
  }
  .words h2{
    font-size: 10px;
  }
  .word-help{
    display: none;
  }
}

.grid{
  display: grid;
  grid-template-columns: repeat(var(--size, 12), 1fr);
  grid-template-rows: repeat(var(--size, 12), 1fr);
  gap: 1px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  padding: 0;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  background: var(--panel);
  /* at least 3/4 of the smaller screen dimension, capped to the space below the header */
  width: min(75vmin, calc(100dvh - 90px));
  height: min(75vmin, calc(100dvh - 90px));
  flex: 0 0 auto;
  max-width: none;
  max-height: none;
}

@media (max-width: 620px){
  .grid{
    width: min(75vmin, 78vw, calc(100dvh - 130px));
    height: min(75vmin, 78vw, calc(100dvh - 130px));
  }
  .board-wrap{
    justify-content: center;
  }
  .board-controls .btn{
    padding: 6px 12px;
    min-height: 34px;
    font-size: 13px;
  }
}

.cell{
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  padding: 0;
  font-weight: 700;
  font-size: clamp(10px, 2.4vw, 22px);
  color: var(--text);
  cursor: pointer;
  transition: background .12s ease, transform .12s ease, color .12s ease;
  line-height: 1;
}

.cell:nth-child(even){
  background: var(--cell-bg-alt);
}

.cell.sel{
  background: var(--sel);
  color: var(--sel-text);
  transform: scale(1.07);
  z-index: 2;
  box-shadow: 0 4px 14px rgba(251,191,36,.35);
}

.cell.found{
  background: var(--found);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--found-bd);
}

.cell.miss{
  background: var(--miss) !important;
  color: #fff !important;
}

.cell.hint{
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  animation: pulse .7s ease-in-out infinite alternate;
}

@keyframes pulse{
  from{ box-shadow: 0 0 0 0 rgba(110,231,183,0); }
  to{ box-shadow: 0 0 0 6px rgba(110,231,183,.25); }
}

.board-controls{
  display: flex;
  gap: 10px;
  margin-top: 4px;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
  flex: 0 0 auto;
}

.btn{
  font-family: inherit;
  font-weight: 700;
  font-size: 15px;
  padding: 12px 20px;
  min-height: 44px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  color: #0e1016;
  background: linear-gradient(180deg, var(--accent), #4fd39b);
  transition: transform .1s ease, filter .12s ease, box-shadow .12s ease;
  box-shadow: 0 4px 14px rgba(110,231,183,.25);
}

.btn:active{
  transform: translateY(1px) scale(.99);
}

.btn:hover{
  filter: brightness(1.05);
}

.btn-ghost{
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}

.btn-icon{
  padding: 12px;
  width: 44px;
  min-width: 44px;
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

body.muted .ic-on{
  display: none;
}

body:not(.muted) .ic-off{
  display: none;
}

.btn-big{
  padding: 14px 28px;
  font-size: 16px;
  margin-top: 8px;
}

.words{
  flex: 0 0 280px;
  min-width: 150px;
  max-width: 300px;
  min-height: 0;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 8px 10px;
  box-shadow: var(--shadow);
}

.words h2{
  margin: 0 0 2px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.word-help{
  margin: 0 0 6px;
  color: var(--accent2);
  font-size: 12px;
  font-weight: 500;
}

.words ul{
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.words li{
  border-radius: 12px;
  border: 1px solid transparent;
  transition: background .15s ease, border-color .15s ease;
}

.words li.found{
  border-color: var(--found-bd);
  background: var(--found);
}

.word-card{
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 6px 9px;
  color: var(--text);
  background: var(--panel2);
  border: 1px solid transparent;
  border-radius: 11px;
  cursor: pointer;
  text-align: right;
  transition: transform .12s ease, background .15s ease, border-color .15s ease;
}

.word-card:hover,
.word-card:focus-visible{
  background: color-mix(in srgb, var(--panel2) 78%, var(--accent2));
  border-color: rgba(96,165,250,.5);
  outline: none;
}

.word-card:active{
  transform: scale(.985);
}

.words li.found .word-card{
  background: transparent;
}

.dot{
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
  flex: 0 0 auto;
  margin-right: 2px;
  transition: background .15s ease;
}

.w-main{
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
}

.w-en{
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  max-width: 100%;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.words li.found .w-en{
  text-decoration: line-through;
  text-decoration-thickness: 2px;
  text-decoration-color: var(--accent);
  opacity: .75;
}

.w-tr{
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  letter-spacing: .01em;
  max-width: 100%;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.w-he{
  font-size: 17px;
  font-weight: 900;
  color: var(--accent);
  flex: 0 0 auto;
}

.w-he.pending{
  color: var(--text);
  opacity: .9;
  font-weight: 700;
}

.info-mark{
  width: 21px;
  height: 21px;
  flex: 0 0 21px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  direction: ltr;
  border: 1px solid var(--accent2);
  border-radius: 50%;
  color: var(--accent2);
  font-size: 12px;
  font-family: Georgia, serif;
  font-style: italic;
  font-weight: 700;
}

.toast{
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 50;
  max-width: 90vw;
  text-align: center;
}

.toast.show{
  opacity: 1;
  transform: translate(-50%, 0);
}

.overlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.overlay.show{
  display: flex;
  animation: fadein .25s ease;
}

@keyframes fadein{
  from{ opacity: 0; }
  to{ opacity: 1; }
}

.modal{
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 30px 28px;
  text-align: center;
  max-width: 360px;
  width: 100%;
  box-shadow: var(--shadow);
  animation: pop .3s cubic-bezier(.2,.9,.3,1.3);
}

@keyframes pop{
  from{ transform: scale(.85); opacity: 0; }
  to{ transform: scale(1); opacity: 1; }
}

.modal h2{
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 900;
  color: var(--accent);
}

.modal p{
  margin: 6px 0;
  color: var(--muted);
}

.modal .time{
  color: var(--text);
  font-weight: 700;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  margin: 10px 0 16px;
}

.word-modal{
  max-width: 540px;
  max-height: min(760px, 90vh);
  overflow-y: auto;
  text-align: left;
  padding: 28px;
}

.word-modal h2{
  color: var(--accent);
  font-size: clamp(32px, 9vw, 44px);
  line-height: 1;
  margin: 2px 0 10px;
  text-align: right;
}

.close-btn{
  position: absolute;
  top: 12px;
  right: 12px;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  background: var(--panel2);
  cursor: pointer;
  font-size: 27px;
  line-height: 1;
}

.close-btn:hover,
.close-btn:focus-visible{
  border-color: var(--accent2);
  outline: none;
}

.detail-kicker{
  margin: 0 !important;
  color: var(--accent2) !important;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .13em;
}

.word-definition{
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

#detailEnglish{
  font-size: 19px;
  font-weight: 900;
  color: var(--text);
  text-transform: capitalize;
}

#detailPronunciation{
  color: var(--muted);
  font-size: 14px;
  font-style: italic;
}

.detail-section{
  margin-top: 18px;
}

.detail-section h3{
  margin: 0 0 7px;
  color: var(--accent2);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.detail-section p{
  margin: 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.63;
}

.detail-section .reference{
  display: inline-block;
  margin-bottom: 8px;
  padding: 5px 9px;
  border-radius: 8px;
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--accent) !important;
  font-size: 13px;
  font-weight: 700;
}

.study-note{
  margin: 22px 0 0 !important;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  color: var(--muted) !important;
  font-size: 11.5px !important;
  line-height: 1.5;
}

@media (max-width: 899px){
  .howto{
    font-size: 11.5px;
    margin: 4px 0 6px;
  }

  .layout{
    flex-direction: row;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
    max-width: 100vw;
    height: calc(100dvh - 96px);
    overflow: hidden;
  }

  .board-wrap{
    width: auto;
    flex: 3 1 0; /* 75% */
    min-width: 0;
    max-width: 75%;
    max-height: 100%;
    padding: 0;
  }

  .board-controls .btn,
  .board-controls .btn-icon{
    padding: 8px 14px;
    min-height: 38px;
    font-size: 13px;
  }

  .board-controls .btn-icon{
    width: 38px;
    min-width: 38px;
    padding: 8px;
  }

  /* Word list sits beside the grid and scrolls internally */
  .words{
    flex: 1 1 0;
    max-width: 25%;
    min-width: 86px;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px 3px;
    scrollbar-width: thin;
  }

  .words ul{
    flex-direction: column;
    gap: 5px;
    overflow: visible;
    padding: 0;
  }

  .word-card{
    min-height: 50px;
    padding: 5px 8px;
    gap: 6px;
    white-space: normal;
    flex: 1 1 auto;
  }

  .w-he{
    font-size: 17px;
  }

  .w-en{
    font-size: 12.5px;
  }

  .w-tr{
    display: block;
    font-size: 11px;
  }

  .info-mark{
    display: none;
  }

  .word-card{
    min-height: 44px;
    padding: 5px 9px;
    gap: 7px;
    white-space: nowrap;
    flex: 0 0 auto;
  }

  .w-he{
    font-size: 17px;
  }

  .w-en{
    font-size: 12.5px;
  }

  .w-tr{
    display: none;
  }

  .info-mark{
    display: none;
  }
}

@media (max-width: 380px){
  .stats{
    gap: 6px;
  }

  .stat{
    padding: 7px 10px;
    font-size: 14px;
    min-width: 56px;
  }

  .word-modal{
    padding: 24px 19px;
  }
}

@media (max-width: 380px){
  .stats{
    gap: 6px;
  }

  .stat{
    padding: 7px 10px;
    font-size: 14px;
    min-width: 56px;
  }

  .word-modal{
    padding: 24px 19px;
  }
}
