/* Plantão — Diário de cuidado (demo ILPI, estilo Fable 5)
   Mesma família visual de "Um dia na casa": papel quente, argila e sálvia,
   serifa expressiva para os títulos e formulário em blocos numerados. */

:root {
  color-scheme: light;

  --paper: #fbf5ec;
  --cream: #fffdf8;
  --sand: #f3e8d8;
  --ink: #33291f;
  --ink-soft: #7a6c5c;
  --line: rgba(51, 41, 31, 0.12);

  --clay: #c26d4f;
  --clay-deep: #a85539;
  --clay-soft: rgba(194, 109, 79, 0.14);
  --sage: #6f8b78;
  --sage-deep: #43584a;
  --sage-soft: rgba(111, 139, 120, 0.16);
  --night: #2b2119;
  --light: #fdf8f0;

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Figtree", system-ui, sans-serif;

  --size-0: clamp(1rem, 0.95rem + 0.25vw, 1.0625rem);
  --size-2: clamp(1.7rem, 1.3rem + 1.8vw, 2.6rem);
  --size-hero: clamp(2.1rem, 1.4rem + 3.6vw, 3.9rem);

  --radius: 20px;
  --shadow: 0 16px 44px rgba(51, 41, 31, 0.1);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --wrap: min(760px, calc(100% - 2.4rem));
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--size-0);
  line-height: 1.6;
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 85% -80px, var(--sage-soft), transparent 70%),
    radial-gradient(700px 380px at -60px 30%, var(--clay-soft), transparent 65%),
    var(--paper);
  -webkit-font-smoothing: antialiased;
}

h1, h2 {
  font-family: var(--font-display);
  font-weight: 480;
  line-height: 1.08;
  letter-spacing: -0.015em;
  margin: 0;
}

h1 em, h2 em { font-style: italic; color: var(--clay-deep); }

.kicker {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--sage-deep);
  margin: 0 0 0.9rem;
}

.skip-link {
  position: absolute;
  left: -9999px;
  z-index: 300;
  padding: 0.75rem 1.1rem;
  background: var(--night);
  color: var(--light);
  border-radius: 0 0 12px 0;
}
.skip-link:focus { left: 0; top: 0; }

/* ——— Topo ——— */

.top {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.65rem clamp(1rem, 3vw, 1.6rem);
  padding-top: calc(0.65rem + env(safe-area-inset-top, 0px));
  background: color-mix(in srgb, var(--cream) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.top__back {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--ink);
  background: var(--sand);
  transition: transform 0.3s var(--ease), background 0.3s;
}
.top__back:hover { background: var(--clay-soft); transform: translateX(-2px); }
.top__back svg { width: 20px; height: 20px; }

.top__title { display: flex; flex-direction: column; line-height: 1.15; }
.top__title strong { font-family: var(--font-display); font-size: 1.15rem; font-weight: 520; }
.top__title small { color: var(--ink-soft); font-size: 0.76rem; }

.top__shift {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  background: var(--sage-soft);
  color: var(--sage-deep);
  transition: background 0.5s var(--ease), color 0.5s var(--ease);
}
.top__shift.is-night { background: var(--night); color: #e8dcc8; }

/* ——— Hero ——— */

.hero {
  width: var(--wrap);
  margin: 0 auto;
  padding: clamp(2.6rem, 7vw, 4.6rem) 0 clamp(1.6rem, 4vw, 2.4rem);
}

.hero h1 { font-size: var(--size-hero); max-width: 18ch; }

.hero__lead {
  max-width: 58ch;
  color: var(--ink-soft);
  margin: 1.2rem 0 0;
}

.hero__stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-top: 1.6rem;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 110px;
  padding: 0.8rem 1.1rem;
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.stat strong { font-family: var(--font-display); font-size: 1.7rem; font-weight: 520; color: var(--clay-deep); }
.stat span { font-size: 0.76rem; color: var(--ink-soft); letter-spacing: 0.04em; }

.hero__note { margin: 1.4rem 0 0; font-size: 0.82rem; color: var(--ink-soft); font-style: italic; }

/* ——— Folha do formulário ——— */

.sheet {
  width: var(--wrap);
  margin: 0 auto;
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 6px);
  box-shadow: var(--shadow);
  padding: clamp(1.2rem, 4vw, 2.2rem);
}

.block {
  border: 0;
  margin: 0 0 1.4rem;
  padding: 0 0 1.4rem;
  border-bottom: 1px dashed var(--line);
}
.block:last-of-type { border-bottom: 0; }

.block legend {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 520;
  padding: 0;
  margin-bottom: 1rem;
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
}

.block__num {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--clay);
}

