/* Components added with the backend: account menu, dialogs, forms, comments, pagination, filters,
   profile, article body typography. Built only from the tokens defined in styles.css. */

/* ---------- Account control ---------- */
.account { position: relative; }
.account__btn { gap: 8px; padding-block: 4px; }
.account__name { max-width: 14ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account__menu { position: absolute; inset-inline-end: 0; top: calc(100% + 6px); z-index: 40; min-width: 210px;
  background: var(--surface); color: var(--text); border: 1px solid var(--rule); border-top: 3px solid var(--gold);
  border-radius: 3px; box-shadow: 0 12px 28px rgba(0, 0, 0, .18); padding: 6px; display: grid; }
.account__menu a, .account__menu button { display: block; width: 100%; text-align: start; padding: 9px 10px; border-radius: 2px;
  background: transparent; border: 0; color: inherit; text-decoration: none; font-family: var(--f-ui); font-size: var(--s-sm); cursor: pointer; }
.account__menu a:hover, .account__menu button:hover { background: var(--chip); }

.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex: none; background: var(--chip); }
.avatar--xs { width: 24px; height: 24px; }
.avatar--sm { width: 34px; height: 34px; }
.avatar--lg { width: 88px; height: 88px; }
.avatar--initials { display: inline-grid; place-items: center; background: var(--gold); color: var(--ink);
  font-family: "IBM Plex Sans", sans-serif; font-weight: 600; font-size: .8rem; letter-spacing: .02em; }
.avatar--xs.avatar--initials { font-size: .62rem; }
.avatar--lg.avatar--initials { font-size: 1.6rem; }

/* ---------- Modal (reuses the search overlay frame) ---------- */
.modal__panel { max-width: 460px; }
.modal__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--rule); }
.modal__head h2 { font-size: var(--s-lg); }
.modal__body { padding: 18px; overflow-y: auto; }
.search__more { padding: 0 16px 16px; font-family: var(--f-ui); font-size: var(--s-sm); }
.search__more a { color: var(--accent-text); font-weight: 600; }

/* ---------- Forms ---------- */
.form { display: grid; gap: 14px; }
.form > p { color: var(--muted); }
.field { display: grid; gap: 6px; min-width: 0; }
.field label { font-family: var(--f-ui); font-size: var(--s-sm); font-weight: 600; color: var(--text); }
.field input, .field textarea, .field select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--rule); border-radius: 3px; background: var(--surface); color: var(--text);
  font-family: var(--f-ui); font-size: 1rem; line-height: 1.4; }
