/*
 * Voice journal pages. Built from the Hund i bevegelse design system:
 * every value is a token from tokens.css, and buttons, fields, notes and the
 * header come from components.css.
 */

.journal-main {
  padding-block: var(--spacing-40) var(--layout-section-y);
}

/* One readable column on desktop; below that, .container fills the screen */
.journal-container {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-24);
}

@media (min-width: 1024px) {
  .journal-container {
    max-width: calc(var(--layout-measure) + 2 * var(--layout-margin));
  }
}

/* Card: same look as the contact form card */
.journal-card {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-20);
  padding: var(--spacing-32);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  background: var(--color-bg-surface);
}

.journal-card > .button {
  align-self: flex-start;
}

.journal-card__title {
  font: var(--text-heading-h3);
}

.journal-card__intro,
.journal-meta {
  font: var(--text-body-small);
  color: var(--color-text-muted);
}

.journal-error {
  font: var(--text-body-small);
  color: var(--color-text-error);
}

.journal-error:empty {
  display: none;
}

/* File picker: the native input is hidden and its label looks like an
   outline button, so the picker matches the rest of the site */
.file-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--spacing-12) var(--spacing-16);
}

.file-picker__input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.file-picker__input:focus-visible + .button {
  background: var(--color-bg-subtle-hover);
  box-shadow: inset 0 0 0 1.5px var(--color-border-strong), var(--focus-ring);
}

.file-picker__input:disabled + .button,
.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.file-picker__name {
  min-width: 0;
  font: var(--text-body-small);
  color: var(--color-text-muted);
  overflow-wrap: anywhere;
}

.upload-progress {
  width: 100%;
  height: var(--spacing-8);
  border: 0;
  border-radius: var(--radius-full);
  background: var(--color-bg-section);
  overflow: hidden;
  appearance: none;
}

.upload-progress::-webkit-progress-bar {
  background: var(--color-bg-section);
}

.upload-progress::-webkit-progress-value {
  border-radius: var(--radius-full);
  background: var(--color-bg-inverse);
  transition: width var(--duration-base) var(--ease-standard);
}

.upload-progress::-moz-progress-bar {
  border-radius: var(--radius-full);
  background: var(--color-bg-inverse);
}

/* Entry list */
.entry-list {
  padding: 0;
  list-style: none;
}

.entry-list > li + li {
  border-top: 1px solid var(--color-border-subtle);
}

.entry-list__empty {
  font: var(--text-body-medium);
  color: var(--color-text-muted);
}

.entry-row {
  display: flex;
  align-items: center;
  gap: var(--spacing-16);
  min-height: var(--layout-tap-target);
  padding-block: var(--spacing-16);
  color: var(--color-text-primary);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-standard);
}

.entry-row:hover {
  color: var(--color-text-accent-hover);
  text-decoration: none;
}

.entry-row:active {
  color: var(--color-text-accent-active);
}

.entry-row:focus-visible {
  outline: 2px solid var(--color-border-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.entry-row__text {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--spacing-4);
  min-width: 0;
}

.entry-row__title {
  font: var(--text-label-medium);
}

.entry-row__status {
  font: var(--text-caption);
  color: var(--color-text-muted);
}

.entry-row .icon {
  color: var(--color-icon-accent);
}

/* Progress steps on the detail page */
.steps {
  display: flex;
  gap: var(--spacing-4);
  padding: 0;
  list-style: none;
}

.steps__step {
  flex: 1;
  padding-top: var(--spacing-8);
  border-top: var(--spacing-4) solid var(--color-border-subtle);
  font: var(--text-caption);
  color: var(--color-text-muted);
  text-align: center;
}

.steps__step--done {
  border-color: var(--color-bg-inverse);
  color: var(--color-text-primary);
}

.steps__step--active {
  border-color: var(--color-bg-inverse);
  color: var(--color-text-primary);
  font: var(--text-label-small);
  animation: journal-pulse calc(2 * var(--duration-deliberate)) var(--ease-standard) infinite alternate;
}

.steps__step--failed {
  border-color: var(--color-border-error);
  color: var(--color-text-error);
  font: var(--text-label-small);
}

@keyframes journal-pulse {
  to { border-color: var(--color-border-subtle); }
}

@media (prefers-reduced-motion: reduce) {
  .steps__step--active { animation: none; }
}

.journal-status {
  font: var(--text-body-medium);
}

.journal-card details summary {
  min-height: var(--layout-tap-target);
  font: var(--text-label-small);
  color: var(--color-text-muted);
  cursor: pointer;
}

.journal-card audio {
  width: 100%;
}

/* Drafted fields */
.journal-section + .journal-section {
  padding-top: var(--spacing-20);
  border-top: 1px solid var(--color-border-subtle);
}

.journal-section h2 {
  margin-bottom: var(--spacing-12);
  font: var(--text-heading-h4);
}

.journal-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  align-items: baseline;
  gap: var(--spacing-12) var(--spacing-24);
  margin: 0;
}

