/* TriggerMark — Therapist view: map, trigger zones, heat map and insight cards.
   Split out of index.html. */

  /* ---------- Therapist view / Map ---------- */
  .map-wrap{
    margin:2px 20px 14px;
    border-radius:var(--radius-l);
    overflow:hidden;
    border:1px solid var(--border);
    box-shadow:var(--shadow);
    height:340px;
    flex:none;
    position:relative;
    z-index:0;
    background:var(--card);
  }
  .map-wrap > div{width:100%;height:100%;}
  .map-caption{
    padding:0 20px 18px;
    color:var(--text-faint);
    font-size:.78rem;
    line-height:1.55;
  }
  .leaflet-pin{
    width:22px;height:22px;
    border-radius:50% 50% 50% 0;
    background:var(--mark);
    border:2px solid #fff2;
    box-shadow:0 3px 10px rgba(0,0,0,.4), 0 0 0 4px var(--mark-glow);
    transform:rotate(45deg);
  }
  .leaflet-pin::after{
    content:"";
    position:absolute;
    top:5px;left:5px;
    width:8px;height:8px;
    border-radius:50%;
    background:#fff;
    opacity:.9;
  }
  .leaflet-popup-content-wrapper,.leaflet-popup-tip{display:none;}

  .day-group{padding:6px 20px 4px;}
  .day-heading{
    display:flex;align-items:baseline;gap:9px;
    margin:18px 0 10px;
    padding:0 2px;
  }
  .day-heading:first-child{margin-top:2px;}
  .day-heading h3{font-size:.95rem;font-weight:700;color:var(--text);}
  .day-heading .count{
    color:var(--text-faint);
    font-size:.78rem;
    font-weight:600;
  }
  .day-heading .rule{flex:1;height:1px;background:var(--border-soft);}

  .entry-card{
    background:var(--card);
    border:1px solid var(--border-soft);
    border-radius:var(--radius-m);
    padding:14px 16px;
    margin-bottom:10px;
    display:flex;flex-direction:column;gap:8px;
    cursor:pointer;
    text-align:right;
    width:100%;
    color:inherit;
    appearance:none;
    transition:transform .12s ease, background .15s ease;
  }
  .entry-card:active{transform:scale(.985);background:var(--card-2);}
  .entry-top{display:flex;align-items:center;gap:8px;flex-wrap:wrap;}
  .entry-time{
    font-weight:800;
    font-size:.92rem;
    color:var(--calm);
    font-variant-numeric:tabular-nums;
    background:var(--calm-soft);
    padding:3px 10px;
    border-radius:999px;
  }
  .entry-loc{
    display:flex;align-items:center;gap:5px;
    min-width:0;overflow-wrap:anywhere;
    color:var(--text-dim);
    font-size:.82rem;
    font-weight:600;
  }
  .entry-loc svg{width:13px;height:13px;flex:none;}
  /* The watch is a different source from the patient's own tap, and the
     therapist has to be able to tell — a pill, not a colour that means more. */
  .entry-src{
    flex:none;font-size:.72rem;font-weight:600;color:var(--text-dim);
    border:1px solid var(--border);border-radius:999px;padding:2px 8px;
  }
  /* A preview, because the card opens the full note on tap — but two lines cut
     off most of what a patient actually writes. Twelve shows even a long entry
     whole and still stops a pasted wall of text from swallowing the list. */
  .entry-text{
    color:var(--text);
    font-size:.94rem;
    line-height:1.65;
    text-wrap:pretty;
    overflow-wrap:anywhere;
    display:-webkit-box;
    -webkit-line-clamp:12;
    -webkit-box-orient:vertical;
    overflow:hidden;
  }

  /* ---------- Zone cards (therapist stats) ---------- */
  .zone-card{
    display:flex;align-items:center;gap:12px;
    background:var(--card);
    border:1px solid var(--border-soft);
    border-radius:var(--radius-m);
    padding:12px 14px;
    cursor:pointer;
    text-align:right;
    width:100%;
    color:inherit;
    appearance:none;
    transition:transform .12s ease, background .15s ease;
  }
  .zone-card:active{transform:scale(.985);background:var(--card-2);}
  .zone-rank{
    width:26px;height:26px;border-radius:50%;
    background:var(--mark-glow);
    color:#fff;
    font-weight:800;font-size:.78rem;
    display:flex;align-items:center;justify-content:center;
    flex:none;
  }
  .zone-meta{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px;}
  .zone-name{font-weight:700;font-size:.92rem;}
  .zone-sub{color:var(--text-faint);font-size:.76rem;}
  .zone-count{
    flex:none;
    background:rgba(210,75,75,.16);
    color:#e58a8a;
    font-weight:800;
    font-size:.85rem;
    padding:4px 10px;
    border-radius:999px;
    font-variant-numeric:tabular-nums;
  }

  /* ---------- Insights screen ---------- */
  .insights-section{padding:6px 20px 26px;}
  .insights-section h3{font-size:1rem;font-weight:700;margin-bottom:4px;}
  .insights-sub{color:var(--text-faint);font-size:.78rem;margin-bottom:16px;line-height:1.55;}
  .heatmap-card{
    background:var(--card);
    border:1px solid var(--border-soft);
    border-radius:var(--radius-m);
    padding:16px 14px;
  }
  .heatmap-grid{
    display:grid;
    grid-template-columns:34px repeat(6,1fr);
    gap:4px;
    align-items:center;
  }
  .heatmap-grid .hcell{
    aspect-ratio:1/1;
    border-radius:5px;
    background:var(--bg-soft);
  }
  .heatmap-grid .hlabel{
    font-size:.66rem;
    color:var(--text-faint);
    text-align:right;
    font-weight:700;
  }
  .heatmap-grid .hcol-label{
    font-size:.6rem;
    color:var(--text-faint);
    text-align:center;
    font-weight:700;
  }
  .heat-legend{
    display:flex;align-items:center;justify-content:flex-end;gap:8px;
    margin-top:14px;
    color:var(--text-faint);
    font-size:.7rem;
  }
  .heat-legend .swatches{display:flex;gap:3px;}
  .heat-legend .sw{width:13px;height:13px;border-radius:3px;}

  .bars-card{
    background:var(--card);
    border:1px solid var(--border-soft);
    border-radius:var(--radius-m);
    padding:18px 16px;
    margin-top:16px;
  }
  .bar-row{margin-bottom:14px;}
  .bar-row:last-child{margin-bottom:0;}
  .bar-row .bar-top{
    display:flex;justify-content:space-between;
    font-size:.84rem;font-weight:600;
    margin-bottom:6px;
  }
  .bar-row .bar-top b{font-weight:800;color:var(--amber);font-variant-numeric:tabular-nums;}
  .bar-track{
    height:8px;border-radius:99px;
    background:var(--bg-soft);
    overflow:hidden;
  }
  .bar-fill{
    height:100%;border-radius:99px;
    background:linear-gradient(90deg, var(--amber), #e2bd7c);
  }
  .insights-note{
    margin-top:16px;
    color:var(--text-faint);
    font-size:.76rem;
    line-height:1.6;
    background:var(--bg-soft);
    border:1px solid var(--border-soft);
    border-radius:var(--radius-s);
    padding:12px 14px;
  }
