/* ==========================================================================
   "ورقة وأثر": a shared board of sticky notes (behaviour in assets/js/notes.js)
   ========================================================================== */

.note--mint, .pad--mint, .sheet-ghost--mint { --c-soft: var(--mint-soft); --c-strong: var(--mint); }
.note--sun, .pad--sun, .sheet-ghost--sun { --c-soft: var(--sun-soft); --c-strong: var(--sun); }
.note--peach, .pad--peach, .sheet-ghost--peach { --c-soft: var(--peach-soft); --c-strong: var(--peach); }
.note--lilac, .pad--lilac, .sheet-ghost--lilac { --c-soft: var(--lilac-soft); --c-strong: var(--lilac); }

.notes__hint { margin-top: .75rem; font-family: var(--font-note); font-size: var(--fs-note); line-height: 1.3; color: var(--petrol); }

/* ---------- The dock: a pad of sheets and the color choice ---------- */
.notes__dock {
  display: flex; align-items: center; gap: clamp(1.5rem, 4vw, 3rem);
  margin-bottom: 1.75rem;
}

.pad__stack {
  position: relative; display: block; width: 11.5rem; height: 9.5rem; padding: 0;
  border: 0; background: none; cursor: grab; -webkit-tap-highlight-color: transparent;
}
.notes--canvas .pad__stack { touch-action: none; } /* lets a finger drag the sheet; the board list mode keeps normal scrolling */
.pad__stack:active { cursor: grabbing; }
.pad__stack:focus-visible { outline: none; }
.pad__stack:focus-visible .pad__sheet--top { outline: 3px solid var(--petrol); outline-offset: 4px; }

.pad__sheet {
  position: absolute; inset: 0; border-radius: .55rem;
  background: var(--sheet);
  box-shadow: 0 1px 2px rgb(23 59 53 / .08), 0 6px 14px -4px rgb(23 59 53 / .14);
}
.pad__sheet--4 { --sheet: var(--lilac-soft); rotate: -8deg; translate: -12px 10px; }
.pad__sheet--3 { --sheet: var(--peach-soft); rotate: 6deg; translate: 10px 7px; }
.pad__sheet--2 { --sheet: var(--sun-soft); rotate: -3deg; translate: -5px 3px; }
.pad__sheet--top {
  --sheet: var(--c-soft);
  display: grid; place-items: center; overflow: hidden;
  transition: translate .3s var(--ease-out), rotate .3s var(--ease-out), box-shadow .3s var(--ease-out), background-color .25s;
}
/* the glue strip of a sticky pad */
.pad__sheet--top::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 1.15rem;
  background: color-mix(in srgb, var(--c-strong) 55%, var(--c-soft));
}
/* a corner that lifts on hover, inviting a pull */
.pad__sheet--top::after {
  content: ""; position: absolute; bottom: 0; left: 0; width: 0; height: 0;
  background: linear-gradient(45deg, var(--section-bg, var(--bg)) 50%, color-mix(in srgb, var(--c-strong) 70%, var(--c-soft)) 50%);
  box-shadow: 2px -2px 4px rgb(23 59 53 / .12);
  transition: width .3s var(--ease-out), height .3s var(--ease-out);
}
.pad__stack:hover .pad__sheet--top,
.pad__stack:focus-visible .pad__sheet--top {
  translate: 0 -9px; rotate: -2.5deg;
  box-shadow: 0 2px 4px rgb(23 59 53 / .08), 0 18px 30px -10px rgb(23 59 53 / .3);
}
.pad__stack:hover .pad__sheet--top::after,
.pad__stack:focus-visible .pad__sheet--top::after { width: 1.6rem; height: 1.6rem; }
.pad__label { position: relative; padding-top: .9rem; font-family: var(--font-note); font-size: 1.6rem; color: var(--ink); }

.pad.is-taking .pad__sheet--top { opacity: 0; }
@keyframes pad-refill { from { translate: 0 12px; opacity: 0; } to { translate: 0 0; opacity: 1; } }
.pad.is-refilling .pad__sheet--top { animation: pad-refill .45s var(--ease-out); }