.journal-fields dt {
  font: var(--text-label-small);
  color: var(--color-text-muted);
}

.journal-fields dd {
  margin: 0;
  font: var(--text-body-medium);
}

.transcript {
  font: var(--text-body-medium);
  white-space: pre-wrap;
}

/* Login */
.journal-login {
  align-self: center;
  width: 100%;
  max-width: calc(var(--layout-content-max) / 2);
}

@media (max-width: 767px) {
  .journal-main {
    padding-block: var(--spacing-24) var(--layout-section-y);
  }

  .journal-card {
    padding: var(--spacing-24);
  }

  .journal-fields {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--spacing-4);
  }

  .journal-fields dd + dt {
    margin-top: var(--spacing-12);
  }

  .journal-login {
    max-width: none;
  }
}

.site-header__actions .button {
  white-space: nowrap;
}

/* Header: the logout form has the site-nav class, so it hides with the nav
   on mobile, where the menu dialog has its own logout button */
.mobile-menu__bottom form {
  display: flex;
}

.mobile-menu__bottom form .button {
  width: 100%;
}

.journal-signed-in {
  font: var(--text-body-small);
  color: var(--color-text-inverse);
}

.journal-messages {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-12);
}

/*
 * Form controls the Figma design system doesn't have yet (select, checkbox,
 * checkbox group). Built from the Input Field tokens; reported to the designer.
 */
.field__select {
  position: relative;
}

.field__select select {
  padding-right: var(--spacing-48);
  appearance: none;
  cursor: pointer;
}

/* Chevron drawn with the field border, so no new icon is needed */
.field__select::after {
  content: "";
  position: absolute;
  top: 50%;
  right: var(--spacing-20);
  width: var(--spacing-8);
  height: var(--spacing-8);
  border-right: 1.5px solid var(--color-icon-primary);
  border-bottom: 1.5px solid var(--color-icon-primary);
  transform: translateY(-75%) rotate(45deg);
  pointer-events: none;
}

input[type="datetime-local"].field__control {
  padding-block: var(--spacing-8);
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-12);
  min-height: var(--layout-tap-target);
  font: var(--text-body-medium);
  color: var(--color-text-primary);
  cursor: pointer;
}

.checkbox input {
  flex: none;
  width: var(--spacing-20);
  height: var(--spacing-20);
  margin: 0;
  accent-color: var(--color-bg-inverse);
  cursor: pointer;
}

.checkbox input:focus-visible {
  outline: 2px solid var(--color-border-focus);
  outline-offset: 2px;
}

.field-choices {
  margin: 0;
  padding: 0;
  border: 0;
}

.field-choices__list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0 var(--spacing-16);
}

@media (min-width: 768px) {
  .field-choices__list {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Edit form */
.journal-form {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-24);
}

.journal-form__section {
  margin: 0;
  padding: 0;
  border: 0;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-20);
}

.journal-form__section legend {
  padding: 0;
}

.journal-form__section h2 {
  font: var(--text-heading-h4);
}

.journal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-12);
}

.journal-actions form {
  display: flex;
}

.journal-transcript summary {
  min-height: var(--layout-tap-target);
  display: flex;
  align-items: center;
  font: var(--text-label-medium);
  cursor: pointer;
}

.journal-transcript .transcript {
  margin-top: var(--spacing-12);
}

/* Page title with an action next to it */
.journal-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-16);
}

.journal-search {
  display: flex;
  gap: var(--spacing-12);
}

.journal-search .field__control {
  flex: 1;
  min-width: 0;
}

/*
 * Body map (kroppskart). The drawing is the journal's own schematic artwork
 * (journal/bodymap.py); colours are tokens.
 */
.bodymap__defs {
  position: absolute;
  width: 0;
  height: 0;
}

.bodymap__tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-8);
}

.bodymap__tab[aria-selected="true"] {
  background: var(--color-bg-inverse);
  color: var(--color-text-inverse);
}

.bodymap__view-title,
.bodymap__subtitle {
  font: var(--text-heading-h4);
}

.bodymap__view {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-8);
}

.bodymap__view[hidden] {
  display: none;
}

.bodymap__svg {
  width: 100%;
  max-height: 60vh;
  border-radius: var(--radius-md);
  background: var(--color-bg-page);
}

.bodymap__body {
  fill: var(--color-bg-page);
  stroke: var(--color-border-strong);
  stroke-width: 2;
  stroke-linejoin: round;
}

