/* prisoner-letters - styles.
 *
 * Mulish; red #FF4236, black, grey #B8B8B8 on a #F5F5F5 page. The visual
 * language (polaroid photos, red name highlights, red band) follows the
 * project's Figma mock-ups.
 *
 * No inline styles anywhere (the CSP has no 'unsafe-inline'), so everything
 * visual lives here.
 */

@font-face {
  font-family: "Mulish";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("fonts/mulish-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Mulish";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("fonts/mulish-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Mulish";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("fonts/mulish-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --red: #ff4236;
  --red-dark: #d92f24;
  --red-tint: #ffe3e1;
  --black: #000;
  --ink: #1a1a1a;
  --muted: #5c5c5c;
  --grey: #b8b8b8;
  --line: #e2e2e2;
  --page: #f5f5f5;
  --white: #fff;
  --ok: #1d7a3a;
  --radius: 4px;
  --shadow: 0 2px 10px rgb(0 0 0 / 0.08);
  --font: "Mulish", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

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

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

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.55;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: var(--red-dark);
}

a:hover {
  color: var(--black);
}

:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 2px;
}

.wrap {
  width: 100%;
  max-width: 1160px;
  margin: 0 auto;
  padding-inline: 20px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------------------------------------------------------------- header */

.site-header {
  background: var(--white);
  border-bottom: 1px solid var(--line);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-block: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--black);
  text-decoration: none;
}

.brand img {
  width: 44px;
  height: auto;
  flex: none;
}

.brand-name {
  font-weight: 900;
  font-size: 1.05rem;
  line-height: 1.1;
  text-transform: uppercase;
  letter-spacing: 0.01em;
}

@media (max-width: 640px) {
  .site-header .wrap {
    flex-wrap: wrap;
    gap: 6px 16px;
    padding-block: 10px 6px;
  }

  .brand-name {
    font-size: 0.9rem;
  }

  /* The links drop to their own row rather than disappearing: the article
     must stay one tap away on a phone too. */
  .site-nav {
    width: 100%;
    gap: 0 18px;
    font-size: 0.92rem;
  }

  .site-nav a {
    padding-block: 6px;
  }
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0 22px;
}

/* The logo's bars, as a link marker. */
.nav-hash {
  color: var(--red);
  font-weight: 900;
  margin-right: 3px;
}

.site-header nav a {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--ink);
  text-decoration: none;
}

/* ------------------------------------------------------------------ hero */

.hero {
  padding-block: 48px 36px;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 40px;
  align-items: center;
}

@media (max-width: 900px) {
  .hero-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .hero-map {
    max-width: 520px;
  }
}

@media (max-width: 640px) {
  .hero {
    padding-block: 28px 24px;
  }

  .hero-map {
    max-width: 290px;
    margin-inline: auto;
  }
}

.hero-map {
  margin: 0;
}

.hero-map img {
  width: 100%;
  height: auto;
}

.hero h1 {
  margin: 0 0 16px;
  font-size: clamp(2rem, 5vw, 3.4rem);
  font-weight: 900;
  line-height: 1.08;
  letter-spacing: -0.01em;
  max-width: 24ch;
}

.hero h1 em {
  font-style: normal;
  color: var(--red);
}

.hero p {
  max-width: 62ch;
  font-size: 1.12rem;
  margin: 0 0 12px;
}

/* The red band under the hero. */
.band {
  background: var(--red);
  color: var(--white);
  font-weight: 800;
  padding-block: 14px;
  text-align: center;
}

/* ------------------------------------------------------------------ grid */

.prisoners {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: 28px;
  padding-block: 40px 64px;
  margin: 0;
  list-style: none;
}

.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.card-photo {
  padding: 22px 22px 0;
}

.polaroid {
  background: var(--white);
  padding: 10px 10px 34px;
  box-shadow: 0 3px 12px rgb(0 0 0 / 0.18);
  transform: rotate(-1.5deg);
  max-width: 260px;
  margin-inline: auto;
}

.card:nth-child(even) .polaroid {
  transform: rotate(1.5deg);
}

.polaroid img,
.polaroid .no-photo {
  aspect-ratio: 4 / 5;
  width: 100%;
  /* The width/height attributes reserve space before load; without this the
     height attribute wins over aspect-ratio and the photo stretches. */
  height: auto;
  object-fit: cover;
  filter: grayscale(0.15);
}

.photo-credit {
  margin: 6px 0 -26px;
  font-size: 0.68rem;
  line-height: 1.3;
  color: var(--muted);
  text-align: center;
  overflow-wrap: anywhere;
}

.no-photo {
  background: repeating-linear-gradient(
    -45deg,
    #ececec 0 10px,
    #e2e2e2 10px 20px
  );
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.9rem;
}

.card-body {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.card h2 {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 900;
  line-height: 1.15;
}

.surname {
  color: var(--red);
}

.card .name-ru {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.card .summary {
  margin: 0;
  font-weight: 700;
}

.card details {
  font-size: 0.97rem;
}

.card summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--red-dark);
  list-style: none;
}

.card summary::-webkit-details-marker {
  display: none;
}

.card summary::after {
  content: " ›";
}

.card details[open] summary::after {
  content: " ‹";
}

.card details p {
  margin: 8px 0 0;
}

.card .actions {
  margin-top: auto;
  padding-top: 8px;
}

/* --------------------------------------------------------------- buttons */

.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 22px;
  border: 2px solid var(--black);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--black);
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.button.primary,
button.primary {
  background: var(--red);
  border-color: var(--red);
  color: var(--white);
}