.notes__controls { display: flex; flex-direction: column; align-items: flex-start; gap: 1rem; }

.swatches { margin: 0; padding: 0; border: 0; min-width: 0; }
.swatches__label { padding: 0; margin-bottom: .55rem; font-family: var(--font-display); font-size: .95rem; color: var(--ink-2); }
.swatches__row { display: flex; gap: .65rem; }
.swatch {
  position: relative; width: 2.6rem; height: 2.6rem; border-radius: 50%;
  background: var(--soft); box-shadow: inset 0 0 0 3px var(--strong);
  cursor: pointer; transition: transform .2s var(--ease-bounce), box-shadow .2s var(--ease-out);
}
.swatch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.swatch:hover { transform: scale(1.08); }
.swatch:has(input:checked) { box-shadow: inset 0 0 0 3px var(--strong), 0 0 0 3px var(--surface), 0 0 0 5px var(--petrol); }
.swatch:has(input:focus-visible) { outline: 3px solid var(--petrol); outline-offset: 5px; }
.swatch--mint { --soft: var(--mint-soft); --strong: var(--mint); }
.swatch--sun { --soft: var(--sun-soft); --strong: var(--sun); }
.swatch--peach { --soft: var(--peach-soft); --strong: var(--peach); }
.swatch--lilac { --soft: var(--lilac-soft); --strong: var(--lilac); }

/* ---------- The board ---------- */
.board {
  position: relative; overflow: hidden; min-height: 18rem;
  border: 1px solid var(--line); border-radius: var(--r-xl);
  background-color: var(--surface);
  background-image: repeating-linear-gradient(to bottom, transparent 0 35px, color-mix(in srgb, var(--line) 75%, var(--surface)) 35px 36px);
  transition: border-color .25s var(--ease-out), box-shadow .25s var(--ease-out);
}
.board.is-target { border-color: var(--mint); box-shadow: 0 0 0 4px color-mix(in srgb, var(--mint) 22%, var(--surface)); }

/* Notes sit on a 1000-wide logical canvas, scaled to the board, so positions mean the
   same thing on every screen. Narrow boards switch to a reading list instead. */
.board__canvas { position: absolute; z-index: 1; top: 0; left: 0; width: 1000px; transform-origin: 0 0; }
.board--flow { display: flex; flex-direction: column; height: auto !important; }
.board--flow .board__canvas {
  position: static; width: auto; transform: none !important; height: auto !important;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 15.5rem), 1fr));
  align-items: start; gap: 1.5rem 1.25rem; padding: 1.75rem 1.25rem;
}

/* where a sheet will land; it sits under the notes so it never hides one */
.board__drop {
  position: absolute; z-index: 0; top: 0; left: 0; border: 2px dashed var(--mint); border-radius: .6rem;
  background: color-mix(in srgb, var(--mint-soft) 60%, var(--surface));
  opacity: 0; pointer-events: none; transition: opacity .15s var(--ease-out);
}
.board__drop.is-on { opacity: .9; }

.board__empty {
  position: absolute; inset: 0; z-index: 1;
  display: grid; place-content: center; padding: 2rem; text-align: center; pointer-events: none;
}
.board__empty-text { font-family: var(--font-note); font-size: clamp(1.7rem, 1.2rem + 1.6vw, 2.6rem); line-height: 1.3; color: var(--ink-2); }
/* loading, or the server out of reach: a quiet pill that leaves the board (and a draft) usable */
.board__state {
  position: absolute; z-index: 5; top: 1.1rem; left: 50%; translate: -50% 0;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .5rem .9rem;
  width: max-content; max-width: calc(100% - 2rem); padding: .5rem 1.1rem;
  border: 1px solid var(--line); border-radius: var(--r-pill);
  background: var(--surface); box-shadow: var(--shadow-1);
  color: var(--ink-2); font-family: var(--font-display); font-size: .98rem; text-align: center;
}
.board--flow .board__state { position: relative; top: auto; left: auto; translate: none; order: -1; align-self: center; margin-top: 1.25rem; }