.field textarea { resize: vertical; min-height: 5.5em; font-family: var(--f-body); font-size: 1.02rem; line-height: 1.6; }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px rgba(254, 182, 7, .28); }
.field [aria-invalid="true"] { border-color: #c2412d; }
.field__hint { font-family: var(--f-ui); font-size: var(--s-xs); color: var(--muted); }
html[dir="rtl"] .field__hint { font-size: var(--s-sm); }
.field__err, .form-error { font-family: var(--f-ui); font-size: var(--s-sm); color: #b3261e; }
.form-error { background: rgba(194, 65, 45, .08); border-inline-start: 3px solid #c2412d; padding: 10px 12px; }
.form-ok { font-family: var(--f-ui); font-size: var(--s-sm); color: var(--text); background: var(--chip); border-inline-start: 3px solid var(--gold); padding: 10px 12px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .field__err, :root:not([data-theme="light"]) .form-error { color: #ffb4a8; } }
:root[data-theme="dark"] .field__err, :root[data-theme="dark"] .form-error { color: #ffb4a8; }
.form-links { font-family: var(--f-ui); font-size: var(--s-sm); color: var(--muted); }
.linklike { background: none; border: 0; padding: 0; color: var(--accent-text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.linklike.danger, .btn-line.danger { color: #b3261e; }
.pw { position: relative; }
.pw input { padding-inline-end: 84px; }
.pw__toggle { position: absolute; inset-inline-end: 6px; top: 50%; transform: translateY(-50%); background: var(--chip); color: var(--text);
  border: 0; border-radius: 2px; padding: 5px 9px; font-family: var(--f-ui); font-size: var(--s-xs); cursor: pointer; }
.hp { position: absolute !important; inset-inline-start: -10000px; width: 1px; height: 1px; overflow: hidden; }
.btn-gold[disabled], .btn-line[disabled] { opacity: .6; cursor: progress; }
.btn-gold { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }

/* ---------- Loading / empty / error ---------- */
.state { display: grid; justify-items: center; gap: 12px; padding: 48px 16px; color: var(--muted); font-family: var(--f-ui); text-align: center; }
.state--error { color: var(--text); }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--rule); border-top-color: var(--gold); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.muted { color: var(--muted); }

.narrow { max-width: 560px; margin-inline: auto; display: grid; gap: 16px; padding-block: 12px; }
.page-title { font-size: clamp(1.7rem, 3.6vw, 2.4rem); font-weight: 700; }

/* ---------- Pagination ---------- */
.pager { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; margin-top: 36px; padding-top: 16px; border-top: 1px solid var(--rule); }
.pager a:last-child { justify-self: end; }
.pager__info { font-family: var(--f-ui); font-size: var(--s-sm); color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- Real images ---------- */
.ph--img { background: var(--chip); }
.ph--img::before, .ph--img::after { display: none; }
.ph--img img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Article ---------- */
.meta__author { color: var(--text); font-weight: 600; text-decoration: none; }
.meta__author:hover { text-decoration: underline; }
.article__figure { margin: 0; }
.article__figure figcaption { display: flex; flex-wrap: wrap; gap: 2px 10px; }
.figcredit { color: var(--muted); font-style: italic; }
.preview-banner { max-width: 760px; margin: 0 auto 18px; background: var(--ink); color: var(--gold); padding: 10px 14px; border-radius: 3px;
  font-family: var(--f-ui); font-size: var(--s-sm); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.prose { min-width: 0; overflow-wrap: anywhere; }
.prose h2 { font-size: var(--s-lg); margin-top: 12px; }
.prose h3 { font-size: var(--s-md); margin-top: 8px; }
.prose a { color: var(--accent-text); text-underline-offset: 3px; }
.prose ul, .prose ol { padding-inline-start: 1.4em; margin: 0; display: grid; gap: 6px; }
.prose blockquote { margin: 0; padding: 4px 0; padding-inline-start: 18px; border-inline-start: 4px solid var(--gold); color: var(--muted); }
.prose blockquote p { color: inherit; }
.prose img { border-radius: 2px; height: auto; }
.prose pre { overflow-x: auto; background: var(--chip); padding: 12px; border-radius: 3px; font-size: .9rem; }
.prose table { border-collapse: collapse; display: block; overflow-x: auto; max-width: 100%; font-family: var(--f-ui); font-size: var(--s-sm); }
.prose th, .prose td { border: 1px solid var(--rule); padding: 6px 10px; text-align: start; }
.prose hr { border: 0; border-top: 1px solid var(--rule); width: 100%; }

.tags { display: grid; gap: 10px; }
.tags__h { font-family: var(--f-ui); font-size: var(--s-xs); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
html[dir="rtl"] .tags__h { letter-spacing: 0; font-size: var(--s-sm); }
.tags ul { display: flex; flex-wrap: wrap; gap: 8px; }
.tags a { display: inline-block; padding: 5px 11px; border: 1px solid var(--rule); border-radius: 999px; font-family: var(--f-ui); font-size: var(--s-sm); text-decoration: none; }
.tags a:hover { border-color: var(--text); }

/* ---------- Comments ---------- */
.comments { max-width: 760px; margin: 48px auto 0; display: grid; gap: 16px; }
.comments .section-head { margin-bottom: 0; }
.comments__rules { font-family: var(--f-ui); font-size: var(--s-sm); color: var(--muted); }
.comments__signin { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--rule); padding: 14px 16px; border-radius: 3px; font-family: var(--f-ui); }
.comment-form { background: var(--surface); border: 1px solid var(--rule); padding: 14px 16px; border-radius: 3px; }
.comment-form__row { display: flex; gap: 10px; flex-wrap: wrap; }
.comments__list { display: grid; gap: 0; }
.comments__list > li.muted { font-family: var(--f-ui); padding-block: 8px; }
.comment { display: grid; gap: 8px; padding-block: 16px; border-top: 1px solid var(--rule); min-width: 0; }
.comment__replies { display: grid; margin-inline-start: 20px; padding-inline-start: 16px; border-inline-start: 2px solid var(--rule); }
.comment__replies .comment:first-child { border-top: 0; }
.comment--pending { background: linear-gradient(to right, rgba(254, 182, 7, .08), transparent); }
.comment__head { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center; }
.comment__head .avatar { grid-row: 1 / span 2; }
.comment__who { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; font-family: var(--f-ui); font-size: .95rem; }
.comment__body { white-space: pre-line; overflow-wrap: anywhere; }
.comment__actions { display: flex; gap: 16px; flex-wrap: wrap; font-family: var(--f-ui); font-size: var(--s-sm); }
.comment__actions:empty { display: none; }
.comment__actions .linklike { font-weight: 500; color: var(--muted); }
.comment__actions .linklike:hover { color: var(--text); }
.pill { display: inline-block; font-family: var(--f-ui); font-size: .7rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 999px; background: var(--chip); color: var(--text); border: 1px solid var(--rule); }
html[dir="rtl"] .pill { letter-spacing: 0; text-transform: none; font-size: .78rem; }
.pill--staff { background: var(--gold); color: var(--ink); border-color: var(--gold); }
.pill--pending, .pill--flagged { border-color: var(--focus); }
.pill--rejected, .pill--hidden { opacity: .75; }

/* ---------- Search page filters ---------- */
.filters { display: grid; gap: 14px; grid-template-columns: 1fr; background: var(--surface); border: 1px solid var(--rule); padding: 16px; border-radius: 3px; margin-bottom: 24px; }
@media (min-width: 640px) { .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); } .filters .field:first-child { grid-column: 1 / -1; } }
@media (min-width: 1000px) { .filters { grid-template-columns: 2fr 1fr 1fr 1fr 1fr 1fr; } .filters .field:first-child { grid-column: auto; } }
.filters__actions { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; grid-column: 1 / -1; }
.search-count { margin-bottom: 18px; }
.author-head { margin-top: 6px; }
.lang-links { display: grid; gap: 8px; }

/* ---------- Profile ---------- */
.profile__grid { display: grid; gap: 24px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .profile__grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: 3px; padding: 18px; display: grid; gap: 14px; align-content: start; min-width: 0; }
.panel__h { font-size: var(--s-md); }
.panel__foot { border-top: 1px solid var(--rule); padding-top: 14px; }
.avatar-edit { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.avatar-edit__actions { display: grid; gap: 8px; justify-items: start; }
.avatar-edit__actions label.btn-line { cursor: pointer; }
.avatar-edit__actions:focus-within label.btn-line { outline: 3px solid var(--focus); outline-offset: 2px; }
.my-comments { display: grid; gap: 0; }
.my-comments li { display: grid; gap: 6px; padding-block: 12px; border-top: 1px solid var(--rule); }
.my-comments li:first-child { border-top: 0; }
.my-comments__body { white-space: pre-line; overflow-wrap: anywhere; font-size: 1rem; }
.my-comments a { color: var(--accent-text); }

@media (max-width: 719px) {
  .account__name { display: none; }
  .account__btn span:not(.avatar) { display: none; }
  #signInBtn span { display: none; }
  .modal__body { padding: 16px; }
  .comment__replies { margin-inline-start: 8px; padding-inline-start: 10px; }
}
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
