/* Client Reports portal — Ollin-style master/detail reader on Konstrukt.
   Layout ported from sites/ollin-site, trimmed to the report reader. */

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    linear-gradient(rgba(10, 10, 10, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(10, 10, 10, 0.035) 1px, transparent 1px),
    var(--bg);
  background-size: 32px 32px;
  color: var(--ink);
  font-family: var(--font-sans);
  line-height: 1.55;
}

a { color: inherit; text-decoration: none; }

.page { max-width: none; margin: 0; padding: 0; }

/* ---- Sticky top bar (Ollin-style) ---- */
.portal-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  padding: 14px clamp(16px, 3vw, 32px);
  border-bottom: 2px solid var(--border);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.portal-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.portal-brand-mark {
  display: inline-grid;
  place-items: center;
  min-width: 42px;
  height: 30px;
  padding: 0 8px;
  border: 2px solid var(--border);
  background: var(--accent-light);
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.portal-brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.portal-brand-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.05;
}

.portal-brand-subject {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.portal-bar-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  justify-content: flex-end;
  min-width: 0;
}

.portal-bar-tools input {
  width: 100%;
  max-width: 360px;
  min-height: 44px;
  border: 2px solid var(--border);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  font: 700 0.9rem var(--font-sans);
  padding: 10px 12px;
}
.portal-bar-tools input:focus { outline: 3px solid var(--accent-soft); }

/* ---- Theme toggle ---- */
.theme-toggle {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border: 2px solid var(--border);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.theme-toggle:hover,
.theme-toggle:focus-visible { background: var(--accent-light); color: var(--accent); }
.theme-toggle-icon {
  width: 18px;
  height: 18px;
  display: block;
}
/* Sun (shown in dark mode → click to go light) */
.theme-toggle-icon {
  background: currentColor;
  -webkit-mask: var(--theme-icon-moon) center / contain no-repeat;
          mask: var(--theme-icon-moon) center / contain no-repeat;
}
[data-mode="dark"] .theme-toggle-icon {
  -webkit-mask-image: var(--theme-icon-sun);
          mask-image: var(--theme-icon-sun);
}
:root {
  --theme-icon-moon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z'/%3E%3C/svg%3E");
  --theme-icon-sun: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3Cpath d='M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41'/%3E%3C/svg%3E");
}

.notes-app {
  display: grid;
  grid-template-columns: minmax(300px, 0.78fr) minmax(0, 1.22fr);
  min-height: 720px;
  border: 0;
  border-bottom: 2px solid var(--border);
  background: var(--bg);
}

.notes-list {
  max-height: 82vh;
  overflow: auto;
  border-right: 2px solid var(--border);
}

/* ---- Category groups ---- */
.report-group {
  border-bottom: 2px solid var(--border);
}
.report-group:last-child { border-bottom: 0; }

summary.report-group-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  list-style: none;
  cursor: pointer;
  user-select: none;
  background: var(--bg-alt, var(--bg));
  border-bottom: 2px solid var(--border-light);
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink);
}
summary.report-group-head::-webkit-details-marker { display: none; }
summary.report-group-head::marker { content: ""; }
summary.report-group-head:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.report-group-chevron {
  flex-shrink: 0;
  font-size: 0.6rem;
  line-height: 1;
  color: var(--muted);
  transition: transform var(--transition, 150ms ease);
}
.report-group[open] .report-group-chevron { transform: rotate(90deg); }
.report-group-count {
  margin-left: auto;
  padding: 1px 7px;
  border: 1px solid var(--border-light);
  background: var(--surface);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.04em;
}

.report-row {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 16px;
  border: 0;
  border-bottom: 2px solid var(--border-light);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.report-group .report-row:last-child { border-bottom: 0; }

.report-row:nth-child(odd) { background: var(--bg); }
.report-row:hover,
.report-row:focus-visible,
.report-row.is-active {
  outline: 0;
  background: var(--accent-light);
  border-bottom-color: var(--border);
}

.report-row strong {
  font-family: var(--font-display);
  font-size: 1.05rem;
  line-height: 1.12;
  letter-spacing: -0.02em;
}

.report-row-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.report-row-date {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
}

.report-badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 2px 7px;
  border: 1px solid var(--border-light);
  background: var(--surface);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.report-badge.is-uxcrit { color: var(--muted); }

.report-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.report-tags span {
  padding: 2px 6px;
  border: 1px solid var(--border-light);
  background: var(--surface);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.68rem;
}

/* ---- Reader pane ---- */
.note-reader {
  min-width: 0;
  max-height: 82vh;
  overflow: auto;
  padding: clamp(20px, 4vw, 42px);
  background: var(--surface);
}

.reader-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 6px;
}