/* ---------- A note ---------- */
.note {
  position: absolute; left: calc(var(--x) * 1px); top: calc(var(--y) * 1px); width: calc(var(--w) * 1px);
  padding: 1.3rem 1.25rem .95rem; border-radius: .4rem;
  background: var(--c-soft); color: var(--ink);
  box-shadow: 0 1px 2px rgb(23 59 53 / .07), 0 10px 22px -10px rgb(23 59 53 / .28);
  rotate: var(--rot, 0deg);
}
.note:focus { outline: none; }
.note:focus-visible { outline: 3px solid var(--petrol); outline-offset: 3px; }
.note__text {
  font-family: var(--font-note); font-size: 1.45rem; line-height: 1.55;
  white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink);
}
.note--long .note__text { font-size: 1.3rem; }
.note__meta { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; margin-top: .8rem; }
.note__name { font-family: var(--font-display); font-size: .92rem; color: var(--ink-2); }
.note__name::before { content: "— "; }
.note__time { flex: none; font-size: .74rem; color: var(--ink-2); }

/* small finishing touches, used sparingly: a strip of tape, or a folded corner */
.note--tape::before {
  content: ""; position: absolute; top: -.75rem; left: 50%; width: 5.2rem; height: 1.45rem;
  translate: -50% 0; rotate: -4deg; border-radius: 2px;
  background: color-mix(in srgb, var(--c-strong) 72%, var(--surface));
  box-shadow: 0 1px 2px rgb(23 59 53 / .1);
}
.note--fold::after {
  content: ""; position: absolute; bottom: 0; left: 0; width: 1.5rem; height: 1.5rem;
  background: linear-gradient(45deg, var(--surface) 50%, color-mix(in srgb, var(--c-strong) 65%, var(--c-soft)) 50%);
  border-top-right-radius: .25rem;
}
.note--fold .note__meta { padding-inline-end: 1.1rem; } /* keeps the time clear of the fold */

.note__menu { position: absolute; top: .3rem; inset-inline-end: .3rem; }
.note__menu-btn {
  display: grid; place-items: center; width: 2.1rem; height: 2.1rem; padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: var(--ink-2); cursor: pointer;
  opacity: 0; transition: opacity .2s var(--ease-out), background-color .2s var(--ease-out);
}
.note__menu-btn .icon { width: 1.15rem; height: 1.15rem; }
.note:hover .note__menu-btn, .note:focus-within .note__menu-btn, .note__menu-btn[aria-expanded="true"] { opacity: 1; }
.note__menu-btn:hover, .note__menu-btn[aria-expanded="true"] { background: color-mix(in srgb, var(--surface) 65%, var(--c-soft)); }
@media (hover: none) { .note__menu-btn { opacity: .75; } }
.note__menu-list {
  position: absolute; z-index: 6; top: 2.35rem; inset-inline-end: 0; min-width: 10rem; padding: .35rem;
  border: 1px solid var(--line); border-radius: .8rem; background: var(--surface); box-shadow: var(--shadow-2);
}
.note__menu-list button {
  display: flex; align-items: center; gap: .45rem; width: 100%; padding: .55rem .7rem;
  border: 0; border-radius: .55rem; background: none; color: var(--ink);
  font: inherit; font-size: .92rem; text-align: start; cursor: pointer;
}
.note__menu-list button:hover:not(:disabled) { background: var(--petrol-tint); }
.note__menu-list button:disabled { color: var(--ink-2); cursor: default; }
.note__menu-list .icon { width: 1rem; height: 1rem; }

.board--flow .note, .notes__archive .note { position: relative; left: auto; top: auto; width: auto; }
.board--flow .note { rotate: calc(var(--rot, 0deg) * .5); }