.field { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.9rem; }
.field:last-child { margin-bottom: 0; }

.field label, .field__label {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  text-transform: uppercase;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
}
@media (max-width: 540px) { .field-row { grid-template-columns: 1fr; } }

input[type="text"], input[type="date"], input:not([type]), select, textarea {
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.7rem 0.9rem;
  width: 100%;
  transition: border-color 0.25s, box-shadow 0.25s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--sage);
  box-shadow: 0 0 0 3px var(--sage-soft);
}

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

/* Segmentado (turno / filtro) */

.seg {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  background: var(--sand);
  border-radius: 999px;
}

.seg__opt { position: relative; }
.seg__opt input { position: absolute; opacity: 0; pointer-events: none; }

.seg__opt span {
  display: inline-block;
  padding: 0.45rem 1.05rem;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.3s var(--ease), color 0.3s, box-shadow 0.3s;
}

.seg__opt input:checked + span {
  background: var(--cream);
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(51, 41, 31, 0.12);
}

.seg__opt input:focus-visible + span { outline: 2px solid var(--sage); outline-offset: 2px; }

.seg--small .seg__opt span { padding: 0.3rem 0.75rem; font-size: 0.8rem; }

/* Foto */

.photo { display: flex; align-items: center; gap: 0.9rem; flex-wrap: wrap; }

.photo__pick {
  font: inherit;
  font-weight: 600;
  color: var(--sage-deep);
  background: var(--sage-soft);
  border: 1px dashed var(--sage);
  border-radius: 14px;
  padding: 0.65rem 1.1rem;
  cursor: pointer;
  transition: background 0.3s;
}
.photo__pick:hover { background: color-mix(in srgb, var(--sage-soft) 60%, var(--sage) 14%); }

.photo__preview { position: relative; }
.photo__preview img {
  display: block;
  width: 84px;
  height: 84px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--line);
}

.photo__remove {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 0;
  background: var(--night);
  color: var(--light);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

/* Sinais vitais */

.vitals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 0.7rem;
}

.vital {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 0.15rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.7rem 0.8rem 0.6rem;
  transition: border-color 0.25s, box-shadow 0.25s, transform 0.25s var(--ease);
}
.vital:focus-within {
  border-color: var(--clay);
  box-shadow: 0 0 0 3px var(--clay-soft);
  transform: translateY(-2px);
}

.vital__name {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--clay-deep);
}

.vital input {
  border: 0;
  background: transparent;
  padding: 0;
  border-radius: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 520;
}
.vital input:focus { box-shadow: none; }

.vital__unit { font-size: 0.7rem; color: var(--ink-soft); }

/* Chips de atividades */

.chips { display: flex; flex-wrap: wrap; gap: 0.55rem; }

.chip { position: relative; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }

.chip span {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: all 0.25s var(--ease);
}

.chip input:checked + span {
  background: var(--sage-deep);
  border-color: var(--sage-deep);
  color: var(--light);
  transform: scale(1.04);
}

.chip input:focus-visible + span { outline: 2px solid var(--sage); outline-offset: 2px; }

.chips-actions { margin-top: 0.7rem; }

.chips-add {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--clay-deep);
  background: none;
  border: 0;
  padding: 0.3rem 0.2rem;
  cursor: pointer;
  border-bottom: 1px dashed var(--clay);
}
.chips-add:hover { color: var(--clay); }

/* Botão salvar */

.save {
  position: relative;
  width: 100%;
  border: 0;
  border-radius: 18px;
  padding: 1.05rem 1.2rem;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--light);
  background: linear-gradient(135deg, var(--clay), var(--clay-deep));
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.3s var(--ease), box-shadow 0.3s;
  box-shadow: 0 10px 26px rgba(168, 85, 57, 0.32);
}
.save:hover { transform: translateY(-2px); box-shadow: 0 14px 32px rgba(168, 85, 57, 0.4); }
.save:active { transform: translateY(0); }

.save__ok {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--sage-deep);
  transform: translateY(100%);
  transition: transform 0.4s var(--ease);
}
.save.is-saved .save__ok { transform: translateY(0); }

