/* ---------- Composer (message form) ---------- */

.composer__form {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: calc(28 * var(--space));
}

.composer__field {
  position: relative;
  flex: 1;
  min-width: 0;
  padding-top: 16px;
  width: 100%;
}

.composer__input {
  display: block;
  width: 100%;
  padding: 0.875em 0.5625em 0.875em 1em;
  border: 1px solid var(--color-sage);
  border-radius: 0.5em;
  background: transparent;
  color: #1a1a1a;
  font: 500 18px/1.3 var(--font-body);
  letter-spacing: -0.02em;
  resize: none;
}

textarea.composer__input {
  min-height: 76px;
  field-sizing: content;
  max-height: 6lh;
}

.composer__input:focus::placeholder {
  color: transparent;
}

.composer__input::placeholder {
  color: var(--color-sage);
  opacity: 1;
}

.composer__input:focus-visible {
  outline: 2px solid var(--color-sage);
  outline-offset: 2px;
}

.composer__input:disabled {
  opacity: 0.7;
}

.composer__counter {
  position: absolute;
  right: 28px;
  bottom: 8px;
  font-size: 12px;
  color: var(--color-placeholder);
  pointer-events: none;
}

.composer__counter[data-level="warning"] {
  color: var(--color-warning);
}

.composer__counter[data-level="error"] {
  color: var(--color-error);
}

.composer__actions {
  display: flex;
  gap: 12px;
}

.composer__status {
  display: block;
  min-height: 1.4em;
  margin-top: 12px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--color-text-black);
}

.composer__status[data-state="error"] {
  color: var(--color-error);
}

/* Notice while message input is closed from the admin page. */
.composer__closed {
  display: block;
  margin: 12px 0 0;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.4;
  color: var(--color-text-black);
}

.composer__closed[hidden] {
  display: none;
}

/* Grey out the counter too, matching the disabled input and buttons. */
.composer__form.is-closed .composer__counter {
  opacity: 0.6;
}

/* Small spinner after the "printing" status, in the text colour. */
.composer__spinner {
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  margin-left: 0.5em;
  vertical-align: -0.1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: composer-spin 0.8s linear infinite;
}

@keyframes composer-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .composer__spinner {
    animation-duration: 2.4s;
  }
}

/* The test button is a developer tool: hidden unless ?debug is in the URL. */
.composer__actions [data-debug-only] {
  display: none;
}

.is-debug .composer__actions [data-debug-only] {
  display: inline-flex;
}

@media (min-width: 1024px) {
  .composer__form {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: calc(28 * var(--space));
  }

  .composer__field {
    width: 100%;
    padding-top: calc(16 * var(--space));
  }

  .composer__status {
    margin-top: calc(12 * var(--space));
    font-size: max(0.75rem, calc(14 * var(--space)));
  }

  /* Padding, radius and height in em (from 24.196px in Figma) so the field follows its text. */
  .composer__input {
    padding: 0.875em 0.5625em 0.875em 1em;
    border: 1px solid var(--color-sage);
    border-radius: 0.5em;
    background: transparent;
    color: var(--color-green);
    font-size: var(--fs-input);
  }

  .composer__input:focus::placeholder {
    color: transparent;
  }

  .composer__input::placeholder {
    color: var(--color-placeholder);
    opacity: 1;
  }

  textarea.composer__input {
    min-height: 5.125em;
    field-sizing: content;
  }

  .composer__counter {
    right: calc(42 * var(--space));
    bottom: calc(12 * var(--space));
    font-size: max(0.6875rem, calc(14 * var(--space)));
  }
}

/* ---------- Button ---------- */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* Sizes in em (from 23.261px in Figma) so the button follows its label, with the same
     proportions on mobile and desktop. The icon gap is tighter than in Figma. */
  gap: 0.7em;
  height: 2.7273em;
  padding: 0.3636em 1.3636em;
  border: 0;
  border-radius: 1.8182em;
  background: var(--color-green);
  color: var(--color-beige);
  font: 500 19px/1 var(--font-body);
  letter-spacing: -0.02em;
  white-space: nowrap;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:focus-visible {
  outline: 2px solid var(--color-cream);
  outline-offset: 3px;
}

.button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.button__icon {
  width: 0.6364em;
  height: 1.0909em;
}

.button__icon--dark {
  display: none;
}

