/* ==========================================================================
   قهوة الربوعية — shared styles (RTL, mobile-first, warm coffee palette). Font: Thmanyah Sans
   ========================================================================== */

@font-face { font-family: "Thmanyah Sans"; font-weight: 400; font-style: normal; font-display: swap;
  src: url("/fonts/thmanyahsans-400.woff2") format("woff2"); }
@font-face { font-family: "Thmanyah Sans"; font-weight: 500; font-style: normal; font-display: swap;
  src: url("/fonts/thmanyahsans-500.woff2") format("woff2"); }
@font-face { font-family: "Thmanyah Sans"; font-weight: 700; font-style: normal; font-display: swap;
  src: url("/fonts/thmanyahsans-700.woff2") format("woff2"); }
@font-face { font-family: "Thmanyah Sans"; font-weight: 900; font-style: normal; font-display: swap;
  src: url("/fonts/thmanyahsans-900.woff2") format("woff2"); }

:root {
  --espresso: #2a180d;
  --roast: #43271a;
  --mocha: #6b4128;
  --caramel: #c98a42;
  --caramel-deep: #a96d2b;
  --latte: #ead9c1;
  --cream: #f8f1e6;
  --foam: #fffcf6;
  --ink: #2b1a10;
  --muted: #7b6552;
  --line: #e6d6bf;
  --ok: #2f7a4b;
  --ok-bg: #e4f2e8;
  --err: #b2372c;
  --err-bg: #fbe7e4;
  --radius: 22px;
  --radius-sm: 12px;
  --shadow: 0 10px 30px -12px rgba(67, 39, 26, .28);
  --shadow-sm: 0 4px 14px -6px rgba(67, 39, 26, .25);
  --ease: cubic-bezier(.2, .8, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Thmanyah Sans", "Segoe UI", Tahoma, system-ui, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.7;
  color: var(--ink);
  background:
    radial-gradient(1100px 520px at 85% -8%, #f3dfc0 0%, transparent 60%),
    radial-gradient(900px 480px at -10% 30%, #f1e2cc 0%, transparent 55%),
    var(--cream);
  background-attachment: fixed;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--mocha); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 1.25em; height: 1.25em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon.filled { fill: currentColor; stroke: none; }

:focus-visible { outline: 3px solid color-mix(in srgb, var(--caramel) 70%, white); outline-offset: 2px; border-radius: 8px; }

.wrap { width: 100%; max-width: 760px; margin-inline: auto; padding: 18px 16px 8px; display: grid; gap: 20px; flex: 1; align-content: start; }

/* ---------- entrance animation ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.rise { animation: rise .6s var(--ease) both; animation-delay: calc(var(--i, 0) * 90ms); }

/* ---------- hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  color: var(--cream);
  background:
    radial-gradient(520px 260px at 100% 0%, rgba(201, 138, 66, .35), transparent 70%),
    linear-gradient(155deg, var(--roast) 0%, var(--espresso) 100%);
  border-radius: 28px;
  padding: 26px 20px 22px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
}
.hero-deco { position: absolute; inset-block-start: 8px; inset-inline-end: -10px; width: 130px; height: 130px; opacity: .13; z-index: -1; color: var(--latte); }
.hero-deco .steam { stroke-dasharray: 6 10; animation: steam 5s linear infinite; }
.hero-deco .steam:nth-child(2) { animation-delay: -1.7s; }
.hero-deco .steam:nth-child(3) { animation-delay: -3.2s; }
@keyframes steam { to { stroke-dashoffset: -64; } }

.eyebrow { font-size: .95rem; font-weight: 500; color: var(--caramel); letter-spacing: .02em; display: flex; align-items: center; gap: 8px; }
.eyebrow::before { content: ""; width: 26px; height: 2px; background: currentColor; border-radius: 2px; }
.turn-name { font-size: clamp(2.1rem, 9vw, 3.4rem); line-height: 1.25; font-weight: 900; color: #fff7ea; overflow-wrap: anywhere; }
.turn-sub { color: color-mix(in srgb, var(--latte) 82%, transparent); margin-top: -8px; }

.meta { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.meta li {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(255, 247, 234, .09); border: 1px solid rgba(255, 247, 234, .14);
  padding: 7px 14px; border-radius: 999px; font-size: .98rem;
}
.meta .icon { color: var(--caramel); }

/* ---------- rating widget ---------- */
.rate {
  background: var(--foam); color: var(--ink);
  border-radius: 20px; padding: 18px 16px 16px;
  display: grid; gap: 12px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .5);
  transition: background .3s var(--ease);
}
.rate.is-disabled { background: #efe5d6; }
.rate-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.rate-head h2 { font-size: 1.2rem; }
.rate-for { color: var(--muted); font-size: .95rem; }
.rate-note { display: flex; align-items: flex-start; gap: 8px; font-size: .97rem; color: var(--mocha); background: #f6ecdb; padding: 9px 12px; border-radius: var(--radius-sm); }
.rate-note.open { background: var(--ok-bg); color: var(--ok); }
.rate-note .icon { margin-top: 3px; }
.rate fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 12px; min-inline-size: 0; }
.rate fieldset:disabled { opacity: .62; }

.star-input { display: flex; gap: 4px; }
.star-btn { background: none; border: 0; padding: 4px; cursor: pointer; color: #d8c6ac; transition: transform .18s var(--ease), color .18s; border-radius: 10px; line-height: 0; }
.star-btn .icon { width: 2.3rem; height: 2.3rem; }
.star-btn.on { color: var(--caramel); }
.star-btn:hover { transform: scale(1.12); }
fieldset:disabled .star-btn { cursor: not-allowed; }
fieldset:disabled .star-btn:hover { transform: none; }

textarea, input[type="text"], input[type="email"], input[type="password"], input[type="time"], select {
  width: 100%; background: #fff; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  padding: 11px 14px; transition: border-color .2s, box-shadow .2s;
}
textarea { resize: vertical; min-height: 92px; }
textarea:focus, input:focus, select:focus { outline: none; border-color: var(--caramel); box-shadow: 0 0 0 4px rgba(201, 138, 66, .2); }
::placeholder { color: #a79381; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1.5px solid transparent; border-radius: 14px; padding: 11px 20px; font-weight: 700; cursor: pointer;
  transition: transform .15s var(--ease), background .2s, border-color .2s, box-shadow .2s, opacity .2s;
  text-decoration: none; line-height: 1.4;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--caramel); color: #2a180d; box-shadow: 0 6px 16px -8px rgba(169, 109, 43, .9); }
.btn-primary:hover:not(:disabled) { background: #d99650; }
.btn-ghost { background: transparent; border-color: rgba(255, 247, 234, .35); color: var(--cream); }
.btn-ghost:hover:not(:disabled) { background: rgba(255, 247, 234, .1); border-color: rgba(255, 247, 234, .6); }
.btn-outline { background: #fff; border-color: var(--line); color: var(--mocha); }
.btn-outline:hover:not(:disabled) { border-color: var(--caramel); background: #fff9ef; }
.btn-danger { background: var(--err); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #9c2e24; }
.btn-sm { padding: 7px 14px; font-size: .95rem; border-radius: 11px; }
.icon-btn { width: 40px; height: 40px; padding: 0; border-radius: 12px; background: #fff; border: 1.5px solid var(--line); color: var(--mocha); display: inline-grid; place-items: center; cursor: pointer; transition: all .18s var(--ease); }
.icon-btn:hover:not(:disabled) { border-color: var(--caramel); transform: translateY(-1px); }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }
.icon-btn.danger:hover:not(:disabled) { border-color: var(--err); color: var(--err); }

.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.actions .btn { flex: 1 1 160px; }
.hint { font-size: .92rem; color: color-mix(in srgb, var(--latte) 85%, transparent); }

.remind-form { display: grid; gap: 8px; background: rgba(255, 247, 234, .08); border: 1px solid rgba(255, 247, 234, .15); border-radius: 16px; padding: 14px; animation: rise .35s var(--ease) both; }
.remind-form label { font-weight: 500; }
.remind-form .row { display: flex; gap: 8px; flex-wrap: wrap; }
.remind-form input { flex: 1 1 200px; direction: ltr; text-align: left; color: var(--ink); }

.form-msg { min-height: 1.4em; font-size: .95rem; }
.form-msg.ok { color: #9be3b4; }
.form-msg.err { color: #ffb4a9; }
.panel .form-msg.ok, .rate .form-msg.ok { color: var(--ok); }
.panel .form-msg.err, .rate .form-msg.err { color: var(--err); }

/* ---------- panels ---------- */
.panel { background: var(--foam); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 18px; box-shadow: var(--shadow-sm); display: grid; gap: 14px; }
.panel > h2 { font-size: 1.3rem; display: flex; align-items: center; gap: 10px; }
.panel > h2 .icon { color: var(--caramel-deep); }
.sub { color: var(--muted); font-size: .96rem; margin-top: -8px; }
.empty { color: var(--muted); text-align: center; padding: 18px 8px; background: #f6ecdb; border-radius: var(--radius-sm); }

/* ---------- upcoming timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.timeline li { display: block; padding: 10px 12px; background: #fff; border: 1px solid var(--line); border-radius: 16px; transition: transform .2s var(--ease), box-shadow .2s; }
.timeline li:hover { transform: translateX(-3px); box-shadow: var(--shadow-sm); }
.timeline li.first { border-color: var(--caramel); background: #fff8ec; }
.date-chip { flex: none; width: 58px; text-align: center; background: var(--roast); color: var(--cream); border-radius: 14px; padding: 6px 0 7px; line-height: 1.15; }
.date-chip b { display: block; font-size: 1.45rem; }
.date-chip span { font-size: .8rem; opacity: .85; }
.tl-main { min-width: 0; flex: 1; }
.tl-name { font-weight: 700; overflow-wrap: anywhere; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.tl-date { color: var(--muted); font-size: .92rem; }
.badge { font-size: .78rem; font-weight: 700; padding: 2px 10px; border-radius: 999px; background: var(--caramel); color: #2a180d; white-space: nowrap; }

/* ---------- previous ratings ---------- */
.prev-list { display: grid; gap: 12px; }
.prev { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: grid; gap: 8px; }
.prev-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.prev-top .who { font-weight: 700; }
.prev-top .when { color: var(--muted); font-size: .92rem; }
.score { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.score .num { font-weight: 700; font-size: 1.15rem; }
.score .cnt { color: var(--muted); font-size: .92rem; }
.stars-bar { position: relative; display: inline-flex; line-height: 0; color: #dccbb1; }
.stars-bar .fill { position: absolute; inset-block: 0; inset-inline-start: 0; width: var(--pct, 0%); overflow: hidden; color: var(--caramel); }
.stars-bar .row { display: inline-flex; flex: none; }
.stars-bar .icon { width: 1.25rem; height: 1.25rem; }
details.comments summary { cursor: pointer; color: var(--mocha); font-weight: 500; font-size: .96rem; list-style: none; display: inline-flex; align-items: center; gap: 6px; }
details.comments summary::-webkit-details-marker { display: none; }
details.comments summary::after { content: "▾"; transition: transform .2s; }
details.comments[open] summary::after { transform: rotate(180deg); }
.comment-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.comment-list li { background: #faf3e6; border-radius: 12px; padding: 8px 12px; font-size: .96rem; overflow-wrap: anywhere; white-space: pre-wrap; }
.comment-list .stars-bar .icon { width: .9rem; height: .9rem; }

/* ---------- suggestions ---------- */
.suggest-form { display: grid; gap: 10px; }
.suggest-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.counter { color: var(--muted); font-size: .88rem; }

/* ---------- settings gear + footer ---------- */
.settings { display: flex; justify-content: center; }
.gear { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); border: 1.5px solid var(--line); background: var(--foam); transition: transform .5s var(--ease), color .2s, border-color .2s; }
.gear:hover { transform: rotate(90deg); color: var(--mocha); border-color: var(--caramel); }
.gear .icon { width: 1.35rem; height: 1.35rem; }
.footer { text-align: center; padding: 18px 16px 26px; color: var(--muted); font-size: .92rem; }
.footer a { color: var(--mocha); font-weight: 700; text-decoration: none; border-bottom: 1px dashed currentColor; }
.footer a:hover, .footer a:focus-visible { color: var(--caramel); }

/* ---------- skeleton ---------- */
.skeleton { display: inline-block; min-width: 9ch; border-radius: 10px; color: transparent; background: linear-gradient(90deg, rgba(255,255,255,.08), rgba(255,255,255,.2), rgba(255,255,255,.08)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- toast ---------- */
.toast { position: fixed; inset-inline: 16px; inset-block-end: 20px; margin-inline: auto; max-width: 420px; background: var(--espresso); color: var(--cream); padding: 12px 18px; border-radius: 14px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 10px; transform: translateY(24px); opacity: 0; pointer-events: none; transition: all .35s var(--ease); z-index: 50; }
.toast.show { transform: none; opacity: 1; }
.toast.err { background: var(--err); }
.toast .icon { color: var(--caramel); }
.toast.err .icon { color: #fff; }

/* ---------- dialog ---------- */
dialog { border: 0; border-radius: 22px; padding: 0; max-width: min(92vw, 420px); width: 100%; background: var(--foam); color: var(--ink); box-shadow: 0 30px 60px -20px rgba(42, 24, 13, .6); }
dialog::backdrop { background: rgba(42, 24, 13, .55); backdrop-filter: blur(3px); }
dialog[open] { animation: rise .3s var(--ease) both; }
dialog form { padding: 24px 22px 20px; display: grid; gap: 14px; }
dialog h3 { font-size: 1.25rem; }
dialog p { color: var(--muted); }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-start; flex-wrap: wrap; }

/* ---------- admin ---------- */
.admin-bar { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--cream) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.admin-bar .inner { max-width: 760px; margin-inline: auto; padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.admin-bar h1 { font-size: 1.15rem; display: flex; align-items: center; gap: 8px; }
.admin-bar h1 .icon { color: var(--caramel-deep); }
.admin-bar .nav { display: flex; gap: 8px; }
.login-card { max-width: 400px; margin: 10vh auto 0; background: var(--foam); border: 1px solid var(--line); border-radius: 24px; padding: 28px 22px; box-shadow: var(--shadow); display: grid; gap: 16px; }
.login-card h1 { font-size: 1.5rem; display: flex; align-items: center; gap: 10px; }
.login-card h1 .icon { color: var(--caramel-deep); }
.field { display: grid; gap: 6px; }
.field > label { font-weight: 500; }
.row-2 { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .row-2 { grid-template-columns: 1fr 1fr; } }
.emp-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.emp { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 8px 10px; }
.emp.moved { animation: flash 1s var(--ease); }
@keyframes flash { 0% { background: #fff0d4; transform: scale(1.015); } 100% { background: #fff; transform: none; } }
.emp .no { flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--latte); color: var(--mocha); display: grid; place-items: center; font-weight: 700; font-size: .92rem; }
.emp .nm { flex: 1; min-width: 0; font-weight: 500; overflow-wrap: anywhere; }
.emp .nm-input { flex: 1; min-width: 0; padding: 7px 10px; }
.emp .ctl { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.add-form { display: flex; gap: 8px; flex-wrap: wrap; }
.add-form input { flex: 1 1 200px; }
.item { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; }
.item .txt { white-space: pre-wrap; overflow-wrap: anywhere; min-width: 0; }
.item .when { color: var(--muted); font-size: .85rem; margin-top: 4px; }
.item .em { direction: ltr; unicode-bidi: plaintext; font-weight: 500; overflow-wrap: anywhere; }
.stack { display: grid; gap: 8px; }
.pill { font-size: .85rem; background: var(--latte); color: var(--mocha); border-radius: 999px; padding: 1px 10px; font-weight: 700; }

@media (min-width: 640px) {
  .hero { padding: 34px 32px 28px; }
  .rate { padding: 20px 22px 18px; }
  .panel { padding: 24px 26px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* stagger helpers (CSP forbids inline style attributes, so use data attributes) */
.rise[data-i="1"] { --i: 1; }
.rise[data-i="2"] { --i: 2; }
.rise[data-i="3"] { --i: 3; }
.rise[data-i="4"] { --i: 4; }

@media (max-width: 480px) {
  .emp { gap: 8px; padding: 8px; }
  .emp .ctl { gap: 4px; }
  .emp .icon-btn { width: 34px; height: 34px; border-radius: 10px; }
}

/* per-turn reminder */
.tl-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.tl-row .tl-main { flex: 1 1 140px; }
.tl-remind-btn { flex: none; }
.tl-remind { margin-top: 10px; }
.tl-remind-form { display: grid; gap: 8px; background: #faf3e6; border-radius: 14px; padding: 12px; animation: rise .3s var(--ease) both; }
.tl-remind-form label { font-weight: 500; font-size: .95rem; }
.tl-remind-form .row { display: flex; gap: 8px; flex-wrap: wrap; }
.tl-remind-form input { flex: 1 1 180px; direction: ltr; text-align: left; }
.item .for-turn { font-weight: 500; color: var(--mocha); margin-top: 2px; }
