/* The home (/): Aziz's hello at the top, then a grid of square cells, 4 columns (2 from 600px; one column stream on phones, R11.2). Every card is 1×1,
   2×1 (wide), 1×2 (tall) or 2×2 (big), set by the owner's saved layout (journal/src/preview.js → /hub-home.js). The grid
   flows densely and the script checks the cells, so rows are always complete. The card family (.kc) is in garden.css. */
.kg-hub{container-type:inline-size;padding-block:36px 0}
.kgrid{--n:4;--gap:8px;--cell:calc((100cqw - (var(--n) - 1) * var(--gap)) / var(--n));display:grid;grid-template-columns:repeat(var(--n),minmax(0,1fr));grid-auto-rows:var(--cell);grid-auto-flow:row dense;gap:var(--gap)}
.kgrid > *{min-width:0;min-height:0;height:auto}
.kgrid > [data-w="2"]{grid-column:span 2}
.kgrid > [data-h="2"]{grid-row:span 2}
.kgrid > [hidden]{display:none!important}
@media (max-width:767px){
  .kg-hub{padding-top:20px}
  .kgrid{--n:2;--gap:8px}
}
/* phones: ONE column, owner's order kept; every card takes the height its variant asks for (data-w/h ignored) */
@media (max-width:599px){
  .kg-hub{padding-top:28px}
  #kgGrid{grid-template-columns:minmax(0,1fr);grid-auto-rows:auto;grid-auto-flow:row;gap:8px}
  #kgGrid > *{grid-column:auto!important;grid-row:auto!important}
  #kgGrid > .kc-post{container:kc/inline-size}
  #kgGrid > .kc:not(.kc-post){aspect-ratio:1/1}
  #kgGrid > .kc-sudoku{aspect-ratio:5/4}
  #kgGrid > .kc-tool.is-soon{aspect-ratio:3/2}
  #kgGrid > .kc-hcard[data-cat="coffee"],#kgGrid > .kc-hcard[data-cat="book"],#kgGrid > .kc-hcard[data-cat="product"],#kgGrid > .kc-hcard[data-cat="other"]{aspect-ratio:1/1}
}

/* the hello (.kg-intro) is shared with المدونة, الورشة and الهوايات since 12t: garden.css */

/* ---- cards at every size. Bigger cells give pictures and words more room. */
.kgrid > [data-h="2"] .kc-art .mood{max-height:260px}
.kgrid > [data-w="2"][data-h="2"] .kc-art .mood{max-height:340px}
.kgrid > .kc-tool[data-h="2"] .kc-art{inset:0 0 30%}
.kgrid > .kc-tool[data-w="2"][data-h="2"] .kc-name{font-size:22px}
.kgrid > .kc-tool[data-w="2"][data-h="2"] .kc-line{font-size:16px}
.kgrid > .kc-tool.is-soon[data-h="2"] .kc-soon-list > div{padding-block:16px}
.kgrid > .kc-tool.is-soon[data-w="2"][data-h="2"] .kc-soon-list .mood{height:64px}
.kgrid > .kc-sudoku[data-w="2"][data-h="2"] .kc-board{--bw:min(70cqw,calc(100cqh - 110px))}
.kgrid > .kc-sudoku[data-w="2"][data-h="2"] .kc-sd-line{font-size:15px}
.kgrid > .kc-sudoku[data-h="2"][data-w="1"] .kc-board{--bw:min(80cqw,calc(100cqh - 100px))}
.kgrid > .kc-tool .kc-chip,.kgrid > .kc .kc-arrow{display:none}
.kgrid > .kc-tool.is-soon .kc-label{inset-inline-end:var(--pad)}

/* writing cards: more of the first words as the cell grows */
.kgrid > .kc-post[data-w="2"] .kc-ptitle{font-size:28px}
.kgrid > .kc-post[data-w="2"][data-h="2"] .kc-ptitle{font-size:34px}
.kgrid > .kc-post[data-h="2"] .kc-pex{--pl:7}
.kgrid > .kc-post.has-img[data-h="2"] .kc-pex{--pl:3}
.kgrid > .kc-post.has-img[data-w="2"][data-h="1"] .kc-ptitle{-webkit-line-clamp:1}
.kgrid > .kc-post.has-img[data-w="2"][data-h="1"] .kc-pex{--pl:2}

