/* ============================================================
   Mango Studio · Analytics
   Built on top of styles.css's tokens (paper/ink/mango/line, Fraunces +
   Hanken Grotesk). This file only adds the analytics-page layout.
   ============================================================ */

.an-main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 32px 80px;
}

.an-heading h1 {
  font-family: "Fraunces", serif;
  font-weight: 500;
  font-size: 34px;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 0 0 4px;
}
.an-heading p {
  font-size: 14.5px;
  color: var(--muted);
  margin: 0 0 26px;
  max-width: 56ch;
}

/* ---------- filters ---------- */
.an-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 18px;
  margin-bottom: 24px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.an-field { display: flex; flex-direction: column; gap: 7px; }
.an-field-search { flex: 1 1 220px; min-width: 180px; }
.an-field-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--muted);
}
.an-field select,
.an-field input[type="search"] {
  font-family: inherit; font-size: 13.5px; color: var(--ink);
  background: var(--surface-soft); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 8px 11px; outline: none; min-height: 38px;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.an-field select { min-width: 150px; cursor: pointer; }
.an-field input[type="search"] { width: 100%; }
.an-field select:focus, .an-field input:focus {
  border-color: var(--mango); box-shadow: 0 0 0 3px var(--mango-ring);
}

.an-seg {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--surface-soft); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.an-seg button {
  font-family: inherit; font-size: 13px; font-weight: 500; color: var(--ink-soft);
  background: transparent; border: none; border-radius: 7px; padding: 6px 12px;
  cursor: pointer; transition: background 0.16s, color 0.16s;
}
.an-seg button:hover { color: var(--ink); }
.an-seg button.is-active { background: var(--surface); color: var(--mango); box-shadow: var(--shadow-sm); font-weight: 600; }

/* ---------- stat tiles ---------- */
.an-tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.an-tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow-sm);
}
.an-tile-label { font-size: 12px; color: var(--muted); font-weight: 500; margin-bottom: 8px; }
.an-tile-value {
  font-family: "Fraunces", serif; font-weight: 500; font-size: 30px; line-height: 1;
  color: var(--ink); letter-spacing: -0.01em;
}
.an-tile-sub { font-size: 12px; color: var(--faint); margin-top: 6px; }

