/*
 * ZDES.lab admin panel: the one and only stylesheet.
 *
 * Served from the same origin (GET /static/admin.css, web/static_files.py),
 * because the Content-Security-Policy is default-src 'self': no inline
 * styles, no style="" attributes, no external fonts or images, no @import.
 * All interface texts live in content/admin.yaml, never in this file
 * (a test keeps Cyrillic out of it).
 *
 * Colour language, on purpose the same on every page:
 *   red     - instance PROD, guard banner, errors and refusals
 *   amber   - instance TEST, warnings
 *   green   - success
 *   blue    - the current page, the primary action, neutral news
 *   teal    - links and the focus ring
 * The look follows cards.zdeslab.ru (ADMIN-RESKIN.md); the site orange is
 * not used anywhere: it is too close to the amber TEST plate.
 * Rules for the coloured parts are flat (plain hex colours, no variables),
 * so tests/test_web_ui_layout.py can read the colour of each rule.
 * The whole palette is listed here; tests/test_admin_reskin.py checks that
 * every colour of the file is one of these and that none is missing.
 *
 * Site:
 *   #06131c ink: text, hover of the primary button
 *   #063d59 blue: primary button, current menu item, info
 *   #0d8b96 teal: focus ring, preview stripe
 *   #0b6d78 dark teal: links (teal itself is too pale for text)
 *   #f3f0e9 cream: page background
 *   #ffffff white: header, fields, tables, plain buttons
 *   #dff5f2 mint: hover of buttons and menu
 *   #e7f0ed sage: table header
 *   #faf8f3 paper: zebra rows
 *   #d6d1c4 line: borders of tables, cards, header
 *   #45535a grey text: hints
 *   #5f676b grey border: fields
 * Signals:
 *   #c62828 #7f0000 #7f1d1d #fdecea red
 *   #ffb300 #b26a00 #1f1a00 #f9a825 #5f4300 #fff8e1 amber
 *   #2e7d32 #14421a #e8f5e9 green
 *   #e0ebf5 info background
 *   #06131c1f card shadow (the only eight-digit colour)
 */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 18px;
  line-height: 1.55;
  color: #06131c;
  background: #f3f0e9;
  overflow-wrap: break-word;
}

/* ---- header: brand mark, instance plate, navigation, logout ---- */

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1rem;
  padding: 0.7rem 1rem;
  background: #ffffff;
  border-top: 10px solid #ffb300;
  border-bottom: 1px solid #d6d1c4;
}

body.instance-prod .site-header {
  border-top-color: #c62828;
}

/* The site mark: "zdes" with a small raised "lab" (not a link). */
.brand {
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -1.5px;
  line-height: 1.2;
  color: #06131c;
}

.brand sup {
  margin-left: 1px;
  font-size: 9px;
  letter-spacing: 0;
  line-height: 0;
}

.instance-plate {
  display: inline-block;
  padding: 0.25em 0.9em;
  border-radius: 4px;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.instance-plate.instance-test {
  background: #ffb300;
  color: #1f1a00;
  border: 2px solid #b26a00;
}

.instance-plate.instance-prod {
  background: #c62828;
  color: #ffffff;
  border: 2px solid #7f0000;
}

.main-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.5rem;
}

.main-nav a {
  display: inline-block;
  min-height: 44px;
  padding: 0.5em 0.9em;
  border: 2px solid transparent;
  border-radius: 100px;
  color: #063d59;
  font-weight: 600;
  text-decoration: none;
}

.main-nav a:hover {
  background: #dff5f2;
  border-color: #dff5f2;
  color: #063d59;
}

.main-nav a[aria-current="page"] {
  background: #063d59;
  border-color: #063d59;
  color: #ffffff;
}

.logout-form {
  margin: 0 0 0 auto;
}

/* ---- page body ---- */

.page {
  width: 100%;
  max-width: 76rem;
  margin: 0 auto;
  padding: 1rem;
}

/* Running text stays about 60-70 characters wide; tables and card grids may
   use the full width of the page. */
.page > h1,
.page > h2,
.page > h3,
.page > p,
.page > ul,
.page > ol,
.page > form,
.page > pre,
.page > .guard-banner,
.page > .error,
.page > .warning,
.page > .info,
.page > .ok,
.page > .help-toc,
.page > .help-steps,
.page > .help-caveats,
.page > .help-list {
  max-width: 68ch;
}