/* ---------- The note being written ---------- */
.note--draft {
  z-index: 4; width: 280px; padding-top: 2.2rem;
  box-shadow: 0 2px 4px rgb(23 59 53 / .08), 0 22px 40px -14px rgb(23 59 53 / .35);
}
.board--flow .note--draft { grid-column: 1 / -1; width: min(100%, 26rem); justify-self: center; rotate: 0deg; }
.note--draft:focus-within { box-shadow: 0 2px 4px rgb(23 59 53 / .08), 0 22px 40px -14px rgb(23 59 53 / .35), 0 0 0 3px color-mix(in srgb, var(--petrol) 35%, transparent); }
/* picked up by its grip: a little higher, a little more tilted */
.note--draft.is-lifted {
  z-index: 5; scale: 1.02; rotate: calc(var(--rot, 0deg) + 1.5deg); cursor: grabbing;
  box-shadow: 0 6px 14px rgb(23 59 53 / .14), 0 30px 50px -14px rgb(23 59 53 / .4);
}

.note__grip {
  position: absolute; top: .45rem; left: 50%; translate: -50% 0;
  display: grid; place-items: center; width: 3rem; height: 1.45rem; padding: 0;
  border: 0; border-radius: 1rem; cursor: grab; touch-action: none;
  background: color-mix(in srgb, var(--c-strong) 40%, var(--c-soft)); color: var(--ink-2);
}
.note__grip .icon { width: 1.1rem; height: 1.1rem; rotate: 90deg; }
.note__grip:active { cursor: grabbing; }
.board--flow .note__grip { display: none; }
.board--flow .note--draft { padding-top: 1.3rem; }

