/* FishCare — mobile-first stylesheet
   Conventions:
   - Primary actions: min 56x56 px, pinned bottom thumb-zone
   - Secondary actions: min 44x44 px
   - Adjacent tap target gap: >= 8 px
   - WCAG AA across the board; AAA for primary Done / Call now
   - No hover-only affordances
*/

:root {
  --bg: #fafaf7;
  --surface: #ffffff;
  --ink: #1a1a1a;
  --ink-soft: #4a4a4a;
  --ink-faint: #7a7a7a;
  --border: #d8d8d2;
  --accent: #1e6b4d;          /* deep green, primary CTA */
  --accent-ink: #ffffff;
  --accent-press: #154d36;
  --warn: #c75a18;            /* maintenance orange */
  --warn-soft: #fde8d6;
  --warn-ink: #4a1f04;
  --red: #b3261e;
  --red-soft: #fbe4e2;
  --red-ink: #4a0a06;
  --orange: #b65f0e;
  --orange-soft: #fdecd4;
  --orange-ink: #4a2304;
  --green: #1b6b3a;
  --green-soft: #d8efde;
  --green-ink: #0c331b;
  --shadow: 0 1px 2px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04);
  --radius: 12px;
  --radius-lg: 16px;
  --gap: 12px;
  --gap-lg: 20px;
  --tap: 56px;
  --tap-min: 44px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 96px;
}

/* On wider screens, give a comfortable reading column but keep mobile feel */
@media (min-width: 720px) {
  main { padding: 24px 24px 120px; }
}

h1 { font-size: 1.6rem; margin: 0 0 8px; line-height: 1.2; }
h2 { font-size: 1.2rem; margin: 24px 0 8px; }
h3 { font-size: 1.05rem; margin: 16px 0 6px; }
p  { margin: 0 0 12px; color: var(--ink-soft); }

a { color: var(--accent); }

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

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

.site-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 12px;
}

.site-header .brand {
  font-weight: 600;
  font-size: 1.05rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: var(--tap-min);
  padding: 8px 4px;
  text-decoration: none;
  color: var(--accent);
  font-weight: 500;
}

.back-link::before { content: "←"; }

.last-updated {
  margin-top: 32px;
  text-align: center;
  color: var(--ink-faint);
  font-size: 0.85rem;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 14px 18px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
}

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

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:active { background: var(--accent-press); }

.btn-warn {
  background: var(--warn-soft);
  color: var(--warn-ink);
  border-color: var(--warn);
}

.btn-neutral {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--border);
}

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

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border-color: var(--border);
}

.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.5;
  pointer-events: none;
}

/* ---------- Home actions ---------- */

.actions {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  margin-top: 16px;
}

.action {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 18px 18px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--ink);
  min-height: var(--tap);
}

.action .title {
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.action .sub {
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.action-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.action-primary .sub { color: rgba(255,255,255,0.9); }

.action-warn {
  background: var(--warn-soft);
  color: var(--warn-ink);
  border-color: var(--warn);
}
.action-warn .sub { color: var(--warn-ink); opacity: 0.85; }

.action-danger {
  background: var(--red-soft);
  color: var(--red-ink);
  border-color: var(--red);
}
.action-danger .sub { color: var(--red-ink); opacity: 0.85; }

.rack-thumb {
  margin: 8px 0 16px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
}

/* ---------- Resume banner ---------- */

.resume-banner {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
  padding: 14px;
  border-radius: var(--radius);
  background: #f3efe2;
  border: 1px solid #d9c98a;
}

.resume-banner .resume-title {
  font-weight: 700;
}

.resume-banner .resume-buttons {
  display: flex;
  gap: 8px;
}

.resume-banner .btn { flex: 1; }

/* ---------- Browse: rack photo with pins ---------- */

.rack-wrap {
  position: relative;
  margin: 0 0 16px;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.rack-wrap img { display: block; width: 100%; }

.hotspot {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  background: rgba(30, 107, 77, 0.95);
  color: #fff;
  font-weight: 700;
  border: 3px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
  text-decoration: none;
  font-size: 1.1rem;
  /* center on the hotspot rectangle's centre */
  transform: translate(-50%, -50%);
}

.hotspot:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.tank-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.tank-list li a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--ink);
  min-height: var(--tap);
}

.tank-list .num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}