h1 {
  margin: 0.4rem 0 0.8rem;
  font-size: 1.6rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

h2 {
  margin: 1.6rem 0 0.6rem;
  font-size: 1.3rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

h3 {
  margin: 1.2rem 0 0.5rem;
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.3;
}

p,
ul,
ol {
  margin: 0.6rem 0;
}

a {
  color: #0b6d78;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

a:hover {
  color: #06131c;
}

img {
  max-width: 100%;
  height: auto;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid #0d8b96;
  outline-offset: 2px;
}

/* The tick box "remove image" and the file picker button, in site colours. */
input[type="checkbox"] {
  accent-color: #063d59;
}

/* The field itself: its font is the browser's 13.33px, and the button inherits it from here;
   max-width keeps it inside the page on a 320px phone. */
input[type="file"] {
  max-width: 100%;
  font: inherit;
}

input[type="file"]::file-selector-button {
  min-height: 44px;
  margin-right: 0.75rem;
  padding: 0.4em 1.2em;
  font: inherit;
  font-weight: 600;
  color: #06131c;
  background: #ffffff;
  border: 2px solid #063d59;
  border-radius: 100px;
  cursor: pointer;
}

input[type="file"]::file-selector-button:hover {
  background: #dff5f2;
}

/* ---- forms ---- */

label {
  display: block;
  font-weight: 600;
}

input[type="text"],
input[type="password"],
textarea {
  display: block;
  width: 100%;
  max-width: 100%;
  min-height: 48px;
  margin-top: 0.3rem;
  padding: 0.55em 0.75em;
  font: inherit;
  color: inherit;
  background: #ffffff;
  border: 2px solid #5f676b;
  border-radius: 12px;
}

/* The post is typed here in full, several paragraphs (rows="10" in the template). */
textarea {
  min-height: 12rem;
  resize: vertical;
}

/* A line of help under a field label: the same width as the field, lighter than the label. */
.hint {
  display: block;
  margin: 0.2rem 0 0.1rem;
  font-weight: 400;
  color: #45535a;
}

/* Date and time of a scheduled post: one field, Moscow time (the browser knows
   no zone, the server reads the value as Moscow). Narrower than a text line. */
input[type="datetime-local"] {
  display: block;
  width: 100%;
  max-width: 20rem;
  min-height: 48px;
  margin-top: 0.3rem;
  padding: 0.55em 0.75em;
  font: inherit;
  color: inherit;
  background: #ffffff;
  border: 2px solid #5f676b;
  border-radius: 12px;
}

button {
  min-height: 48px;
  padding: 0.5em 1.4em;
  font: inherit;
  font-weight: 600;
  color: #06131c;
  background: #ffffff;
  border: 2px solid #063d59;
  border-radius: 100px;
  cursor: pointer;
}

button:hover {
  background: #dff5f2;
}

/* The one action that must not be missed: Publish (and Sign in). */
button.primary {
  padding: 0.65em 2em;
  font-size: 1.1rem;
  color: #ffffff;
  background: #063d59;
  border-color: #063d59;
}

button.primary:hover {
  background: #06131c;
  border-color: #06131c;
}

/* A small form next to other content (stuck-publish choices, views in a table). */
.inline-form {
  display: inline-block;
  margin: 0 0.5rem 0.5rem 0;
}

/* The move field sits in a form next to its button, not on its own line. */
.inline-form input[type="datetime-local"] {
  display: inline-block;
  width: auto;
  max-width: 100%;
  margin: 0 0.4rem 0.3rem 0;
}

td input[type="text"] {
  display: inline-block;
  width: 8em;
  margin: 0 0.4rem 0 0;
}

/* ---- messages ---- */

.guard-banner {
  margin: 1rem 0;
  padding: 0.8rem 1rem;
  color: #7f1d1d;
  background: #fdecea;
  border: 3px solid #c62828;
  border-radius: 14px;
}

.guard-banner p,
.guard-banner ul {
  margin: 0.3rem 0;
}

.error {
  margin: 1rem 0;
  padding: 0.7rem 1rem;
  color: #7f1d1d;
  background: #fdecea;
  border: 2px solid #c62828;
  border-radius: 14px;
}

/* An empty error line (the image field, filled in by admin.js) draws no box.
   Not display: none, so that aria-live keeps announcing the text later. */
.error:empty {
  padding: 0;
  border: 0;
}

.warning {
  margin: 1rem 0;
  padding: 0.7rem 1rem;
  color: #5f4300;
  background: #fff8e1;
  border: 2px solid #f9a825;
  border-radius: 14px;
}

/* Neutral news: a post is scheduled and waiting (the site blue). */
.info {
  margin: 1rem 0;
  padding: 0.7rem 1rem;
  color: #063d59;
  background: #e0ebf5;
  border: 2px solid #063d59;
  border-radius: 14px;
}

.ok {
  margin: 1rem 0;
  padding: 0.7rem 1rem;
  color: #14421a;
  background: #e8f5e9;
  border: 2px solid #2e7d32;
  border-radius: 14px;
}

/* ---- post preview ---- */

/* An example value to type (2026-10-02T18:00): never broken in the middle. */
code {
  font-family: ui-monospace, Consolas, "Courier New", monospace;
  white-space: nowrap;
}

/* Post image (POST-IMAGE.md, I7): never wider than the page, proportions kept. */
.post-image {
  display: block;
  max-width: 100%;
  max-height: 24rem;
  height: auto;
  border: 1px solid #d6d1c4;
  border-radius: 8px;
}

pre {
  margin: 0.5rem 0 1rem;
  padding: 0.75em 1em;
  font: inherit;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #ffffff;
  border: 1px solid #d6d1c4;
  border-left: 6px solid #0d8b96;
  border-radius: 6px;
}

/* ---- tables: bordered, padded, scroll sideways inside their own box ---- */

.table-wrap {
  max-width: 100%;
  margin: 1rem 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid #d6d1c4;
  background: #ffffff;
}

table {
  width: 100%;
  min-width: 34rem;
  border-collapse: collapse;
  background: #ffffff;
}

th,
td {
  padding: 0.55em 0.75em;
  text-align: left;
  vertical-align: top;
  border: 1px solid #d6d1c4;
}

th {
  font-weight: 700;
  background: #e7f0ed;
}

tbody tr:nth-child(even) td {
  background: #faf8f3;
}

/* ---- deck: cards ---- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
  gap: 1rem;
  margin: 1rem 0;
}

.card {
  padding: 0.75rem;
  background: #ffffff;
  border: 1px solid #d6d1c4;
  border-radius: 8px;
  box-shadow: 0 6px 18px #06131c1f;
}

.page > .card {
  max-width: 16rem;
}

.card p {
  margin: 0.4rem 0;
}

.card img {
  display: block;
}

/* ---- instruction page (content/help.html, HELP-IN-ADMIN.md): twelve help-* classes ---- */

.help-lead {
  font-size: 1.1rem;
}

.help-toc {
  margin: 1rem 0;
  padding: 0.9rem 1.2rem 0.6rem;
  background: #ffffff;
  border: 1px solid #d6d1c4;
  border-radius: 14px;
}

.help-toc h2 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}

.help-toc ol {
  margin: 0;
  padding-left: 1.5rem;
}

.help-toc li {
  margin: 0 0 0.3rem;
}

.help-toc ul {
  margin: 0.2rem 0 0.3rem;
  padding: 0;
  list-style: none;
}

.help-toc ul li {
  margin: 0 0 0.15rem;
  font-size: 0.95em;
}

.help-toc ul li::before {
  content: "- ";
  color: #45535a;
}

.help-toc a {
  text-decoration: none;
}

.help-toc a:hover,
.help-toc a:focus {
  text-decoration: underline;
}

/* The section number inside h2. */
.help-num {
  margin-right: 0.4rem;
  font-size: 0.9em;
  font-weight: 400;
  color: #45535a;
}

/* Numbered steps in circles. */
.help-steps {
  margin: 0.6rem 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.help-steps > li {
  position: relative;
  padding: 0.75rem 0 0.75rem 2.6rem;
  border-top: 1px solid #d6d1c4;
  counter-increment: step;
}

.help-steps > li:first-child {
  border-top: 0;
}

.help-steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  font-size: 0.875rem;
  font-weight: 600;
  color: #ffffff;
  background: #063d59;
}

.help-steps p {
  margin: 0 0 0.4rem;
}

.help-steps p:last-child {
  margin-bottom: 0;
}

.help-sub {
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
}

.help-sub li {
  position: relative;
  margin: 0 0 0.4rem;
  padding-left: 0.9rem;
}

.help-sub li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.7em;
  width: 0.3rem;
  height: 0.3rem;
  border-radius: 50%;
  background: #d6d1c4;
}

.help-sub li:last-child {
  margin-bottom: 0;
}

/* A list with dots. */
.help-list {
  margin: 0.6rem 0 0.9rem;
  padding: 0;
  list-style: none;
}

.help-list li {
  position: relative;
  margin: 0 0 0.55rem;
  padding-left: 1.1rem;
}

.help-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.65em;
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: #063d59;
}