.note__input {
  display: block; width: 100%; min-height: 7rem; padding: 0; resize: none; overflow: hidden;
  border: 0; outline: 0; background: transparent; color: var(--ink);
  font-family: var(--font-note); font-size: 1.45rem; line-height: 1.55;
}
.note__input::placeholder { color: color-mix(in srgb, var(--ink-2) 80%, var(--c-soft)); }
.note__row {
  display: flex; align-items: center; gap: .6rem;
  margin-top: .5rem; padding-top: .65rem;
  border-top: 1px dashed color-mix(in srgb, var(--c-strong) 75%, var(--c-soft));
}
.note__name-input {
  flex: 1; min-width: 0; padding: .45rem .65rem; border: 1px solid transparent; border-radius: .55rem;
  background: color-mix(in srgb, var(--surface) 65%, var(--c-soft)); color: var(--ink); font-size: .92rem;
}
.note__name-input:focus { outline: 0; border-color: var(--petrol); }
.note__name-input::placeholder { color: color-mix(in srgb, var(--ink-2) 85%, var(--surface)); }
.note__count { flex: none; font-size: .78rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.note__count.is-near { color: #a3341f; }

.note__colors { display: flex; gap: .45rem; margin-top: .75rem; }
.note__dot {
  width: 1.65rem; height: 1.65rem; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
  background: var(--soft); box-shadow: inset 0 0 0 2.5px var(--strong);
}
.note__dot[aria-checked="true"] { box-shadow: inset 0 0 0 2.5px var(--strong), 0 0 0 2px var(--c-soft), 0 0 0 4px var(--petrol); }
.note__dot:focus-visible { outline: 2px solid var(--petrol); outline-offset: 3px; }
.note__dot--mint { --soft: var(--mint-soft); --strong: var(--mint); }
.note__dot--sun { --soft: var(--sun-soft); --strong: var(--sun); }
.note__dot--peach { --soft: var(--peach-soft); --strong: var(--peach); }
.note__dot--lilac { --soft: var(--lilac-soft); --strong: var(--lilac); }

.note__public { margin-top: .7rem; font-size: .8rem; line-height: 1.6; color: var(--ink-2); }
.note__restored { margin-bottom: .35rem; font-size: .78rem; color: var(--petrol); }
.note__restored:empty, .note__error:empty { display: none; }
.note__error { margin-top: .45rem; font-size: .84rem; line-height: 1.6; color: #a3341f; }
.note__actions { display: flex; align-items: center; gap: .9rem; margin-top: .75rem; }
.note__cancel {
  padding: .4rem .2rem; border: 0; background: none; cursor: pointer;
  font-family: var(--font-display); font-size: .98rem; color: var(--ink-2);
  text-decoration: underline; text-underline-offset: .35em;
}
.note__cancel:hover { color: var(--ink); }
.note__hp { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* the sheet that follows the pointer while it is carried to the board */
.sheet-ghost {
  position: fixed; z-index: 200; top: 0; left: 0; width: 12rem; height: 10rem;
  display: grid; place-items: center; overflow: hidden; border-radius: .55rem; pointer-events: none;
  background: var(--c-soft); color: var(--ink);
  font-family: var(--font-note); font-size: 1.5rem;
  box-shadow: 0 6px 14px rgb(23 59 53 / .14), 0 30px 50px -14px rgb(23 59 53 / .4);
  rotate: 5deg; scale: 1.04;
  transition: rotate .2s var(--ease-out);
}
.sheet-ghost::before { content: ""; position: absolute; inset: 0 0 auto; height: 1.1rem; background: color-mix(in srgb, var(--c-strong) 55%, var(--c-soft)); }
.sheet-ghost.is-returning { transition: translate .35s var(--ease-out), opacity .35s var(--ease-out); opacity: 0; }
body.is-carrying { cursor: grabbing; user-select: none; }

/* ---------- Motion: sticking, arriving, leaving ---------- */
@keyframes note-stick {
  0% { scale: 1.08; translate: 0 -12px; }
  55% { scale: .97; translate: 0 2px; }
  100% { scale: 1; translate: 0 0; }
}
@keyframes note-arrive { from { opacity: 0; scale: .9; } to { opacity: 1; scale: 1; } }
.note.is-sticking { animation: note-stick .5s var(--ease-bounce); }
.note.is-arriving { animation: note-arrive .45s var(--ease-out); }
.note.is-leaving { opacity: 0; scale: .92; transition: opacity .3s var(--ease-out), scale .3s var(--ease-out); }

/* ---------- More notes, toast ---------- */
.notes__more { display: flex; justify-content: center; margin-top: 1.75rem; }
.notes__archive { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 15.5rem), 1fr)); align-items: start; gap: 1.5rem 1.25rem; margin-top: 1.75rem; }
.notes__archive .note { rotate: calc(var(--rot, 0deg) * .5); }

.notes-toast {
  position: fixed; z-index: 150; bottom: 1.5rem; left: 50%; translate: -50% 1rem;
  max-width: calc(100% - 2rem); padding: .75rem 1.35rem; border-radius: var(--r-pill);
  background: var(--petrol); color: #fff; font-family: var(--font-display); font-size: 1.05rem;
  box-shadow: var(--shadow-3); opacity: 0; pointer-events: none;
  transition: opacity .25s var(--ease-out), translate .25s var(--ease-out);
}
.notes-toast.is-on { opacity: 1; translate: -50% 0; }

.note-measure { position: absolute; top: 0; left: 0; width: 0; height: 0; overflow: hidden; visibility: hidden; pointer-events: none; }

/* ---------- Small screens: the pad sits on top, notes become a readable list ---------- */
@media (max-width: 719.98px) {
  .notes__dock { justify-content: center; gap: 1.25rem; }
  .pad__stack { width: 8.75rem; height: 7.5rem; }
  .pad__label { font-size: 1.3rem; }
  .notes__controls { align-items: stretch; }
  .swatch { width: 2.3rem; height: 2.3rem; }
  .board--flow .note__text, .notes__archive .note__text { font-size: 1.35rem; }
}

@media (prefers-reduced-motion: reduce) {
  .sheet-ghost { rotate: 0deg; scale: 1; }
  .pad__stack:hover .pad__sheet--top { rotate: 0deg; }
  .note--draft.is-lifted { rotate: var(--rot, 0deg); scale: 1; }
}