/* ---------- cards / charts ---------- */
.an-charts {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}
.an-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px 16px; box-shadow: var(--shadow-sm);
}
.an-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.an-card-head h2 { font-size: 15px; font-weight: 600; color: var(--ink); margin: 0; }
.an-card-sub { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* trend bar chart */
.an-trend { display: flex; flex-direction: column; }
.an-trend-frame { position: relative; height: 176px; display: flex; }
.an-trend-grid {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between;
  pointer-events: none;
}
.an-trend-grid-line { position: relative; border-top: 1px solid var(--line); }
.an-trend-grid-line:last-child { border-top: 1px solid var(--line-strong); }
.an-trend-grid-line span {
  position: absolute; right: 0; top: -7px; font-size: 10.5px; color: var(--faint);
  background: var(--surface); padding-left: 4px; font-variant-numeric: tabular-nums;
}
.an-trend-bars {
  position: relative; flex: 1; display: flex; align-items: flex-end; gap: 3px;
  padding-right: 30px; /* room for gridline labels */
}
.an-trend-col {
  flex: 1 1 0; min-width: 0; height: 100%; display: flex; align-items: flex-end; justify-content: center;
}
.an-trend-bar {
  width: min(22px, 100%); border-radius: 4px 4px 0 0; background: var(--mango);
  min-height: 3px; cursor: pointer; transition: opacity 0.15s, transform 0.15s;
  position: relative;
}
.an-trend-bar:hover, .an-trend-bar:focus-visible { opacity: 0.82; outline: none; }
.an-trend-bar .an-bar-tip {
  position: absolute; top: -18px; left: 50%; transform: translateX(-50%);
  font-size: 11px; font-weight: 600; color: var(--ink-soft); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.an-trend-axis { display: flex; gap: 3px; padding-right: 30px; margin-top: 8px; }
.an-trend-axis span {
  flex: 1 1 0; min-width: 0; text-align: center; font-size: 10.5px; color: var(--faint);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.an-trend-empty, .an-hbars-empty { font-size: 13px; color: var(--muted); padding: 30px 0; text-align: center; }

/* horizontal project bars */
.an-hbars { display: flex; flex-direction: column; gap: 11px; }
.an-hbar-row { display: grid; grid-template-columns: minmax(0, 1fr) 2fr auto; align-items: center; gap: 10px; }
.an-hbar-label {
  font-size: 13px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.an-hbar-track { height: 10px; background: var(--surface-soft); border-radius: 6px; overflow: hidden; }
.an-hbar-fill { height: 100%; border-radius: 6px; background: var(--mango); min-width: 4px; transition: width 0.3s var(--ease); }
.an-hbar-value { font-size: 12.5px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; min-width: 22px; text-align: right; }
.an-hbar-row:focus-visible { outline: 2px solid var(--mango-ring); border-radius: 6px; }

/* ---------- table ---------- */
.an-table-card { padding: 18px 0 0; }
.an-table-card .an-card-head { padding: 0 20px; }
.an-table-wrap { overflow: auto; max-height: 560px; border-top: 1px solid var(--line); }
.an-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.an-table thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-soft); text-align: left; font-size: 11px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted);
  padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer;
  user-select: none;
}
.an-table thead th:first-child { padding-left: 20px; }
.an-table thead th:last-child { padding-right: 20px; }
.an-table thead th span { display: inline-flex; align-items: center; gap: 3px; }
.an-table thead th svg { width: 12px; height: 12px; opacity: 0; transition: opacity 0.15s; }
.an-table thead th[aria-sort="ascending"] svg.i-up,
.an-table thead th[aria-sort="descending"] svg.i-down { opacity: 1; color: var(--mango); }
.an-table thead th:hover svg { opacity: 0.5; }
.an-table tbody td {
  padding: 10px 14px; border-bottom: 1px solid var(--line); color: var(--ink-soft); vertical-align: middle;
}
.an-table tbody td:first-child { padding-left: 20px; }
.an-table tbody td:last-child { padding-right: 20px; }
.an-table tbody tr:last-child td { border-bottom: none; }
.an-table tbody tr:hover td { background: var(--surface-soft); }
.an-t-title { color: var(--ink); font-weight: 500; max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.an-t-project { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.an-t-project.is-empty { color: var(--faint); }
.an-t-date, .an-t-duration { font-variant-numeric: tabular-nums; white-space: nowrap; }
.an-assignees { display: flex; gap: 4px; }
.an-chip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 21px; height: 21px; border-radius: 50%; font-size: 10.5px; font-weight: 700;
  background: var(--mango-tint); color: var(--mango-deep);
}
.an-chip.is-jesu { background: var(--slate-tint); color: var(--slate); }

.an-empty, .an-loading { text-align: center; color: var(--muted); font-size: 13.5px; padding: 40px 20px; margin: 0; }

/* ---------- floating tooltip ---------- */
.an-tooltip {
  position: fixed; z-index: 40; pointer-events: none;
  background: var(--ink); color: var(--paper);
  font-size: 12px; line-height: 1.4; border-radius: 8px; padding: 7px 10px;
  box-shadow: var(--shadow-md); max-width: 220px;
  transform: translate(-50%, -100%);
}
[data-theme="dark"] .an-tooltip { background: var(--surface); border: 1px solid var(--line-strong); color: var(--ink); }
.an-tooltip strong { font-weight: 700; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .an-charts { grid-template-columns: 1fr; }
  .an-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .an-main { padding: 20px 16px 64px; }
  .an-heading h1 { font-size: 27px; }
  .an-filters { gap: 14px; padding: 14px; }
  .an-field select, .an-field-search { min-width: 0; }
  .an-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .an-tile { padding: 13px 14px; }
  .an-tile-value { font-size: 24px; }
  .an-card { padding: 15px 14px 14px; }
  .an-t-title { max-width: 160px; }
  .an-t-project { max-width: 100px; }
  .an-table thead th, .an-table tbody td { padding: 9px 10px; }
  .an-table thead th:first-child, .an-table tbody td:first-child { padding-left: 14px; }
  .an-table thead th:last-child, .an-table tbody td:last-child { padding-right: 14px; }
}
@media (max-width: 420px) {
  .an-tiles { grid-template-columns: 1fr 1fr; }
  .an-hbar-row { grid-template-columns: 76px 1fr auto; }
}