/* A quoted answer of the bot. */
.help-quote {
  margin: 0.6rem 0;
  padding: 0.45rem 0.7rem;
  border-left: 3px solid #0d8b96;
  border-radius: 0 6px 6px 0;
  font-size: 0.95rem;
  background: #ffffff;
}

/* Caveats: numbered cards with a stripe on the left. */
.help-caveats {
  margin: 0.6rem 0;
  padding: 0;
  list-style: none;
  counter-reset: cav;
}

.help-caveats > li {
  margin: 0 0 0.6rem;
  padding: 0.75rem 1rem;
  border-left: 3px solid #f9a825;
  border-radius: 0 8px 8px 0;
  background: #ffffff;
  counter-increment: cav;
}

.help-caveats > li p {
  margin: 0;
}

.help-caveats > li p + p {
  margin-top: 0.45rem;
}

.help-caveat-title {
  font-weight: 600;
}

.help-caveat-title::before {
  content: counter(cav) ". ";
  font-weight: 400;
  color: #45535a;
}

/* "Message - what to do" tables: widths of the first column and its weight. */
.help-table td:first-child {
  width: 24%;
  font-weight: 600;
}

.help-table-wide td:first-child {
  width: 50%;
  font-weight: 400;
}

.help-table-nowrap td:first-child {
  width: auto;
  white-space: nowrap;
}

