/* The colours, sizes and card layout of coolture-frontend (_tokens.scss, post-component.scss). */
:root {
  --color-accent: #2563eb;
  --color-accent-hover: #1d4ed8;
  --color-accent-light: #eff6ff;
  --color-surface: #ffffff;
  --color-surface-alt: #f8f9fa;
  --color-text: #111111;
  --color-text-secondary: #6b7280;
  --color-border: #e5e7eb;
  --color-border-light: #f3f4f6;
  --color-warning: #f59e0b;
  --color-success: #10b981;
  --color-background: #fafafa;
  --text-meta: 0.8125rem;
  --text-body: 0.9375rem;
  --text-title: 1.0625rem;
  --radius-md: 10px;
  --radius-lg: 16px;
  --top-height: 48px;
  --actions-height: 132px;
  --column: 560px;
}

* {
  box-sizing: border-box;
}

/* Several elements below set their own display, which would otherwise beat the attribute. */
[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    Roboto,
    'Helvetica Neue',
    Arial,
    'Noto Sans',
    sans-serif;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-background);
}

button,
select,
textarea {
  font: inherit;
  color: inherit;
}

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

.icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.top {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--top-height);
  padding: 0 16px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border-light);
}

.top__brand {
  font-weight: 800;
  letter-spacing: 0.04em;
}

.top__count {
  font-size: var(--text-meta);
  color: var(--color-text-secondary);
  font-variant-numeric: tabular-nums;
}

.progress {
  position: sticky;
  top: var(--top-height);
  z-index: 2;
  height: 4px;
  background: var(--color-border);
}

.progress__bar {
  height: 100%;
  background: var(--color-accent);
  transition: width 200ms ease;
}

main {
  max-width: var(--column);
  margin: 0 auto;
  padding: 16px 16px 32px;
}

h1 {
  margin: 16px 0 8px;
  font-size: 1.5rem;
  line-height: 1.25;
}

p {
  margin: 0 0 12px;
}

.muted {
  font-size: var(--text-body);
  color: var(--color-text-secondary);
}

.note {
  padding: 12px;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  background: var(--color-surface-alt);
  font-size: var(--text-meta);
  color: var(--color-text-secondary);
}

.btn,
.chip {
  min-height: 44px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  font-size: var(--text-body);
  cursor: pointer;
}

.btn {
  padding: 0 20px;
  font-weight: 600;
}

.btn--primary {
  border-color: var(--color-accent);
  background: var(--color-accent);
  color: #fff;
}

.btn--primary:hover {
  background: var(--color-accent-hover);
}

.btn--wide {
  width: 100%;
  margin-top: 16px;
}

.btn:disabled,
.chip:disabled {
  opacity: 0.45;
  cursor: default;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}

.chip {
  padding: 0 16px;
}

.chip[aria-pressed='true'] {
  border-color: var(--color-accent);
  background: var(--color-accent-light);
  color: var(--color-accent-hover);
  font-weight: 600;
}

label {
  display: block;
  margin: 20px 0 6px;
  font-size: var(--text-body);
  font-weight: 600;
}

label small {
  font-weight: 400;
  color: var(--color-text-secondary);
}

select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  /* Under 16px, Safari on iPhone zooms the page when the field gets focus. */
  font-size: 1rem;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

.legend {
  display: grid;
  gap: 12px;
  margin: 16px 0;
  padding: 0;
  list-style: none;
  font-size: var(--text-body);
}

.legend li {
  display: flex;
  gap: 10px;
}

/* Wider than the other screens, as the app's feed is on a phone, and clear of the fixed answer bar. */
.cards {
  margin: -8px -8px 0;
  padding-bottom: calc(var(--actions-height) + env(safe-area-inset-bottom));
}

.post {
  overflow: hidden;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.post__info {
  display: flex;
  flex-wrap: wrap;
  column-gap: 12px;
  padding: 12px 16px 4px;
  font-size: var(--text-meta);
  color: var(--color-text-secondary);
}

.post__info > span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.post__info .icon {
  width: 14px;
  height: 14px;
}

.post__title {
  margin: 0;
  padding: 0 16px 4px;
  font-size: var(--text-title);
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.post__desc {
  position: relative;
  padding: 0 16px 8px;
  font-size: var(--text-body);
  line-height: 1.4;
}

.post__desc-text {
  max-height: 3lh;
  margin: 0;
  overflow: hidden;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.post__desc--open .post__desc-text {
  max-height: none;
}

/* Over the end of the last line, so that showing it never changes the card's height. */
.post__desc-toggle {
  position: absolute;
  right: 16px;
  bottom: 8px;
  padding: 0 0 0 48px;
  border: none;
  background: linear-gradient(to right, transparent, var(--color-surface) 32px);
  font-weight: 600;
  cursor: pointer;
}

.post__desc--open .post__desc-toggle {
  position: static;
  padding: 0;
  background: none;
}

/* The photo is whole over a blurred copy of itself, and never so tall that the text above it leaves the screen. */
.post__frame {
  position: relative;
  max-height: max(200px, calc(100dvh - var(--top-height) - var(--actions-height) - 190px));
  overflow: hidden;
  background: var(--color-border-light) center / cover no-repeat;
  isolation: isolate;
}

.post__frame::before {
  content: '';
  position: absolute;
  inset: -24px;
  z-index: -1;
  background: inherit;
  filter: blur(24px);
}

.post__frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.actions {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 3;
  display: grid;
  gap: 8px;
  padding: 8px max(8px, calc((100% - var(--column)) / 2 + 8px))
    calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
}

.actions__row {
  display: grid;
  gap: 6px;
}

.actions__row--react {
  grid-template-columns: repeat(3, 1fr);
}

.actions__row--nav {
  grid-template-columns: 1fr 2fr;
}

.react {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 56px;
  padding: 4px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.2;
  color: var(--color-text-secondary);
  cursor: pointer;
}

.react[aria-pressed='true'] .icon {
  fill: currentColor;
}

.react--like[aria-pressed='true'] {
  border-color: var(--color-accent);
  background: var(--color-accent-light);
  color: var(--color-accent);
}

.react--interested[aria-pressed='true'] {
  border-color: var(--color-warning);
  background: #fef3c7;
  color: #b45309;
}

.react--takes-part[aria-pressed='true'] {
  border-color: var(--color-success);
  background: #d1fae5;
  color: #047857;
}