.note-reader h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3.5vw, 2.6rem);
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.reader-meta {
  margin: 0 0 28px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.reader-body { max-width: 78ch; font-size: 1rem; }
.reader-body > :first-child { margin-top: 0; }

.reader-body h1,
.reader-body h2,
.reader-body h3,
.reader-body h4 {
  margin: 1.5em 0 0.5em;
  font-family: var(--font-display);
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.reader-body h1 { font-size: 1.9rem; }
.reader-body h2 { font-size: 1.55rem; }
.reader-body h3 { font-size: 1.25rem; }
.reader-body h4 { font-size: 1.05rem; }
.reader-body p,
.reader-body li { color: var(--ink); }
.reader-body a { color: var(--accent); text-decoration: underline; overflow-wrap: anywhere; }
.reader-body ul,
.reader-body ol { padding-left: 1.3rem; }
.reader-body li { margin: 0.3em 0; }
.reader-body blockquote {
  margin: 20px 0;
  padding: 12px 16px;
  border-left: 4px solid var(--accent);
  background: var(--accent-light);
}
.reader-body blockquote p:last-child { margin-bottom: 0; }
.reader-body code {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  padding: 1px 5px;
  border: 1px solid var(--border-light);
  background: var(--bg);
}
.reader-body pre {
  overflow: auto;
  padding: 14px;
  border: 2px solid var(--border-light);
  background: var(--bg);
}
.reader-body pre code { border: 0; padding: 0; }
.reader-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0;
  font-size: 0.92rem;
}
.reader-body th,
.reader-body td {
  padding: 8px 10px;
  border: 1px solid var(--border-light);
  text-align: left;
}
.reader-body th { background: var(--bg); font-family: var(--font-display); }
.reader-body hr { border: 0; border-top: 2px solid var(--border-light); margin: 28px 0; }

/* ---- Buttons ---- */
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 14px;
  border: 2px solid var(--border);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
}
.btn-secondary:hover,
.btn-secondary:focus-visible { background: var(--accent-light); color: var(--accent); }

.reader-external { margin-top: 12px; }

/* ---- Admin (clients) ---- */
.client-card {
  border: 2px solid var(--border);
  background: var(--surface);
  margin-bottom: 16px;
}
.client-card summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  cursor: pointer;
  list-style: none;
}
.client-card summary::-webkit-details-marker { display: none; }
.client-name { font-family: var(--font-display); font-weight: 800; letter-spacing: -0.02em; }
.client-summary { display: flex; flex-direction: column; gap: 4px; }
.review-list { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--border-light); }
.review-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 2px solid var(--border-light);
}
.review-item:last-child { border-bottom: 0; }
.review-item h3 { margin: 0 0 4px; font-size: 1rem; }
.review-actions { display: flex; align-items: center; gap: 10px; }
.btn-copy {
  padding: 6px 10px;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  cursor: pointer;
}
.btn-copy.is-copied { background: var(--accent); color: var(--surface); }
.mono { font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted); }
.meta { color: var(--muted); }
.empty-state { padding: 22px; color: var(--muted); }

/* ---- Footer ---- */
.site-footer {
  margin-top: 32px;
  padding: 16px clamp(16px, 3vw, 32px);
  border-top: 2px solid var(--border-light);
}
.site-footer .meta { font-family: var(--font-mono); font-size: 0.78rem; }

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .notes-app { grid-template-columns: 1fr; }
  .notes-list {
    max-height: 380px;
    border-right: 0;
    border-bottom: 2px solid var(--border);
  }
  .note-reader { max-height: none; }
}

/* ---- Print: hide chrome, show only the open report ---- */
@media print {
  body { background: #fff; }
  .no-print,
  .notes-toolbar,
  .notes-list,
  .site-footer,
  .reader-actions { display: none !important; }
  .notes-app { display: block; border: 0; }
  .note-reader { max-height: none; overflow: visible; padding: 0; }
  .page { padding: 0; }
}