@media (min-width: 1024px) {
  .button {
    font-size: var(--fs-button);
  }

  .button--primary {
    width: auto;
  }

  .button--primary .button__label {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
  }

  .button__icon--light {
    display: block;
  }

  .button__icon--dark {
    display: none;
  }
}

/* ---------- Sections ---------- */
.section__heading {
  font-family: StendahlsSeasonMix, var(--font-display), sans-serif;
  font-weight: 600;
  font-size: 26px;
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: var(--color-text-black);
  font-synthesis-weight: none;
}

.section--shreds {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section--info {
  display: flex;
  flex-direction: column;
  gap: 34px;
}

.section--info .section__heading, .section--shreds .section__heading {
  font-size: 40px;
}

.section__text {
  margin-left: 73px;
  font-size: 22px;
  line-height: 1.364;
  letter-spacing: -0.02em;
  color: var(--color-text-black);
}

.section__text a {
  color: var(--color-text-black);
}

.section__text a:hover, .section__text a:focus {
  color: var(--color-warning);
}

@media (min-width: 1024px) {
  .section--shreds {
    gap: calc(16 * var(--space));
  }

  .section--info {
    gap: calc(34 * var(--space));
  }

  .section--info .section__heading,
  .section--shreds .section__heading {
    font-size: var(--fs-section-heading);
  }

  /* The indent is in em (88px at 22px) so it follows the text. */
  .section__text {
    margin-left: 4em;
    font-size: var(--fs-section-text);
  }
}

@media (max-width: 767px) {
  .section__text {
    margin-left: 0;
  }
}

/* Heading row of the shreds section: the title, and on desktop the scroll buttons. */
.section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

/* ---------- Shred list scroll buttons (desktop only) ---------- */
.shred-nav {
  display: none;
  gap: 8px;
  /* Reset the browser's fieldset styles. */
  min-inline-size: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

@media (min-width: 1024px) {
  .shred-nav {
    display: flex;
  }
}

.shred-nav__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1.5px solid var(--color-green);
  border-radius: 50%;
  background: none;
  color: var(--color-green);
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease, opacity 150ms ease;
}

.shred-nav__button:hover:not(:disabled) {
  background-color: var(--color-green);
  color: var(--color-beige);
}

.shred-nav__button:focus-visible {
  outline: 2px solid var(--color-sage);
  outline-offset: 2px;
}

.shred-nav__button:disabled {
  opacity: 0.3;
  cursor: default;
}

/* ---------- Shred cards (message queue) ---------- */
.shred-list {
  display: flex;
  gap: 11px;
  /* The scroll container clips its contents, so leave room for the card shadows
     and pull the list back out with negative margins to keep the layout in place. */
  margin: -6px -37px -6px -8px;
  padding: 6px 37px 10px 8px;
  scroll-padding-inline-start: 8px;
  list-style: none;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  /* Scrollable (swipe, trackpad, the desktop buttons), but without a visible scrollbar. */
  scrollbar-width: none;
}

.shred-list::-webkit-scrollbar {
  display: none;
}

.shred-list:empty::before {
  content: attr(data-empty);
  color: var(--color-text-black);
  font-size: 16px;
}

/* A card is the sheet of paper plus, once printed, the share button below it. */
.shred-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex: 0 0 143px;
  scroll-snap-align: start;
}

.shred-card__paper {
  position: relative;
  width: 100%;
  /* A4 proportions (210 × 297 mm). */
  height: calc(143px * 297 / 210);
  overflow: hidden;
  /* No visible frame, but keep the border so the hover and printing states can colour it. */
  border: 1.226px solid transparent;
  border-radius: 4px;
  /*
    A soft shadow so the card reads as paper (the same values as --shadow-paper). It's a
    drop-shadow filter, not box-shadow, so it follows the shredded strips instead of the box.
  */
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.06)) drop-shadow(0 2px 6px rgba(0, 0, 0, 0.1));
}

/*
  The paper, cut into strips: white areas of the mask keep the sheet, transparent ones let the
  page show through. The mask is stretched to the A4 card. The filter runs before the mask and
  pushes the text under each gap into the strips beside it, so letters are split, not cut away.
  The map's shifts are in screen pixels for this card size; rebuild it (tools/shred-assets.py)
  if the card size changes.
*/
.shred-card__sheet {
  position: absolute;
  inset: 0;
  /* Centre the message both ways; the padding keeps it clear of the paper edges. */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: white;
  filter: url("#shred-offset");
  -webkit-mask: url("/images/shred-mask.png") center / 100% 100% no-repeat;
  mask: url("/images/shred-mask.png") center / 100% 100% no-repeat;
}