/* hobby cards, like the writing cards: the picture at the top, then title, subtitle and a small meta line.
   A photo fades down into the card (.kc-pimg, shared with the writing cards). A sticker (.kg-sticker, a transparent
   cut-out with its outline) sits whole in the upper part on the card colour: no fade, no frame. */
.kc-hob{container-type:size;background:var(--tile)}
.kc-hob[data-cat="perfume"]{background:var(--paper);box-shadow:inset 0 0 0 1px var(--line)}
/* round 11: hobbies on the home are the flip cards from hobbies.css, filling their cell */
.kc-hcard{background:none;overflow:visible;contain:none}
.kc-hcard > .cc{position:absolute;inset:0;width:auto;height:auto;aspect-ratio:auto!important;animation:none}
.kgrid > .kc-hcard .cc .cc-name{font-size:26px}
html[data-look] .kc-hcard .cc-name{overflow-wrap:normal}
.kgrid > .kc-hcard[data-w="2"] .cc .cc-name{font-size:32px;line-height:1.15}
@container kc (max-width:250px){.kgrid > .kc-hcard .cc .cc-name{font-size:20px;-webkit-line-clamp:2}.kc-hcard .cc.hc-coffee:not(.has-sticker) .hc-img{display:none}.kc-hcard .cc.hc-coffee.has-img .cc-body{margin-top:auto}.kgrid > .kc-hcard .cc.has-img:not(.hc-coffee) .cc-name{font-size:17px;-webkit-line-clamp:1}.kc-hcard .cc-meta{margin-top:6px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.kc-hcard .cc-tags{margin-bottom:8px}.kc-hcard .cc-face{padding-inline:16px;padding-bottom:16px}.kc-hcard .cc-flav{display:none}.kc-hcard .pf-name b{font-size:17px}}
@container kc (max-height:250px){.kc-hcard .cc-flav{display:none}.kc-hcard .cc-tags{margin-bottom:8px}}
.kc-hstick{position:absolute;z-index:0;inset:40px var(--pad) 40%;display:flex;align-items:center;justify-content:center}
.kc-hstick img{display:block;max-width:min(86%,320px);max-height:100%;width:auto;height:auto;object-fit:contain;transform:translateY(calc(var(--h) * -4px)) rotate(calc(var(--h) * -1.5deg));transition:transform var(--d3) var(--ease)}
.kc-hob .kc-pimg{height:62%}
.kc-htext{position:absolute;z-index:1;inset-inline:var(--pad);inset-block-end:var(--pad);display:flex;flex-direction:column;gap:2px;text-align:right}
.kc-hob .kc-title{font:700 21px/1.3 var(--font);overflow-wrap:anywhere;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden;padding-bottom:.32em;margin-bottom:-.32em}
.kc-hsub{margin:0;font:400 15px/1.5 var(--font);color:var(--ink-2);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.kc-hob .kc-meta{margin-top:2px;font-size:13px}
.kc-hob .kc-sub{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3;overflow:hidden;margin-top:6px;font-size:15px}
.kgrid > .kc-hob[data-h="2"] .kc-hstick{inset-block-end:30%}
.kgrid > .kc-hob.is-photo[data-h="2"] .kc-pimg{height:70%}
.kgrid > .kc-hob[data-w="2"][data-h="1"] .kc-hstick{inset:var(--pad);inset-inline-start:50%}
.kgrid > .kc-hob[data-w="2"][data-h="1"] .kc-htext{inset-inline-end:52%}
.kgrid > .kc-hob.is-photo[data-w="2"][data-h="1"] .kc-pimg{height:72%}
.kgrid > .kc-hob[data-w="2"] .kc-title{font-size:26px}
.kgrid > .kc-hob[data-w="2"][data-h="2"] .kc-title{font-size:30px}
@container (max-width:250px){
  .kc-hob .kc-title{font-size:17px}
  .kc-hsub{font-size:13.5px}
  .kc-hob .kc-meta{font-size:12px}
  .kc-hob .kc-sub{display:none!important}
  .kc-hstick{inset:36px 12px 42%}
  .kc-htext{inset-inline:14px;inset-block-end:14px}
}
@container (max-height:230px){.kc-hob .kc-meta{display:none}}

/* ============ arrange mode (owner only) ============ */
/* the arrange button: on the page, at the top-left of the grid (round 6), a quiet text button */
.kh-head{display:flex;justify-content:flex-end;margin:-6px 0 8px}
.kh-toggle{display:inline-flex;align-items:center;gap:6px;height:32px;padding:0 10px;border:1px solid transparent;background:none;color:var(--ink-3);font:500 14px/1 var(--font);cursor:pointer;transition:color var(--d1) ease,border-color var(--d1) ease,background-color var(--d1) ease}
.kh-toggle svg{width:17px;height:17px;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linejoin:round}
.kh-toggle:hover{border-color:var(--line-2);color:var(--ink)}
.kh-toggle[aria-pressed="true"]{background:var(--ink);border-color:var(--ink);color:var(--bg)}
html[data-look="garden"] .kh-toggle{border-radius:var(--r-ctl)!important}
body.kh-editing #kgGrid > *,body.kh-editing .kh-tray-grid > *{position:relative;outline:1px dashed var(--line-2);outline-offset:3px;transform:none!important;box-shadow:none!important;cursor:grab;-webkit-user-drag:none;user-select:none;-webkit-user-select:none}
body.kh-editing #kgGrid img,body.kh-editing .kh-tray-grid img{-webkit-user-drag:none;pointer-events:none}
body.kh-editing .kg-intro [contenteditable]{user-select:text;-webkit-user-select:text;cursor:text;outline:1px dashed var(--ink-3);outline-offset:6px}
body.kh-editing .kg-intro [contenteditable]:focus{outline:1.5px solid var(--ink)}
body.kh-editing .kg-intro a{pointer-events:none}
body.kh-dragging,body.kh-dragging *{cursor:grabbing!important}
#kgGrid > .is-dragging,.kh-tray-grid > .is-dragging{opacity:.28}
/* in the tray a card only needs its grip, its pin and the eye (the size waits until it's back on the grid) */
.kh-tray-grid .kh-sizes{display:none}
body.kh-editing .kh-tray-grid > *{min-height:0}
body.kh-editing .kc-hcard .cc-ctl{display:none}
.kh-ghost{position:fixed;z-index:200;left:0;top:0;margin:0;pointer-events:none;transform-origin:0 0;box-shadow:0 24px 50px -20px rgba(40,32,20,.5)!important;opacity:.95;outline:1.5px solid var(--ink)!important}
.kh-ghost .kh-ctl{display:none}
/* the controls on each card: grip, the four sizes, the eye */
.kh-ctl{position:absolute;z-index:20;inset-block-start:8px;inset-inline-start:8px;max-width:calc(100% - 16px);display:flex;flex-wrap:wrap;align-items:center;gap:2px;padding:3px;border:1px solid var(--line-2);background:color-mix(in srgb,var(--bg) 80%,transparent);backdrop-filter:blur(12px) saturate(1.2);-webkit-backdrop-filter:blur(12px) saturate(1.2);box-shadow:0 6px 16px -10px rgba(40,32,20,.4);cursor:default}
.kh-ctl button{display:grid;place-items:center;width:30px;height:30px;padding:0;border:0;background:none;color:var(--ink-2);cursor:pointer}
.kh-ctl button:hover{background:var(--tile);color:var(--ink)}
.kh-ctl button:focus-visible{outline:2px solid var(--ink);outline-offset:-2px}
.kh-ctl svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round}
.kh-ctl .kh-grip{cursor:grab;touch-action:none;color:var(--ink)}
.kh-ctl .kh-grip svg{fill:currentColor;stroke:none}
.kh-sizes{display:flex;gap:1px;padding-inline:2px;border-inline:1px solid var(--line)}
.kh-sizes button{width:26px}
.kh-sizes svg{width:16px;height:16px}
.kh-sizes button[aria-checked="true"]{background:var(--ink);color:var(--bg)}
.is-off > :not(.kh-ctl){opacity:.4}
@media (max-width:767px){.kh-ctl button{width:34px;height:34px}.kh-sizes button{width:30px}}
/* hidden cards wait under the grid, small: «المخفي». The ones the 16-cell cap sent down wear a dashed edge. */
.kh-tray{margin-top:28px;padding-top:16px;border-top:1px dashed var(--line-2)}
.kh-tray-t{margin:0 0 4px;font:700 18px/1.4 var(--font);color:var(--ink)}
.kh-tray-h{margin:0 0 12px;font:400 14px/1.6 var(--font);color:var(--ink-3)}
.kh-tray-grid > .is-auto{outline-style:dotted!important}
.kh-ctl .kh-pin[aria-pressed="true"]{background:var(--ink);color:var(--bg)}
.kh-ctl .kh-pin[aria-pressed="true"] svg{fill:currentColor}
.kh-tray-grid{--n:6}
@media (max-width:767px){.kh-tray-grid{--n:2}}
/* the bar: glass, at the foot of the screen */
.kh-bar{position:fixed;z-index:120;inset-inline:0;bottom:calc(14px + env(safe-area-inset-bottom,0px));margin-inline:auto;width:max-content;max-width:calc(100% - 24px);display:flex;align-items:center;gap:8px 16px;flex-wrap:wrap;justify-content:center;padding:8px 8px 8px 8px;padding-inline-start:16px;border:1px solid var(--line-2);background:color-mix(in srgb,var(--bg) 74%,transparent);backdrop-filter:blur(18px) saturate(1.25);-webkit-backdrop-filter:blur(18px) saturate(1.25);box-shadow:0 18px 44px -22px rgba(40,32,20,.5)}
.kh-bar[hidden]{display:none}
.kh-msg{margin:0;max-width:40ch;font:400 13.5px/1.5 var(--font);color:var(--ink-2)}
.kh-acts{display:flex;gap:6px}
.kh-btn{display:inline-flex;align-items:center;gap:6px;height:38px;padding:0 14px;border:1px solid var(--line-2);background:color-mix(in srgb,var(--bg) 60%,transparent);color:var(--ink);font:700 14px/1 var(--font);cursor:pointer}
.kh-btn:hover{background:var(--tile)}
.kh-btn svg{width:17px;height:17px;fill:none;stroke:currentColor;stroke-width:1.6}
.kh-btn svg circle{fill:currentColor;stroke:none}
.kh-btn.is-ink{background:var(--ink);border-color:var(--ink);color:var(--bg)}
.kh-btn.is-ink:hover{background:var(--moss)}
.kh-btn:disabled{opacity:.5;cursor:progress}
body.kh-editing .foot{padding-bottom:96px}
.kh-flash{position:fixed;z-index:130;inset-inline:0;bottom:calc(18px + env(safe-area-inset-bottom,0px));margin:0 auto;width:max-content;max-width:calc(100% - 24px);padding:10px 16px;background:var(--ink);color:var(--bg);font:500 14px/1.4 var(--font);transition:opacity .3s ease}
.kh-flash.bye{opacity:0}
@media (prefers-reduced-motion:reduce){.kh-flash{transition:none}}
/* short wide cells (phones, tablets): the cover takes less height so the title sits below the strong part */

/* round 6: the today's-sudoku card. The label says «لعبة · الورشة»; under the board, its name and date, then the streak */
.kc-sd-line{display:flex;flex-direction:column;align-items:center;gap:0}
.kc-sd-line b{font:700 14px/1.5 var(--font);color:var(--ink)}
.kc-sd-line b span{font-weight:400;color:var(--ink-3)}
.kc-sd-line > span{font-size:12.5px;color:var(--ink-3)}
.kgrid > .kc-sudoku[data-span="2"] .kc-sd-line{align-items:flex-start}
@container kc (max-height:240px){.kc-sd-line > span{display:none}}
@container kc (min-width:201px){.kgrid > .kc-sudoku[data-w="1"][data-h="1"] .kc-board{--bw:min(68cqw,calc(100cqh - 120px))}}
@container kc (max-width:200px){
  .kc-sd-line{display:none}
  .kgrid > .kc-sudoku .kc-sd{padding-top:38px}
  .kgrid > .kc-sudoku .kc-board{--bw:min(74cqw,calc(100cqh - 52px))}
}
/* 12k: lock. A locked card wears a solid frame and only its lock + eye; gaps show as dashed cells while arranging */
.kh-ctl .kh-lock[aria-pressed="true"]{background:var(--ink);color:var(--bg)}
.kh-ctl .kh-sizes[hidden],.kh-ctl .kh-grip[hidden]{display:none}
body.kh-editing #kgGrid > .is-locked{outline:1.5px solid var(--ink);cursor:default}
.kh-tray-grid .kh-lock{display:none}
.kh-hole{border:1.5px dashed var(--line-2);border-radius:var(--r-card,12px);background:repeating-linear-gradient(135deg,transparent 0 10px,color-mix(in srgb,var(--line) 45%,transparent) 10px 11px);pointer-events:none;animation:khHole .3s ease both}
@keyframes khHole{from{opacity:0}to{opacity:1}}
.kh-btn[hidden]{display:none}
@media (prefers-reduced-motion:reduce){.kh-hole{animation:none}}
/* 12n: no flash of the default arrangement — hidden (space kept) until the real layout is applied, then a soft fade */
#kgGrid{transition:opacity .28s ease}
#kgGrid.is-loading{opacity:0;min-height:min(70vh,900px);pointer-events:none}
@media (prefers-reduced-motion:reduce){#kgGrid{transition:none}}
/* 15n: «احجبها» (only in the tray): a blocked card is faded and marked, it never takes part in the new-release shuffle */
.kh-ctl .kh-block[aria-pressed="true"]{background:var(--ink);color:var(--bg)}
.kh-tray-grid [data-id].is-blocked{opacity:.45}
.kh-tray-grid [data-id].is-blocked::after{content:'محجوبة';position:absolute;inset-inline-start:8px;bottom:8px;z-index:3;padding:2px 8px;border-radius:6px;background:var(--ink);color:var(--bg);font:500 12px/1.6 var(--font)}
.kh-ctl .kh-block[hidden]{display:none}
/* 15ah: where a dragged card will land (nothing moves until it's let go) */
.kh-drop{z-index:5;pointer-events:none;border:2px solid var(--ink,#111);border-radius:var(--r-card,12px);background:color-mix(in srgb,var(--ink,#111) 8%,transparent);box-shadow:0 0 0 4px color-mix(in srgb,var(--ink,#111) 10%,transparent)}
.kh-drop.bad{border-color:#C2412D;background:color-mix(in srgb,#C2412D 10%,transparent);box-shadow:none}
/* 15ai/15aj (Aziz): الإقلو by time — the newest card on the left, the grid flows left to right; the cards stay Arabic */
#kgGrid.kg-time{direction:ltr}
#kgGrid.kg-time > *{direction:rtl}

/* 15aw (Aziz): a zikr always in الإقلو's top right corner (not a tool): a short, authentic dhikr or dua that changes
   every hour, matched to the time of day (morning, evening, before sleep). preview.js fills it. */
#kgGrid > .kc-zikr{grid-row:1;grid-column:1 / 2;display:flex;flex-direction:column;justify-content:center;gap:10px;padding:22px 24px;background:var(--cc-back,#fff);box-shadow:inset 0 0 0 1px var(--line);container-type:size;cursor:default}
#kgGrid.kg-time > .kc-zikr{grid-column:-2 / -1;direction:rtl}
.kc-zikr .kz-k{position:absolute;inset-block-start:16px;inset-inline-start:20px;font:500 13px/1.4 var(--font);color:var(--ink-3)}
.kc-zikr .kz-x{margin:0;font:400 19px/2 var(--font);color:var(--ink);text-align:center;text-wrap:balance}
@container (max-height:250px){.kc-zikr .kz-x{font-size:16.5px;line-height:1.9}}
@container (min-height:330px){.kc-zikr .kz-x{font-size:21px}}
.kc-zikr .kz-src{margin:0;font:400 12.5px/1.4 var(--font);color:var(--ink-3);text-align:center}
.kc-zikr .kz-x.kz-in{animation:kzIn .6s ease both}
@keyframes kzIn{from{opacity:0}to{opacity:1}}
@media (prefers-reduced-motion:reduce){.kc-zikr .kz-x.kz-in{animation:none}}
@media (max-width:599px){#kgGrid > .kc-zikr{aspect-ratio:auto!important;min-height:0;padding:26px 22px;container-type:inline-size}}