.button.primary:hover,
button.primary:hover {
  background: var(--red-dark);
  border-color: var(--red-dark);
  color: var(--white);
}

.button:hover,
button:hover {
  background: var(--black);
  color: var(--white);
}

button:disabled,
button:disabled:hover {
  background: var(--grey);
  border-color: var(--grey);
  color: var(--white);
  cursor: not-allowed;
}

.button.block {
  width: 100%;
}

button.small,
.button.small {
  min-height: 34px;
  padding: 4px 12px;
  font-size: 0.88rem;
}

/* --------------------------------------------------------------- compose */

.compose {
  display: grid;
  grid-template-columns: minmax(0, 340px) minmax(0, 1fr);
  gap: 40px;
  padding-block: 40px 72px;
  align-items: start;
}

@media (max-width: 820px) {
  .compose {
    grid-template-columns: 1fr;
    gap: 24px;
  }
}

.about-prisoner {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

@media (min-width: 821px) {
  .about-prisoner {
    position: sticky;
    top: 20px;
  }
}

.about-prisoner .polaroid {
  max-width: 220px;
  margin-bottom: 18px;
}

.about-prisoner h1 {
  font-size: 1.6rem;
  font-weight: 900;
  line-height: 1.15;
  margin: 0 0 8px;
}

.about-prisoner p {
  margin: 0 0 10px;
  font-size: 0.97rem;
}

.bio-more {
  display: none;
  margin-bottom: 10px;
}

.bio-more summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--red-dark);
  margin-bottom: 6px;
}

@media (max-width: 820px) {
  .bio-full {
    display: none;
  }

  .bio-more {
    display: block;
  }

  .about-prisoner {
    padding: 18px;
  }

  .about-prisoner .polaroid {
    max-width: 170px;
  }

  .about-prisoner h1 {
    font-size: 1.4rem;
  }
}

.sheet {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(20px, 4vw, 36px);
}

.sheet h2 {
  font-size: 1.7rem;
  font-weight: 900;
  line-height: 1.15;
  margin: 0 0 14px;
}

.guidance {
  background: var(--page);
  border-left: 4px solid var(--red);
  padding: 14px 18px;
  margin: 0 0 24px;
  font-size: 0.95rem;
}

.guidance ul {
  margin: 6px 0 0;
  padding-left: 20px;
}

.guidance li + li {
  margin-top: 4px;
}

/* The feedback box at the foot of the Donate page. */
.feedback {
  margin-top: 40px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.feedback-sent {
  border-left: 4px solid var(--ok);
  padding: 10px 14px;
  background: var(--page);
}

/* In place of the form, for visitors outside Australia (geo.py). */
.australia-only {
  margin: 0;
}

.field {
  margin-bottom: 20px;
}

.field label,
.field .label {
  display: block;
  font-weight: 800;
  margin-bottom: 6px;
}

.field .hint {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 400;
  margin-top: 2px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
select,
textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--white);
  border: 2px solid var(--grey);
  border-radius: var(--radius);
  padding: 10px 12px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--black);
  outline: none;
}

textarea {
  min-height: 320px;
  resize: vertical;
  line-height: 1.6;
}

.letter-box {
  /* Faint ruled lines, like the paper the letter will be printed on. */
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent calc(1.6em - 1px),
    #eef0f4 calc(1.6em - 1px),
    #eef0f4 1.6em
  );
  background-attachment: local;
  background-position-y: 10px;
}

.field.invalid input,
.field.invalid textarea {
  border-color: var(--red);
}

.error-text {
  color: var(--red-dark);
  font-weight: 700;
  font-size: 0.93rem;
  margin: 6px 0 0;
}

