/* Juan Lucas — mobile-first, dyslexia-friendly design.
   Overview first, complexity behind a tap, never everything at once. */

:root {
  --bg: #fbf7f2;
  --surface: #ffffff;
  --text: #2b2622;
  --text-muted: #6f665d;
  --accent: #e08a3c;
  --accent-strong: #c96f22;
  --accent-contrast: #ffffff;
  --danger: #c94f3c;
  --danger-bg: #fbe9e5;
  --info: #3c7ae0;
  --info-bg: #e7eefc;
  --warn: #b8892b;
  --warn-bg: #faf0dd;
  --border: #e9e0d5;
  --shadow: 0 6px 18px rgba(60, 45, 20, 0.08);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --nav-height: 76px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1a17;
    --surface: #262320;
    --text: #f1ece4;
    --text-muted: #b3a99c;
    --accent: #e79a52;
    --accent-strong: #f0ac6c;
    --accent-contrast: #1c1a17;
    --danger: #e28173;
    --danger-bg: #3a231f;
    --info: #7fa8f2;
    --info-bg: #1f2b3f;
    --warn: #e0b767;
    --warn-bg: #3a2f1a;
    --border: #38332c;
    --shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  }
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.65;
  letter-spacing: 0.01em;
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
}

a {
  color: inherit;
}

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

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

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px 12px;
}

.page-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 0 0 12px;
  letter-spacing: 0.01em;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.page-header .page-title {
  margin: 0;
}

/* ---- language toggle ---- */

.lang-toggle {
  display: inline-block;
  padding: 10px 14px;
  min-height: 48px;
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 0.95rem;
  color: var(--text-muted);
  box-shadow: var(--shadow);
}

/* ---- feed of cards ---- */

.feed {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.card {
  display: block;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--border);
}

.entry-card {
  display: flex;
  align-items: stretch;
  min-height: 84px;
}

.entry-card:active {
  transform: scale(0.99);
}

.entry-card-photo {
  width: 100%;
  height: 220px;
  object-fit: cover;
  background: var(--info-bg);
}

.entry-card-photo.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  background: linear-gradient(135deg, var(--info-bg), var(--warn-bg));
}

.entry-card-body {
  flex: 1;
  min-width: 0; /* lets long words wrap instead of stretching the card */
  padding: 11px 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.entry-card-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 1px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.entry-card-lead {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---- badges ---- */

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

.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.badge-info {
  background: var(--info-bg);
  color: var(--info);
}

.badge-warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.badge-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  align-self: center;
}

/* ---- empty state ---- */

.empty-state {
  margin-top: 40px;
  padding: 48px 24px;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
}

.empty-icon {
  font-size: 3.5rem;
  margin-bottom: 12px;
}

.empty-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0 0 8px;
}

.empty-hint {
  color: var(--text-muted);
  margin: 0;
}

/* ---- entry detail ---- */

.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 8px;
}

.entry-photos {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 -16px 16px;
}

.entry-photo {
  width: 100%;
  max-height: 480px;
  object-fit: cover;
}

.entry-photo-placeholder {
  margin: 0 0 16px;
  height: 220px;
  border-radius: var(--radius-lg);
  font-size: 4rem;
}

.entry-detail {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 20px;
}

.entry-date {
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent-strong);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 10px;
}

.entry-text {
  font-size: 1.2rem;
  line-height: 1.75;
  white-space: pre-wrap;
  margin: 0 0 20px;
}

.entry-author {
  color: var(--text-muted);
  font-size: 1rem;
  margin: 0 0 20px;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  border: none;
  font-size: 1.05rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  letter-spacing: 0.01em;
}

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

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-text-danger {
  background: transparent;
  color: var(--danger);
  border: none;
  font-weight: 600;
}

.btn-large {
  width: 100%;
  padding: 16px 20px;
  font-size: 1.15rem;
}

.btn-small {
  min-height: 40px;
  padding: 8px 14px;
  font-size: 0.9rem;
}

.btn:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

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

.field {
  display: block;
  margin-bottom: 18px;
}

.field-label {
  display: block;
  font-weight: 700;
  margin-bottom: 8px;
  font-size: 1.05rem;
}

.field-input,
.field-textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font-size: 1.05rem;
  line-height: 1.6;
}

.field-textarea {
  resize: vertical;
}

.entry-form {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 20px;
}

.existing-photos {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 18px;
}

.existing-photo {
  width: 130px;
}

.existing-photo img {
  width: 130px;
  height: 130px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.danger-zone {
  margin: 28px 0 12px;
  text-align: center;
}

.error {
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-weight: 600;
  margin-bottom: 16px;
}

/* ---- you / prefs ---- */

.you-name {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0 0 24px;
}

.lang-form {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 24px;
}

.lang-choice-group {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 20px;
}

.lang-choice {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 56px;
  padding: 14px 18px;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
}

.lang-choice input {
  width: 22px;
  height: 22px;
}

.lang-choice-label {
  font-size: 1.15rem;
  font-weight: 600;
}

.lang-choice-selected {
  border-color: var(--accent);
  background: var(--warn-bg);
}

.signout-form {
  text-align: center;
}

/* ---- centred pages (login, enrol, error) ---- */

.page-centred {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 90vh;
  padding: 24px 16px;
}

.centred-card {
  width: 100%;
  max-width: 420px;
  text-align: center;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 36px 24px;
}

.centred-icon {
  font-size: 3.5rem;
  margin-bottom: 16px;
}

.centred-hint {
  color: var(--text-muted);
  margin: 0 0 24px;
  font-size: 1.05rem;
}

/* ---- bottom navigation ---- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06);
  padding-bottom: var(--safe-bottom);
  z-index: 10;
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: var(--nav-height);
  text-decoration: none;
  color: var(--text-muted);
}

.tab-icon {
  font-size: 1.6rem;
}

.tab-label {
  font-size: 0.85rem;
  font-weight: 600;
}

.tab:active {
  color: var(--accent-strong);
}

@media (min-width: 700px) {
  .page {
    padding-top: 32px;
  }

  .entry-card-photo {
    flex-basis: 110px;
    width: 110px;
  }

  .entry-card {
    min-height: 104px;
  }
}

/* Titles: the thing you scan. Bigger and heavier than the lead under it. */
.entry-card-title {
  margin: 0 0 2px;
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.entry-title {
  margin: 0.2rem 0 0.9rem;
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--text);
}

/* Each language gets its own visible block on the edit screen, so the title
   and the story it belongs to read as one thing rather than four fields. */
.lang-block {
  margin: 0 0 1.4rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.lang-block > legend {
  padding: 0 0.5rem;
  font-weight: 700;
}

/* Badges on a card are a footnote, not a headline: the reader needs to know
   a translation is missing, not to be stopped by it. */
.entry-card-body .badge {
  margin-top: 5px;
  align-self: flex-start;
  font-size: 0.7rem;
  padding: 2px 7px;
}

/* Photos waiting to be uploaded. Seeing them before saving matters more here
   than anywhere else: you cannot tell one blurry thumbnail from another by
   filename, and the file input shows only a count. */
.field-hint {
  display: block;
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

#photoDrop.dragging {
  outline: 3px dashed var(--accent);
  outline-offset: 4px;
  border-radius: var(--radius-lg);
}

.pending-photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
  margin: 0 0 1.4rem;
}

.pending-photo {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pending-photo img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--border);
}
