/* הלוח עצמו. הכול כאן יחסי לגודל המיכל, כדי שאותו לוח ייראה נכון בטלפון ובהדפסה. */

:root {
  --teal: #005074;
  --lightblue: #D3E1E0;
  --yellow: #F0A61F;
  --cream: #F9E7CC;
  --coral: #E7745D;
  --peach: #F9DED3;
  --ink: #1b2a33;
}

.board {
  position: relative;
  width: 100%;
  aspect-ratio: 210 / 297;
  background: var(--cream);
  overflow: hidden;
  isolation: isolate;
  /* יחידה פנימית: 1cqw = אחוז מרוחב הלוח. כל הטיפוגרפיה נשענת עליה. */
  container-type: inline-size;
  box-shadow: 0 2px 6px rgba(27, 42, 51, .10), 0 18px 50px rgba(27, 42, 51, .16);
}

.board[data-orientation="landscape"] { aspect-ratio: 297 / 210; }

/* רקע לנייד. מסך אייפון פרו מקס, שיורד יפה לכל מכשיר אחר. */
.board[data-orientation="phone"] { aspect-ratio: 1290 / 2796; }

/* נייר: סיבי הנייר של הרקע */
.board::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: .5;
  background-image:
    radial-gradient(circle at 20% 15%, rgba(255,255,255,.65), transparent 55%),
    radial-gradient(circle at 85% 80%, rgba(0,80,116,.05), transparent 50%);
}

/* גרעין: השכבה שמונעת מהלוח להיראות דיגיטלי */
.board::after {
  content: "";
  position: absolute;
  inset: -2%;
  z-index: 60;
  pointer-events: none;
  opacity: .28;
  mix-blend-mode: multiply;
  background-image: var(--grain);
  background-size: 180px 180px;
}

/* צילום אמיתי של נייר מתחת לכול. זה מה שמונע מהרקע להרגיש כמו מלבן צבע. */
.board-texture {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-size: cover;
  background-position: center;
  opacity: .22;
  mix-blend-mode: multiply;
  filter: saturate(.55);
  pointer-events: none;
}

.el {
  position: absolute;
  transform-origin: center;
  will-change: transform;
}

/* ---------- תמונות ---------- */

.el-photo {
  overflow: visible;
  filter: drop-shadow(1px 3px 5px rgba(27, 42, 51, .26));
}

.el-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* הקצה הגזור. ה-polygon נכתב מה-JS לכל תמונה בנפרד. */
  clip-path: var(--cut);
  background: #ddd;
}

.el-photo[data-bw="1"] img { filter: grayscale(1) contrast(1.04) brightness(1.02); }

/* סרט הדבקה */
.el-photo .tape {
  position: absolute;
  width: 30%;
  height: 4.2cqw;
  min-height: 11px;
  top: -2cqw;
  opacity: .72;
  mix-blend-mode: multiply;
  border-radius: 1px;
  box-shadow: 0 1px 2px rgba(27, 42, 51, .18);
}
.el-photo .tape[data-at="tl"] { right: 6%;  transform: rotate(-7deg); }
.el-photo .tape[data-at="tr"] { left: 6%;   transform: rotate(6deg); }

/* ---------- טקסט ---------- */

.el-text { display: flex; }

.el-echo {
  align-items: flex-start;
  font-family: "Frank Ruhl Libre", Georgia, serif;
  font-weight: 700;
  font-size: 6.4cqw;
  line-height: 1.12;
  letter-spacing: -.015em;
  color: var(--teal);
  text-wrap: balance;
}

.el-phrase {
  align-items: center;
  font-family: "Assistant", system-ui, sans-serif;
  font-weight: 600;
  font-size: 3.5cqw;
  line-height: 1.32;
  text-wrap: balance;
}

.el-word {
  align-items: center;
  font-family: "Frank Ruhl Libre", Georgia, serif;
  font-weight: 800;
  font-size: 5.2cqw;
  line-height: 1;
  letter-spacing: -.02em;
}

/* מילה שנראית כמו גזיר אותיות ממגזין */
.el-word[data-cut="1"] span {
  background: #fff;
  padding: .12em .34em .2em;
  box-shadow: 1px 2px 4px rgba(27, 42, 51, .2);
  clip-path: var(--cut);
}

/* ---------- פתק ---------- */

.el-note {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4% 6%;
  font-family: "Gveret Levin", "Assistant", cursive;
  font-size: 3.5cqw;
  line-height: 1.34;
  color: var(--ink);
  box-shadow: 1px 3px 7px rgba(27, 42, 51, .2);
  clip-path: var(--cut);
}

/*
 * גודל הטקסט נמדד באחוזים מרוחב הלוח (cqw). על לוח לרוחב הרוחב גדול בהרבה
 * מהגובה, ולכן אותו ערך מייצר טקסט שגולש מהתיבה הנמוכה ונחתך -
 * ובפתק, שיש לו clip-path, הוא נגזר ממש באמצע מילה.
 * לכן לרוחב מקבל ערכים מוקטנים ביחס הגובה-רוחב שלו.
 */
.board[data-orientation="landscape"] .el-echo   { font-size: 4.5cqw; }
.board[data-orientation="landscape"] .el-phrase { font-size: 2.45cqw; }
.board[data-orientation="landscape"] .el-word   { font-size: 3.65cqw; }
.board[data-orientation="landscape"] .el-note   { font-size: 2.4cqw; }

/* הרקע לנייד צר וגבוה, והטקסט צריך להיות קצת גדול יחסית לרוחב */
.board[data-orientation="phone"] .el-echo   { font-size: 7cqw; }
.board[data-orientation="phone"] .el-phrase { font-size: 4cqw; }
.board[data-orientation="phone"] .el-word   { font-size: 5.6cqw; }
.board[data-orientation="phone"] .el-note   { font-size: 3.9cqw; }

/* ---------- עריכה ---------- */

.board[data-editable="1"] .el { cursor: grab; }
.board[data-editable="1"] .el:hover { outline: 2px dashed rgba(0, 80, 116, .45); outline-offset: 5px; }
.board[data-editable="1"] .el[data-selected="1"] { outline: 2px solid var(--teal); outline-offset: 5px; }
.el[data-dragging="1"] { cursor: grabbing; z-index: 59 !important; }

@media (prefers-reduced-motion: no-preference) {
  .board[data-building="1"] .el {
    animation: place .5s cubic-bezier(.2, .8, .3, 1) both;
  }
}

@keyframes place {
  from { opacity: 0; transform: translateY(14px) rotate(var(--rot)) scale(.94); }
  to   { opacity: 1; transform: rotate(var(--rot)) scale(1); }
}