.shred-card__paper.flagged .shred-card__sheet {
  background-color: white;
  /* The image is a whole A4 sheet, so it fills the paper. */
  background-image: url("/images/flagged.jpg");
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
}

.shred-card__text {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 10;
  -webkit-box-orient: vertical;
  color: #000;
  font-family: StendahlsSeasonMix, var(--font-display), sans-serif;
  font-weight: 600;
  font-size: 12px;
  line-height: 1.35;
  text-align: center;
  word-break: break-word;
}

.shred-card__timestamp {
  position: absolute;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 7;
  -webkit-box-orient: vertical;
  color: var(--color-dark-tint);
  font-size: 11px;
  line-height: 1.35;
  word-break: break-word;
  top: 0;
  right: 0;
}

/* Printed cards: the whole sheet links to the clip. */
.shred-card__link {
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
}

.shred-card__link:focus-visible {
  outline: 2px solid var(--color-sage);
  outline-offset: -4px;
}

.shred-card.is-printed .shred-card__paper {
  cursor: pointer;
  transition: border-color 150ms ease;
}

.shred-card.is-printed .shred-card__paper:hover,
.shred-card.is-printed .shred-card__paper:focus-within {
  border-color: var(--color-sage);
}

/* Still printing, so not shredded yet: a whole sheet. */
.shred-card.is-printing .shred-card__sheet {
  background-image: url("/images/printing.svg");
  background-position: center top 35%;
  background-repeat: no-repeat;
  -webkit-mask: none;
  mask: none;
}

/*
  Download/Save button under the sheet: a black icon and label, no background
*/

/* Share button under the sheet: a black icon and label, no background. */
.shred-card__share {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
  border: 0;
  background: none;
  color: #000;
  font: 500 13px/1.2 var(--font-body);
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 150ms ease;
}

.shred-card__share[hidden] {
  display: none;
}

.shred-card__share:hover {
  opacity: 0.7;
}

.shred-card__share:focus-visible {
  outline: 2px solid var(--color-sage);
  outline-offset: 2px;
  border-radius: 2px;
}

.shred-card__share svg {
  flex: none;
}

/* While "Share URL copied" is shown, the button is text only. */
.shred-card__share.is-feedback svg {
  display: none;
}

@media (min-width: 1024px) {
  .shred-list {
    margin-right: 0;
    padding-right: 0;
  }
}

.load-status {
  font-size: 13px;
  color: var(--color-sage);
}

/* ---------- Printer status (temporary placement below the form) ---------- */
.printer-status {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: baseline;
  column-gap: 10px;
  row-gap: 2px;
  margin-top: 12px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--color-text-light);
}

.printer-status__indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-placeholder);
  transform: translateY(-1px);
}

.printer-status[data-state="online"] .printer-status__indicator {
  background: #4caf50;
}

.printer-status[data-state="offline"] .printer-status__indicator {
  background: var(--color-error);
}

.printer-status__time {
  grid-column: 2;
  font-size: 12px;
  color: var(--color-sage);
}

.printer-status__time:empty {
  display: none;
}

/* On mobile the composer floats over the video, so give the status a backdrop. */
@media (max-width: 1023px) {
  .printer-status {
    padding: 8px 12px;
    border-radius: 8px;
    background: rgba(9, 63, 31, 0.88);
  }
}

@media (min-width: 1024px) {
  .printer-status {
    font-size: max(0.75rem, calc(16 * var(--space)));
  }

  .printer-status__time {
    font-size: max(0.6875rem, calc(12 * var(--space)));
  }
}

/*
  Desktop: the small text and the scroll buttons follow the spacing too, so the page scales as
  a whole (see --space in base.css). The small text never goes below 11–12px.
*/
@media (min-width: 1024px) {
  .shred-list:empty::before {
    font-size: max(0.75rem, calc(16 * var(--space)));
  }

  .load-status {
    font-size: max(0.6875rem, calc(13 * var(--space)));
  }

  .shred-nav__button {
    width: calc(40 * var(--space));
    height: calc(40 * var(--space));
  }

  .shred-nav__button svg {
    width: calc(16 * var(--space));
    height: calc(16 * var(--space));
  }
}