.form-hint { margin: 0.7rem 0 0; text-align: center; color: var(--clay-deep); font-size: 0.88rem; }

/* ——— Linha do tempo ——— */

.feed {
  width: var(--wrap);
  margin: 0 auto;
  padding: clamp(2.4rem, 6vw, 4rem) 0 2rem;
}

.feed__head h2 { font-size: var(--size-2); }

.feed__tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1.1rem;
}

.feed__reset {
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft);
  background: none;
  border: 0;
  cursor: pointer;
  border-bottom: 1px dashed var(--ink-soft);
  padding: 0.2rem 0;
}
.feed__reset:hover { color: var(--ink); }

.timeline {
  list-style: none;
  margin: 1.6rem 0 0;
  padding: 0;
}

.entry {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 0.9rem;
  opacity: 0;
  transform: translateY(14px);
  animation: entry-in 0.55s var(--ease) forwards;
}

@keyframes entry-in {
  to { opacity: 1; transform: none; }
}

.entry__rail { position: relative; }
.entry__rail::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  transform: translateX(-50%);
  background: var(--line);
}
.entry:last-child .entry__rail::before { bottom: auto; height: 28px; }

.entry__dot {
  position: absolute;
  left: 50%;
  top: 20px;
  width: 12px;
  height: 12px;
  transform: translate(-50%, 0);
  border-radius: 50%;
  background: var(--clay);
  border: 3px solid var(--paper);
  box-shadow: 0 0 0 1px var(--line);
}
.entry.is-night .entry__dot { background: var(--sage-deep); }

.entry__card {
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 8px 22px rgba(51, 41, 31, 0.06);
}

.entry__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.8rem;
}

.entry__who { font-family: var(--font-display); font-size: 1.12rem; font-weight: 520; }
.entry__when { display: block; font-size: 0.76rem; color: var(--ink-soft); margin-top: 0.1rem; }

.entry__shift {
  flex-shrink: 0;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 0.28rem 0.75rem;
  border-radius: 999px;
  background: var(--clay-soft);
  color: var(--clay-deep);
}
.entry.is-night .entry__shift { background: var(--night); color: #e8dcc8; }

.entry__resident {
  display: inline-block;
  margin-top: 0.55rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--sage-deep);
  background: var(--sage-soft);
  padding: 0.22rem 0.7rem;
  border-radius: 999px;
}

.entry__text { margin: 0.7rem 0 0; white-space: pre-line; }
.entry__text:empty { display: none; }

.entry__photo { margin-top: 0.8rem; }
.entry__photo img {
  display: block;
  max-width: 180px;
  max-height: 140px;
  border-radius: 14px;
  border: 1px solid var(--line);
  cursor: zoom-in;
}

.entry__vitals {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.8rem 0 0;
  padding: 0;
}
.entry__vitals:empty { display: none; }

.entry__vitals li {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 0.25rem 0.65rem;
  border-radius: 8px;
}
.entry__vitals li b { color: var(--clay-deep); font-weight: 700; }

.entry__routine { margin: 0.55rem 0 0; font-size: 0.85rem; color: var(--ink-soft); }
.entry__routine:empty { display: none; }

.entry__acts {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.7rem 0 0;
  padding: 0;
}
.entry__acts:empty { display: none; }

.entry__acts li {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--sage-deep);
  background: var(--sage-soft);
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
}

.entry__nurse {
  margin-top: 0.9rem;
  padding: 0.8rem 1rem;
  border-radius: 14px;
  background: var(--sage-soft);
  border-left: 3px solid var(--sage-deep);
}
.entry__nurse strong { font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--sage-deep); }
.entry__nurse p { margin: 0.3rem 0 0.2rem; font-size: 0.92rem; }
.entry__nurse small { color: var(--sage-deep); font-size: 0.75rem; }

.entry__del {
  margin-top: 0.7rem;
  font: inherit;
  font-size: 0.76rem;
  color: var(--ink-soft);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  border-bottom: 1px dashed currentColor;
}
.entry__del:hover { color: var(--clay-deep); }

.feed__empty { color: var(--ink-soft); font-style: italic; margin-top: 1.4rem; }

/* ——— Rodapé ——— */

.foot {
  width: var(--wrap);
  margin: 0 auto;
  padding: 1.6rem 0 calc(2.2rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.85rem;
}
.foot a { color: var(--sage-deep); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  html { scroll-behavior: auto; }
}