/* ---- tablets ---- */

/* With the brand mark the header of TEST needs about 815px (PROD about 850px). Between
   a phone and a desktop the menu and the gaps get tighter, so Logout stays on the first
   row at 768px; heights and the layout are the same. */
@media (min-width: 40.0625rem) and (max-width: 68rem) {
  .site-header {
    gap: 0.5rem 0.4rem;
    padding: 0.7rem 0.6rem;
  }

  .main-nav {
    gap: 0.25rem 0.1rem;
  }

  .main-nav a {
    padding: 0.5em 0.3em;
  }

  .instance-plate {
    padding: 0.2em 0.5em;
  }

  .logout-form button {
    padding: 0.5em 0.8em;
  }
}

/* ---- phones ---- */

/* Brand mark, plate and Logout share the first row, the navigation takes the second. */
@media (max-width: 40rem) {
  body {
    font-size: 17px;
  }

  .site-header {
    gap: 0.4rem 0.75rem;
    padding: 0.5rem 0.75rem;
  }

  .brand {
    font-size: 20px;
  }

  .main-nav {
    order: 3;
    flex-basis: 100%;
    gap: 0.1rem 0.1rem;
  }

  .main-nav a {
    padding: 0.5em 0.3em;
  }

  .page {
    padding: 0.75rem;
  }

  /* The instruction tables fold into rows (two columns of long text do not scroll
     sideways well); the other tables of the admin keep their own scroll box. */
  .help-table,
  .help-table tbody,
  .help-table tr,
  .help-table td {
    display: block;
    width: auto;
  }

  .help-table {
    min-width: 0;
  }

  .help-table thead {
    display: none;
  }

  .help-table tr {
    padding: 0.5rem 0;
    border-top: 1px solid #d6d1c4;
  }

  .help-table tr:first-child {
    border-top: 0;
  }

  .help-table td {
    padding: 0.1rem 0;
    border: 0;
  }

  .help-table td:first-child,
  .help-table-wide td:first-child {
    width: auto;
  }

  .help-table-nowrap td:first-child {
    white-space: normal;
  }
}

/* Print: every admin page. No header or logout button on paper, ink on white,
   the whole sheet width, tables without a scroll frame, links as plain text.
   Blocks that read as one piece stay on one page. */
@media print {
  .site-header {
    display: none;
  }

  body {
    color: #06131c;
    background: #ffffff;
  }

  .page {
    max-width: none;
    padding: 0;
  }

  /* The same list as on screen (68ch): `.page > *` would lose to `.page > h1`. */
  .page > h1,
  .page > h2,
  .page > h3,
  .page > p,
  .page > ul,
  .page > ol,
  .page > form,
  .page > pre,
  .page > .guard-banner,
  .page > .error,
  .page > .warning,
  .page > .info,
  .page > .ok,
  .page > .help-toc,
  .page > .help-steps,
  .page > .help-caveats,
  .page > .help-list {
    max-width: none;
  }

  .table-wrap {
    overflow: visible;
    border: 0;
  }

  table {
    min-width: 0;
  }

  a {
    color: #06131c;
    text-decoration: none;
  }

  .info,
  .help-steps > li,
  .help-caveats > li,
  tr {
    break-inside: avoid;
  }

  h2,
  h3 {
    break-after: avoid;
  }
}
