:root {
    --bg: #fafaf7;
    --text: #1f1f1f;
    --muted: #5a5a5a;
    --line: #e3e1d9;
    --stroke: #1c2b26;
    --art-bg: #f3f0e8;
}

* { box-sizing: border-box; }

/* כל הגדלים בעמוד נמדדים ב-rem, כלומר ביחס לשורה הזאת.
   19px במקום 16px — ידית אחת שמגדילה את כל הטקסט יחד.
   המסגרות של האייקונים והרוחב של העמוד נמדדים בפיקסלים, ולא זזים. */
html { font-size: 118.75%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, "Segoe UI", Arial, sans-serif;
    line-height: 1.6;
}

main {
    max-width: 720px;
    margin: 0 auto;
    padding: 8px 16px 48px;
}

h1 { margin: 0 0 8px; font-size: 1.8rem; }

.muted { color: var(--muted); }

/* טקסט דמה: הסימון הוויזואלי הוסר לבקשת שפי (1.11).
   מה שמסמן אותו עכשיו הוא הסוגריים המרובעים בטקסט עצמו. */

/* ===== סרגל עליון ===== */
.topbar {
    max-width: 720px;
    margin: 0 auto;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.sitename {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: var(--text);
    text-decoration: none;
}

.sitename:hover { text-decoration: underline; }

.lang {
    font: inherit;
    font-size: 0.95rem;
    padding: 7px 16px;
    border: 2px solid var(--stroke);
    border-radius: 999px;
    background: #fff;
    color: var(--text);
    cursor: pointer;
}

.lang:hover { background: var(--stroke); color: #fff; }

.lang:focus-visible { outline: 3px solid #6c8ebf; outline-offset: 2px; }

/* ===== המסגרת =====
   רכיב אחד לכל האייקונים. הציור שקוף; הריבוע, הקו והצבע הם של המערכת.
   הצבע מגיע מ---c שנקבע לכל אייקון ב-index.php. */
.badge {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--c, #d8dce1);
    border: 3px solid var(--stroke);
    border-radius: 18%;
    overflow: hidden;
}

/* קבצי האייקונים חתוכים לגבול הציור עצמו, בלי שוליים שקופים,
   כך שכל אייקון ממלא את המשבצת באותה מידה. */
.badge img {
    width: 95%;
    height: 95%;
    display: block;
    object-fit: contain;
}

.badge-hero { width: 225px; height: 225px; border-width: 4px; }
.badge-row  { width: 108px; height: 108px; }

/* ===== הכותרת הראשית: אייקון גדול, שם ותיאור לידו ===== */
.hero {
    display: flex;
    align-items: center;
    gap: 22px;
    padding: 18px 20px;
    background: var(--art-bg);
    border: 1px solid var(--line);
    border-radius: 18px;
}

.hero-text { min-width: 0; }

.lede {
    margin: 0 0 14px;
    font-size: 1.02rem;
    color: #3a4249;
}

/* ===== שורות הקישור: איפה קונים, איפה רואים ===== */
.linklist {
    list-style: none;
    margin: 22px 0 0;
    padding: 0;
    display: grid;
    gap: 10px;
}

.linkrow {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    border: 2px solid var(--stroke);
    border-radius: 14px;
    background: #fff;
    color: var(--text);
    text-decoration: none;
}

.linkrow:hover { background: #f1f4f8; }

.linkrow:focus-visible { outline: 3px solid #6c8ebf; outline-offset: 2px; }

.linkrow-text { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }

.linkrow strong { font-size: 1.05rem; }

.linkrow .sub { font-size: 0.9rem; color: var(--muted); }

.linkrow .arrow { font-size: 1.3rem; color: var(--muted); flex: 0 0 auto; }

/* החץ פונה לכיוון הקריאה */
[dir="rtl"] .linkrow .arrow { transform: scaleX(-1); }

/* אייקון שעוד לא צויר */
.badge-empty { background: repeating-linear-gradient(45deg, #e7eaee 0 6px, #dde2e8 6px 12px); }

/* ===== קיר האייקונים =====
   כל האייקונים יחד. לחיצה על משבצת פותחת בועה עם הכותרת והתיאור,
   ובמשבצת שהיא קישור — גם כפתור מעבר. */
.iconwall {
    list-style: none;
    margin: 30px 0 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
}

.tile { margin: 0; }

.badge-tile {
    width: 108px;
    height: 108px;
    padding: 0;
    font: inherit;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.badge-tile:hover { transform: translateY(-2px); }

.badge-tile:focus-visible { outline: 3px solid #6c8ebf; outline-offset: 3px; }

.badge-tile[aria-expanded="true"] {
    transform: translateY(-2px);
    box-shadow: 0 0 0 3px #fafaf7, 0 0 0 6px var(--stroke);
}

/* הטקסט קיים בדף אבל לא נראה: קוראי מסך ומנועי חיפוש מוצאים אותו,
   והבועה שואבת ממנו את מה שהיא מציגה. */
.tiletext {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* ===== הבועה ===== */
.pop {
    position: absolute;
    z-index: 20;
    width: min(330px, calc(100vw - 32px));
    padding: 15px 17px;
    background: #fff;
    border: 2px solid var(--stroke);
    border-radius: 14px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.16);
}

/* החץ שמצביע חזרה על המשבצת שנלחצה; --ax נקבע ב-JS */
.pop::before {
    content: "";
    position: absolute;
    top: -8px;
    left: calc(var(--ax, 50%) - 7px);
    width: 12px;
    height: 12px;
    background: #fff;
    border-left: 2px solid var(--stroke);
    border-top: 2px solid var(--stroke);
    transform: rotate(45deg);
}

/* כשהבועה מעל המשבצת, החץ עובר לתחתית ומסתובב */
.pop-up::before {
    top: auto;
    bottom: -8px;
    border-left: 0;
    border-top: 0;
    border-right: 2px solid var(--stroke);
    border-bottom: 2px solid var(--stroke);
}

.pop h3 { margin: 0 0 6px; font-size: 1.05rem; }

.pop p { margin: 0; font-size: 0.95rem; color: #3a4249; }

.pop p[hidden] { display: none; }

.go {
    display: inline-block;
    margin-top: 13px;
    padding: 8px 18px;
    border: 2px solid var(--stroke);
    border-radius: 999px;
    background: #fff;
    color: var(--text);
    font-weight: 700;
    font-size: 0.95rem;
    text-decoration: none;
}

.go:hover { background: var(--stroke); color: #fff; }

.go:focus-visible { outline: 3px solid #6c8ebf; outline-offset: 2px; }

.go[hidden] { display: none; }

/* מתחת ל-430px האייקון עובר למעלה, כדי שהטקסט לא ייחנק */
@media (max-width: 430px) {
    .hero {
        flex-direction: column;
        align-items: flex-start;
        gap: 14px;
        padding: 16px;
    }

    .badge-hero { width: 174px; height: 174px; align-self: center; }

    h1 { font-size: 1.55rem; }

    /* בטלפון הטקסט גדל, ומשבצת של 90 חונקת אותו לשלוש מילים בשורה.
       76 משאיר לשורה אורך סביר ועדיין גדול מהמשבצת המקורית. */
    .badge-row { width: 76px; height: 76px; }

    .iconwall { gap: 12px; }

    .badge-tile { width: 92px; height: 92px; }
}
