/* Loading state. Shown before the first analysis and while switching parcels.
   One idea throughout: morning light crossing the field. A single diagonal band of light is pinned
   to the viewport, so every bone on screen catches it in turn instead of each flickering on its own.
   The brief says in words what is being read, while its field bands are laid down row after row. */

.skel { display: none; }
html:not([data-loaded]) .skel,
html[data-refreshing] .skel { display: grid; gap: 14px; animation: skIn 0.4s var(--ease-out) both; }

/* Hide the real content while the skeleton stands in. The brief (Hoy) and finca's tabs stay. */
html:not([data-loaded]) :is(#view-campo, #view-cuaderno) > :not(.skel),
html:not([data-loaded]) #view-finca .subview > :not(.skel),
html[data-refreshing] :is(#view-campo, #view-cuaderno) > :not(.skel),
html[data-refreshing] #view-finca .subview > :not(.skel),
html[data-refreshing] #view-hoy > :not(.skel, .brief) { display: none !important; }
html:not([data-loaded]) #view-hoy > .skel { display: none; } /* Hoy's own rows carry the bones */

/* ---------- Bones ---------- */

.sk,
html:not([data-loaded]) .vrow-answer {
  --sk-base: #ece7db;
  --sk-glow: #f8f6ef;
  display: block;
  border-radius: 999px;
  background-color: var(--sk-base);
  background-image: linear-gradient(105deg, transparent 38%, var(--sk-glow) 50%, transparent 62%);
  background-attachment: fixed;
  background-repeat: no-repeat;
  background-size: 260vw 100vh;
  animation: skLight 2.2s var(--ease-io) infinite;
}

.sk-card { display: grid; gap: 12px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--leaf-r-sm, 18px 4px 18px 4px); }
.sk-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 10px; }
.sk-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.sk-row:last-child { border-bottom: 0; }
.sk-col { display: grid; gap: 8px; }

.sk-line { height: 12px; }
.sk-line.thin { height: 9px; }
.w40 { width: 40%; } .w50 { width: 50%; } .w60 { width: 60%; } .w70 { width: 70%; } .w80 { width: 80%; } .w90 { width: 90%; }
.sk-num { height: 28px; width: 62%; border-radius: 8px; }
.sk-dot { width: 40px; height: 40px; border-radius: 14px 4px 14px 4px; }
.sk-pill { width: 56px; height: 24px; }
.sk-input { height: 48px; border-radius: 12px; }
.sk-card > .sk:first-child { margin-bottom: 4px; }

/* Charts keep their shape: a faint curve over a quiet ground, not a grey slab. */
.sk-chart,
.sk-bars { border-radius: 12px; }
.sk-chart {
  height: 160px;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 40' preserveAspectRatio='none'%3E%3Cpath d='M0 30C12 26 18 14 30 16S48 30 60 24 80 8 100 12V40H0Z'/%3E%3C/svg%3E") bottom / 100% 72% no-repeat,
                linear-gradient(#000 0 0) bottom / 100% 1px no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 40' preserveAspectRatio='none'%3E%3Cpath d='M0 30C12 26 18 14 30 16S48 30 60 24 80 8 100 12V40H0Z'/%3E%3C/svg%3E") bottom / 100% 72% no-repeat,
                linear-gradient(#000 0 0) bottom / 100% 1px no-repeat;
}
.sk-chart.short { height: 104px; }
.sk-bars {
  height: 120px;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 40' preserveAspectRatio='none'%3E%3Cpath d='M0 22h12v18H0zM18 12h12v28H18zM36 26h12v14H36zM54 8h12v32H54zM72 18h12v22H72zM90 28h10v12H90z'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 40' preserveAspectRatio='none'%3E%3Cpath d='M0 22h12v18H0zM18 12h12v28H18zM36 26h12v14H36zM54 8h12v32H54zM72 18h12v22H72zM90 28h10v12H90z'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
}

/* ---------- The brief while loading ---------- */

/* The field bands are laid down and lifted again, one row after another, until the answer lands;
   then html.intro lays them down for good (motion.css). */
html:not([data-loaded]) .brief-field path { animation: skFurrow 2.4s var(--ease-io) infinite both; }
html:not([data-loaded]) .brief-field .bf-green { animation-delay: 0.16s; }
html:not([data-loaded]) .brief-field .bf-mint { animation-delay: 0.32s; }
html:not([data-loaded]) #briefDate { color: var(--mint); }
html:not([data-loaded]) #briefHead { color: rgba(246, 243, 236, 0.62); font-weight: 600; }

/* Map pane: a quiet pulse until tiles and the parcel arrive. */
html:not([data-loaded]) #map { background: var(--sunken); animation: skPulse 1.6s var(--ease-io) infinite alternate; }

@keyframes skIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes skLight {
  from { background-position: 100% 0; }
  to { background-position: 0 0; }
}
@keyframes skFurrow {
  0% { clip-path: inset(0 100% 0 0); }
  45%, 60% { clip-path: inset(0 0 0 0); }
  100% { clip-path: inset(0 0 0 100%); }
}
@keyframes skPulse { from { background-color: var(--sunken); } to { background-color: #eae6dc; } }

@media (prefers-reduced-motion: reduce) {
  .sk, .skel, html:not([data-loaded]) :is(#map, .vrow-answer) { animation: none !important; }
  html:not([data-loaded]) .brief-field path { animation: none !important; clip-path: none; opacity: 0.35; }
}