.counter {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 6px;
  font-size: 0.92rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.counter strong {
  color: var(--ink);
}

.counter.over strong,
.counter.over {
  color: var(--red-dark);
}

.counter.ok strong {
  color: var(--ok);
}

.meter {
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}

.meter span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--ok);
  transition: width 0.15s;
}

.meter.over span {
  background: var(--red);
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 560px) {
  .row {
    grid-template-columns: 1fr;
  }
}

fieldset {
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 0 0 22px;
}

legend {
  font-weight: 800;
  padding-inline: 6px;
}

.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-weight: 600;
  margin-bottom: 12px;
}

.check input {
  width: 20px;
  height: 20px;
  margin-top: 3px;
  accent-color: var(--red);
  flex: none;
}

.small-print {
  color: var(--muted);
  font-size: 0.86rem;
}

/* Honeypot. Hidden from people, visible to naive bots. */
.hp {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ----------------------------------------------------------- thank you */

.thanks {
  max-width: 640px;
  margin: 56px auto 80px;
  text-align: center;
}

.thanks .sheet {
  text-align: left;
}

.ref {
  display: inline-block;
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  background: var(--red-tint);
  color: var(--black);
  padding: 4px 14px;
  border-radius: var(--radius);
}

/* ---------------------------------------------------------------- prose */

.prose {
  max-width: 720px;
  margin: 48px auto 80px;
}

.prose h1 {
  font-weight: 900;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  line-height: 1.15;
}

.article {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(22px, 5vw, 48px);
}

.article h2 {
  font-weight: 900;
  font-size: 1.3rem;
  margin: 32px 0 8px;
  padding-left: 12px;
  border-left: 4px solid var(--red);
}

.article .lede {
  font-size: 1.15rem;
}

.article li + li {
  margin-top: 6px;
}

.article-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 32px;
}

/* ---------------------------------------------------------------- footer */

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--white);
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  padding-block: 22px;
}

/* ================================================================= admin */

body.admin {
  font-size: 15px;
}

.admin .site-header .wrap {
  padding-block: 10px;
}

.admin-nav {
  display: flex;
  gap: 18px;
  align-items: center;
  flex-wrap: wrap;
}

.admin-nav form {
  margin: 0;
}

.admin main {
  padding-block: 24px 64px;
}

.flash {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-weight: 700;
}

.flash.ok {
  background: #e3f3e8;
  color: var(--ok);
}

.flash.error {
  background: var(--red-tint);
  color: var(--red-dark);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.tabs a {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--white);
  border: 1px solid var(--line);
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  font-size: 0.9rem;
}

.tabs a[aria-current="page"] {
  background: var(--black);
  border-color: var(--black);
  color: var(--white);
}

.tabs .n {
  font-variant-numeric: tabular-nums;
  opacity: 0.7;
  margin-left: 4px;
}

.filters {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.filters select {
  width: auto;
  padding: 6px 10px;
}

.table-scroll {
  overflow-x: auto;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

td.num {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

tr:hover td {
  background: #fafafa;
}

.excerpt {
  color: var(--muted);
  max-width: 48ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 800;
  background: var(--line);
}

.pill.new { background: #fff1c2; }
.pill.ready { background: #dbe9ff; }
.pill.sent { background: #e3f3e8; }
.pill.replied { background: var(--red); color: var(--white); }
.pill.rejected,
.pill.spam { background: #ddd; color: var(--muted); }

.letter-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
}

@media (max-width: 900px) {
  .letter-grid {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 20px;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 1.1rem;
  font-weight: 900;
}

.panel h3 {
  margin: 16px 0 8px;
  font-size: 0.95rem;
}

.letter-text {
  white-space: pre-wrap;
  font-size: 1rem;
  line-height: 1.6;
}

.panel textarea {
  min-height: 300px;
  font-size: 1rem;
}

.meta {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 16px;
  margin: 0;
}

.meta dt {
  color: var(--muted);
  font-weight: 700;
}

.meta dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.copy-list {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr) max-content;
  gap: 8px 12px;
  align-items: center;
}

.copy-list .label {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.9rem;
}

.copy-list .value {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.copy-list .value.empty {
  color: var(--red-dark);
  font-weight: 600;
}

button.copied {
  background: var(--ok);
  border-color: var(--ok);
  color: var(--white);
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
}

.actions-row form {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 0;
}

.actions-row select {
  width: auto;
}

.actions-row input[type="text"] {
  width: auto;
  min-width: 200px;
}

.reply {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 14px;
}

.busy {
  opacity: 0.6;
  pointer-events: none;
}

.login {
  max-width: 380px;
  margin: 80px auto;
}