.tank-list .name { font-weight: 600; }
.tank-list .desc { color: var(--ink-soft); font-size: 0.92rem; display: block; }

/* ---------- Reference (tank.html) ---------- */

.tank-photo {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  border: 1px solid var(--border);
  margin: 0 0 12px;
}

.tank-photo img { width: 100%; display: block; }

.plant-pin {
  position: absolute;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translate(-50%, -50%);
  background: transparent;
  border: 0;
  cursor: pointer;
}

.plant-pin .dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(30, 107, 77, 0.95);
  border: 3px solid #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.5);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.plant-popover {
  position: absolute;
  z-index: 10;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 12px;
  font-size: 0.95rem;
  max-width: 220px;
  transform: translate(-50%, 8px);
}

.plant-popover .sci {
  display: block;
  color: var(--ink-faint);
  font-style: italic;
  font-size: 0.85rem;
  margin-top: 2px;
}

.toggle {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.toggle button.toggle-head {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 14px 16px;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
  min-height: var(--tap);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.toggle .chev {
  transition: transform 200ms ease;
  color: var(--ink-faint);
}

.toggle[open] .chev,
.toggle.open .chev { transform: rotate(180deg); }

.toggle .toggle-body {
  display: none;
  padding: 0 16px 16px;
}

.toggle.open .toggle-body { display: block; }

.fish-list, .plant-legend {
  list-style: none;
  padding: 0;
  margin: 0;
}

.fish-list li, .plant-legend li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.fish-list li:last-child, .plant-legend li:last-child { border-bottom: 0; }

.plant-legend .legend-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.healthy-section h4 {
  margin: 12px 0 4px;
  font-size: 1rem;
}
.healthy-section ul {
  margin: 0 0 12px 18px;
  padding: 0;
}
.healthy-section .normal-label { color: var(--green); }
.healthy-section .contact-label { color: var(--warn); }

/* ---------- Visit (visit.html) ---------- */

.visit-banner {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #eceae0;
  border-bottom: 1px solid var(--border);
}

.visit-banner.maintenance {
  background: var(--warn-soft);
  border-bottom-color: var(--warn);
  color: var(--warn-ink);
  font-weight: 600;
}

.visit-banner .visit-icon {
  font-size: 1.1rem;
}

.visit-banner button.breadcrumb {
  appearance: none;
  background: transparent;
  border: 0;
  font: inherit;
  color: inherit;
  font-weight: 700;
  min-height: var(--tap-min);
  padding: 6px 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.breadcrumb-list {
  display: none;
  list-style: none;
  margin: 0;
  padding: 8px 12px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.breadcrumb-list.open { display: block; }

.breadcrumb-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--tap-min);
  padding: 6px 4px;
  border-bottom: 1px solid var(--border);
}
.breadcrumb-list li:last-child { border-bottom: 0; }

.breadcrumb-list .status {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.breadcrumb-list .status.done { background: var(--green-soft); color: var(--green-ink); }
.breadcrumb-list .status.current { background: var(--accent); color: #fff; }
.breadcrumb-list .status.upcoming { background: #eee; color: var(--ink-faint); }

.breadcrumb-list a {
  text-decoration: none;
  color: var(--ink);
  font-weight: 500;
  flex: 1;
  min-height: var(--tap-min);
  display: inline-flex;
  align-items: center;
}

.breadcrumb-list .upcoming-row {
  color: var(--ink-faint);
}

.visit-content {
  padding-top: 12px;
}

.visit-content h1 {
  margin-bottom: 6px;
}

.visit-thumb {
  width: 96px;
  height: 96px;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  flex-shrink: 0;
}
.visit-thumb img { width: 100%; height: 100%; object-fit: cover; }

.tank-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.feed-photo, .water-photo {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  margin: 12px 0;
}

.feed-photo img, .water-photo img { width: 100%; display: block; }

.feed-summary {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 8px 0;
}

.fert-line {
  color: var(--ink-soft);
  font-style: italic;
  margin: 4px 0 12px;
}

.food-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 8px 0 16px;
}

.food-thumbs button {
  appearance: none;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  cursor: pointer;
  min-width: var(--tap-min);
  min-height: var(--tap-min);
}

.food-thumbs img {
  width: 70px;
  height: 70px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}

.food-thumbs .label {
  display: block;
  font-size: 0.8rem;
  text-align: center;
  margin-top: 2px;
  color: var(--ink-soft);
}

.water-steps {
  margin: 12px 0 16px 22px;
  padding: 0;
}

.water-steps li {
  margin-bottom: 8px;
}

/* Sticky bottom action area — primary action in thumb zone */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  gap: 8px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, rgba(250,250,247,0.0));
  z-index: 20;
}

.bottom-bar .btn { flex: 1; }
/* Keep Done the dominant thumb-zone target; Back is the smaller secondary. */
.bottom-bar .btn-back { flex: 0 0 36%; }

/* Transition during Done press */
.visit-transitioning {
  opacity: 0.35;
  transition: opacity 380ms ease;
}

/* Completion screen */
.completion {
  text-align: center;
  padding: 48px 16px;
}
.completion .emoji {
  font-size: 3rem;
  margin-bottom: 12px;
}
.completion h1 { font-size: 1.5rem; }
.completion .btn {
  display: flex;
  width: 100%;
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
}

/* ---------- Emergency triage ---------- */

.triage-section {
  border-radius: var(--radius);
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid transparent;
}

.triage-section h2 {
  margin: 0 0 8px;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.triage-section.red    { background: var(--red-soft);    color: var(--red-ink);    border-color: var(--red); }
.triage-section.orange { background: var(--orange-soft); color: var(--orange-ink); border-color: var(--orange); }
.triage-section.green  { background: var(--green-soft);  color: var(--green-ink);  border-color: var(--green); }

.triage-list { list-style: none; padding: 0; margin: 0; }

.triage-list li {
  padding: 10px 0;
  border-top: 1px solid rgba(0,0,0,0.08);
}
.triage-list li:first-child { border-top: 0; }

.triage-list .symptom { font-weight: 700; display: block; margin-bottom: 2px; }
.triage-list .action  { color: inherit; opacity: 0.92; font-size: 0.95rem; }

.supplies-section {
  margin-top: 24px;
}

.supplies-section h3 {
  margin: 16px 0 8px;
}

.supplies-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap);
}

@media (min-width: 540px) {
  .supplies-grid { grid-template-columns: 1fr 1fr; }
}

.supply-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.supply-card img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  background: #eee;
}

.supply-card .body {
  padding: 10px 12px;
}

.supply-card .label { font-weight: 700; }
.supply-card .desc  { color: var(--ink-soft); font-size: 0.92rem; margin-top: 2px; }

/* ---------- Onboarding overlay ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}

@media (min-width: 540px) {
  .overlay { align-items: center; }
}

.overlay .panel {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 12px 32px rgba(0,0,0,0.3);
}

.overlay h2 { margin-top: 0; }

.overlay ul { padding-left: 20px; margin: 8px 0 16px; }

.overlay .btn { width: 100%; }

/* ---------- Lightbox ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
}

.lightbox .close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: #fff;
  border: 0;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 1.4rem;
  cursor: pointer;
}

/* ---------- Utility ---------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.hidden { display: none !important; }

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  .visit-transitioning,
  .toggle .chev { transition: none !important; }
}