.bodymap__far {
  fill: var(--color-bg-surface-active);
  stroke: var(--color-border-field);
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.bodymap__landmarks {
  fill: none;
  stroke: var(--color-border-field);
  stroke-width: 1.2;
  stroke-linecap: round;
  pointer-events: none;
}

.bodymap__zone {
  fill: transparent;
  stroke: none;
}

.bodymap__zone.is-marked {
  fill: var(--color-bg-section);
}

.bodymap__zone[data-zone] {
  cursor: pointer;
}

.bodymap__zone[data-zone]:hover,
.bodymap__zone.is-selected {
  fill: var(--color-bg-surface-active);
  stroke: var(--color-border-accent);
  stroke-width: 1.5;
}

.bodymap__zone[data-zone]:focus-visible {
  outline: none;
  fill: var(--color-bg-surface-active);
  stroke: var(--color-border-focus);
  stroke-width: 2.5;
}

.bodymap__mark {
  pointer-events: none;
}

.bodymap__mark--pain,
.bodymap__mark--swelling { color: var(--color-text-error); }
.bodymap__mark--tension { color: var(--color-icon-accent); }
.bodymap__mark--reduced_rom,
.bodymap__mark--treated { color: var(--color-icon-primary); }
.bodymap__mark--other { color: var(--color-text-muted); }

.bodymap__legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-8) var(--spacing-16);
  padding: 0;
  list-style: none;
  font: var(--text-body-small);
}

.bodymap__legend li,
.bodymap__item {
  display: flex;
  align-items: center;
  gap: var(--spacing-8);
}

.bodymap__list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-8);
  padding: 0;
  list-style: none;
}

.bodymap__item {
  justify-content: space-between;
  min-height: var(--layout-tap-target);
  font: var(--text-body-medium);
}

.bodymap__item-text {
  flex: 1;
}

.bodymap__ai {
  font: var(--text-caption);
  color: var(--color-text-muted);
}

/* Attachments (vedlegg) */
.attachments__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--spacing-16);
  padding: 0;
  list-style: none;
}

@media (min-width: 768px) {
  .attachments__grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.attachments__item {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-8);
  padding: var(--spacing-12);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  background: var(--color-bg-page);
}

.attachments__item form {
  display: flex;
}

.attachments__media {
  display: block;
  width: 100%;
  border-radius: var(--radius-sm);
  background: var(--color-bg-surface-active);
}

.attachments__media img {
  display: block;
  width: 100%;
  border-radius: var(--radius-sm);
}

.attachments__meta {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-4);
  min-width: 0;
  overflow-wrap: anywhere;
}

.attachments__upload {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-12);
}

/* Payments */
.payments__table-wrap {
  overflow-x: auto;
}

.payments__table {
  width: 100%;
  border-collapse: collapse;
  font: var(--text-body-small);
}

.payments__table th,
.payments__table td {
  padding: var(--spacing-8);
  border-bottom: 1px solid var(--color-border-subtle);
  text-align: left;
  white-space: nowrap;
}

.payments__table thead th {
  font: var(--text-label-small);
  color: var(--color-text-muted);
}

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

.payments__table tfoot th {
  font: var(--text-label-small);
}

.price-presets ul {
  padding: 0;
  list-style: none;
}

/* Phones: each payment as a small block instead of a wide table row */
@media (max-width: 767px) {
  .payments__table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .payments__table tbody tr {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "client amount"
      "date method"
      "dog edit";
    gap: var(--spacing-4) var(--spacing-12);
    padding-block: var(--spacing-12);
    border-bottom: 1px solid var(--color-border-subtle);
  }

  .payments__table tbody td {
    padding: 0;
    border: 0;
    white-space: normal;
  }

  .payments__client { grid-area: client; }
  .payments__amount { grid-area: amount; }
  .payments__date { grid-area: date; color: var(--color-text-muted); }
  .payments__method { grid-area: method; text-align: right; color: var(--color-text-muted); }
  .payments__dog { grid-area: dog; color: var(--color-text-muted); }
  .payments__edit { grid-area: edit; text-align: right; }

  .payments__table tfoot tr {
    display: flex;
    justify-content: space-between;
  }

  .payments__table tfoot td:empty {
    display: none;
  }
}

/* Klippekort */
.punch-card {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-8);
  padding: var(--spacing-16);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  background: var(--color-bg-page);
}

.punch-card form {
  display: flex;
}

.punch-card__head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--spacing-8);
}

.punch-card__title {
  font: var(--text-label-medium);
}

.punch-card__count {
  font: var(--text-label-small);
}

.punch-card--used-up .punch-card__count {
  color: var(--color-text-muted);
}

.punch-card__clips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-4);
}

.punch-card__clip {
  width: var(--spacing-16);
  height: var(--spacing-16);
  border: 1.5px solid var(--color-border-strong);
  border-radius: var(--radius-full);
}

.punch-card__clip.is-used {
  background: var(--color-bg-inverse);
}

.punch-card__uses {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-4);
  padding: 0;
  list-style: none;
}

.punch-card__uses li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-12);
  min-height: var(--layout-tap-target);
  font: var(--text-body-small);
}
