/* ==========================================================================
   Procapita Research Hub — application stylesheet.

   Layer order matters and mirrors the design prototypes exactly:
     tokens/fonts → colors → typography → spacing → radius → shadows
     → fig-tokens → base → (this file)

   fig-tokens.css deliberately re-points --text-primary at pure black, which is
   what the prototypes render. Do not "fix" it here — it is the intended cascade.
   ========================================================================== */

@import url("tokens/fonts.css");
@import url("tokens/colors.css");
@import url("tokens/typography.css");
@import url("tokens/spacing.css");
@import url("tokens/radius.css");
@import url("tokens/shadows.css");
@import url("tokens/fig-tokens.css");
@import url("tokens/base.css");

/* --------------------------------------------------------------------------
   Hub theme overrides — every page in the redesign remaps the brand from
   Procapita Green to the primary blue (design checklist item 41).
   -------------------------------------------------------------------------- */
:root {
  --pc-blue-700: #2c5f9e;
  --pc-lav: #f2f2f9;
  --text-link: var(--pc-blue-primary);
  --brand: var(--pc-blue-primary);
  --brand-hover: var(--pc-blue-700);
}

body { background: var(--pc-white); }
a { color: var(--pc-blue-primary); }
a:hover { color: var(--pc-blue-700); }

/* --------------------------------------------------------------------------
   Keyframes
   -------------------------------------------------------------------------- */
@keyframes pc-blink  { 0%, 100% { opacity: 1 } 50% { opacity: .25 } }
@keyframes pc-scroll { from { transform: translateX(0) } to { transform: translateX(-50%) } }
@keyframes pc-bounce { 0%, 100% { transform: translateY(0) } 50% { transform: translateY(-5px) } }
@keyframes pc-fade   { from { opacity: 0; transform: translateY(4px) } to { opacity: 1; transform: none } }

/* --------------------------------------------------------------------------
   Scrollbars
   -------------------------------------------------------------------------- */
.pc-thinscroll::-webkit-scrollbar { width: 6px }
.pc-thinscroll::-webkit-scrollbar-thumb { background: var(--pc-line); border-radius: 3px }

/* ==========================================================================
   Interaction utilities.
   The prototypes express pseudo-classes as `style-hover` / `style-focus`
   attributes. Each distinct rule becomes one class here, values verbatim.
   ========================================================================== */
.hv-btn-blue:hover        { background: var(--pc-blue-700) }
.hv-txt-blue:hover        { color: var(--pc-blue-primary) }
.hv-bg-mist:hover         { background: var(--pc-mist) }
.hv-card:hover            { border-color: var(--pc-blue-primary); box-shadow: var(--shadow-card-hover) }
.hv-card-sm:hover         { border-color: var(--pc-blue-primary); box-shadow: var(--shadow-card) }
.hv-card-purple:hover     { border-color: var(--pc-purple); box-shadow: var(--shadow-card-hover) }
.hv-shadow:hover          { box-shadow: var(--shadow-card-hover) }
.hv-bd-blue:hover         { border-color: var(--pc-blue-primary) }
.hv-bd-blue-txt:hover     { border-color: var(--pc-blue-primary); color: var(--pc-blue-primary) }
.hv-bd-blue-mist:hover    { border-color: var(--pc-blue-primary); background: var(--pc-mist) }
.hv-chip-blue:hover       { border-color: var(--pc-blue-primary); color: var(--pc-blue-primary); background: #e8f0fa }
.hv-chip-green:hover      { border-color: var(--pc-blue-primary); color: var(--pc-green); background: #e6f1ec }
.hv-bd-blue-green:hover   { border-color: var(--pc-blue-primary); color: var(--pc-green) }
.hv-bd-bright:hover       { border-color: var(--pc-green-bright) }
.hv-bright:hover          { border-color: var(--pc-green-bright); color: var(--pc-green-bright) }
.hv-txt-red:hover         { color: #c02626 }

.fc-blue:focus            { border-color: var(--pc-blue-primary) }
.fc-bright:focus          { border-color: var(--pc-green-bright) }
.fw-search:focus-within   { border-color: var(--pc-blue-primary); box-shadow: 0 0 0 3px rgba(54, 119, 194, .18) }

/* ==========================================================================
   Page chrome — sticky header, nav, ticker
   ========================================================================== */
.pc-header {
  top: 0;
  z-index: 200;
  background: rgba(255, 255, 255, .95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: var(--shadow-xsmall);
}
.pc-header--sticky { position: sticky }
.pc-header--static { position: static }

.pc-header__bar {
  max-width: var(--container-max);
  margin: 0 auto;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(20px, 5vw, 64px);
  gap: 24px;
}
.pc-header__left  { display: flex; align-items: center; gap: 16px; min-width: 0 }
.pc-header__right { display: flex; align-items: center; gap: 12px; flex-shrink: 0 }

.pc-hubbadge {
  font-family: var(--font-label);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--pc-blue-primary);
  background: #e8f0fa;
  border: 1px solid #cfe0f4;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.pc-nav {
  display: flex;
  align-items: center;
  gap: 26px;
  margin-left: 12px;
  min-width: 0;
  overflow-x: auto;
  flex: 0 1 auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.pc-nav::-webkit-scrollbar { display: none }
.pc-nav a {
  font-size: 15px;
  text-decoration: none;
  white-space: nowrap;
  padding-bottom: 3px;
  flex-shrink: 0;
  font-weight: 500;
  color: var(--text-body);
  border-bottom: 2px solid transparent;
}
.pc-nav a:hover { color: var(--pc-blue-primary); text-decoration: none }
.pc-nav a.is-active {
  font-weight: 600;
  color: var(--pc-blue-primary);
  border-bottom-color: var(--pc-blue-primary);
}

@media (max-width: 1180px) { .pc-nav { gap: 18px } }
@media (max-width: 1060px) { .pc-nav { gap: 14px } .pc-hubbadge { display: none } }
@media (max-width: 900px)  { .pc-nav a { font-size: 14px } }

/* Header action controls */
.pc-hbtn {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text-body);
  border: 1px solid var(--border);
  background: var(--pc-white);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  cursor: pointer;
}
.pc-hbtn:hover { border-color: var(--pc-blue-primary); color: var(--pc-blue-primary) }

.pc-hicon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-body);
  border: 1px solid var(--border);
  background: var(--pc-white);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.pc-hicon:hover { border-color: var(--pc-blue-primary); color: var(--pc-blue-primary) }

.pc-signin {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 15px;
  color: var(--pc-white);
  background: var(--pc-blue-primary);
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 20px;
  min-height: 40px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.pc-signin:hover { background: var(--pc-blue-700) }

/* Live ticker */
.pc-tickwrap {
  background: var(--pc-mist);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  height: 38px;
  display: flex;
  align-items: center;
  overflow: hidden;
}
.pc-tickwrap:hover .pc-ticktrack { animation-play-state: paused }
.pc-tick__label {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--pc-green);
  color: var(--pc-cream);
  font-family: var(--font-label);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 0 14px;
  height: 100%;
  flex-shrink: 0;
  z-index: 2;
}
.pc-tick__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--pc-cream);
  animation: pc-blink 1.4s infinite;
}
.pc-ticktrack {
  display: flex;
  align-items: center;
  white-space: nowrap;
  animation: pc-scroll 46s linear infinite;
}
.pc-tick__item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px;
  font-size: 13px;
  color: var(--text-body);
  border-right: 1px solid var(--border);
}
.pc-tick__item b     { color: var(--text-primary); font-weight: 600 }
.pc-tick__item small { color: var(--text-muted); font-size: 11px }

/* ==========================================================================
   Layout primitives
   ========================================================================== */
.pc-container { max-width: var(--container-max); margin: 0 auto }

/* Standard section rhythm used by every content band. */
.pc-band            { padding: clamp(48px, 6vw, 80px) clamp(20px, 5vw, 64px) }
.pc-band--tight     { padding: clamp(44px, 5vw, 68px) clamp(20px, 5vw, 64px) }
.pc-band--cta       { padding: clamp(44px, 6vw, 72px) clamp(20px, 5vw, 64px) }
.pc-band--hero      { padding: clamp(44px, 6vw, 76px) clamp(20px, 5vw, 64px) clamp(32px, 4vw, 44px) }

.pc-sec--white { background: var(--pc-white) }
.pc-sec--mist  { background: var(--pc-mist); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border) }
.pc-sec--lav   { background: var(--pc-lav);  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border) }
.pc-sec--navy  { background: var(--pc-navy-deep) }

/* Section header: eyebrow + h2 + optional lede on the left, link on the right. */
.pc-sechead {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.pc-eyebrow {
  font-family: var(--font-label);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--pc-blue-primary);
  margin-bottom: 6px;
}
.pc-eyebrow--purple { color: var(--pc-purple) }
.pc-h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(24px, 2.6vw, 32px);
  letter-spacing: var(--ls-display);
  color: var(--text-primary);
}
.pc-h2--sm { font-size: clamp(22px, 2.4vw, 28px) }
.pc-lede { font-size: 15px; color: var(--text-body); margin-top: 6px }

.pc-morelink {
  font-size: 14px;
  font-weight: 600;
  color: var(--pc-blue-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}
.pc-morelink:hover { text-decoration: none }

/* Auto-fit card grids. The minimum track width varies per section. */
.pc-grid { display: grid; gap: 12px }
.pc-grid--150 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)) }
.pc-grid--160 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)) }
.pc-grid--170 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)) }
.pc-grid--260 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px }
.pc-grid--280 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px }
.pc-grid--300 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start }
.pc-grid--320 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: clamp(28px, 4vw, 48px); align-items: start }

/* ==========================================================================
   Cards & data display
   ========================================================================== */
.pc-card {
  background: var(--pc-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}
.pc-card--lg { border-radius: var(--radius-lg) }
.pc-card--xl { border-radius: var(--radius-xl) }

/* Metric tile: label, big tabular figure, delta pill, source footnote. */
.pc-metric        { padding: 15px }
.pc-metric__k     { font-size: 12px; color: var(--text-body); margin-bottom: 8px; display: flex; align-items: center; gap: 6px }
.pc-metric__v {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  color: var(--text-primary);
  letter-spacing: var(--ls-display);
  line-height: 1;
  margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
}
.pc-metric__src   { font-size: 10px; color: var(--text-muted); margin-top: 8px }

.pc-delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
}
.pc-delta--up   { background: #e6f1ec; color: var(--pc-green) }
.pc-delta--down { background: #fdecec; color: #c02626 }

/* Pill chips (trending searches, filters, interests) */
.pc-chip {
  font-size: 13px;
  font-family: var(--font-body);
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--pc-white);
  color: var(--text-body);
  white-space: nowrap;
  cursor: pointer;
}
.pc-chip.is-on {
  border-color: var(--pc-blue-primary);
  background: #e8f0fa;
  color: var(--pc-blue-primary);
  font-weight: 600;
}
.pc-chip--static { cursor: default; font-size: 12px; color: var(--text-body); padding: 3px 9px }

/* Buttons used inside page content */
.pc-btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
}
.pc-btn--primary { color: var(--pc-white); background: var(--pc-blue-primary); padding: 10px 18px }
.pc-btn--primary:hover { background: var(--pc-blue-700) }
.pc-btn--outline {
  color: var(--pc-blue-primary);
  background: var(--pc-white);
  border: 1px solid var(--pc-blue-primary);
  padding: 9px 16px;
}
.pc-btn--outline:hover { background: var(--pc-mist) }
.pc-btn--block { width: 100%; justify-content: center; padding: 13px; font-size: 15px }

/* Square icon tile that fronts most cards and list rows. */
.pc-icontile {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  flex-shrink: 0;
}
.pc-icontile--34 { width: 34px; height: 34px; font-size: 17px }
.pc-icontile--38 { width: 38px; height: 38px; font-size: 17px }
.pc-icontile--42 { width: 42px; height: 42px; font-size: 20px }
.pc-icontile--46 { width: 46px; height: 46px; font-size: 22px }
.pc-icontile--48 { width: 48px; height: 48px; font-size: 22px }
.pc-icontile--56 { width: 56px; height: 56px; font-size: 26px }

/* Form controls */
.pc-input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 13px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text-primary);
  outline: none;
  background: var(--pc-white);
}
.pc-input--num { font-variant-numeric: tabular-nums }

.pc-select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 32px 0 13px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text-primary);
  background-color: var(--pc-white);
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23808080' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
}
/* Dark variant used in the personalisation bar */
.pc-select--dark {
  height: 38px;
  color: var(--pc-white);
  background-color: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .2);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  font-size: 13px;
  width: auto;
}
.pc-label {
  font-family: var(--font-label);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 6px;
  display: block;
}

/* Segmented two-button toggle */
.pc-seg {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  height: 42px;
}
.pc-seg--dark  { border-color: rgba(255, 255, 255, .2); height: 38px }
.pc-seg button {
  flex: 1;
  font-family: var(--font-body);
  font-size: 13px;
  border: none;
  cursor: pointer;
  background: transparent;
  color: var(--text-body);
  padding: 0 15px;
}
.pc-seg button.is-on { background: var(--pc-blue-primary); color: var(--pc-white); font-weight: 600 }
.pc-seg--dark button        { color: var(--pc-slate-300) }
.pc-seg--dark button.is-on  { background: var(--pc-blue-primary); color: var(--pc-white); font-weight: 600 }

/* ==========================================================================
   Modals / overlays
   ========================================================================== */
.pc-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 31, 61, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.pc-overlay[hidden] { display: none }
.pc-modal {
  background: var(--pc-white);
  border-radius: var(--radius-xl);
  max-width: 100%;
  box-shadow: var(--shadow-xlarge);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: pc-fade .18s ease both;
}
.pc-modal__head {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.pc-modal__body { overflow-y: auto; padding: 18px 22px; display: flex; flex-direction: column; gap: 10px }
.pc-modal__x {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  display: flex;
}

/* Z-index ladder, matching the prototypes. */
.pc-overlay--lib   { z-index: 410 }
.pc-overlay--gov   { z-index: 410 }
.pc-overlay--gate  { z-index: 420 }
.pc-overlay--law   { z-index: 430 }
.pc-overlay--pref  { z-index: 430 }

/* ==========================================================================
   AI research assistant
   ========================================================================== */
.pc-chat-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 56px;
  height: 56px;
  background: var(--pc-blue-primary);
  border-radius: var(--radius-lg);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--pc-white);
  z-index: 300;
  box-shadow: var(--shadow-large);
}
.pc-chat-fab:hover { background: var(--pc-blue-700) }

.pc-chat {
  position: fixed;
  bottom: 96px;
  right: 28px;
  width: 390px;
  max-width: calc(100vw - 32px);
  background: var(--pc-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  z-index: 300;
  overflow: hidden;
  max-height: 560px;
  box-shadow: var(--shadow-xlarge);
}
.pc-chat[hidden] { display: none }
.pc-chat__head { background: var(--pc-navy-deep); padding: 16px 18px; display: flex; align-items: center; gap: 11px }
.pc-chat__msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 11px }
.pc-chat__foot { padding: 13px 15px; border-top: 1px solid var(--border); display: flex; gap: 9px }
.pc-typing {
  display: flex;
  gap: 4px;
  padding: 10px 13px;
  background: var(--pc-mist);
  border-radius: 12px 12px 12px 3px;
  align-self: flex-start;
}
.pc-typing span {
  width: 6px;
  height: 6px;
  background: var(--pc-blue-primary);
  border-radius: 50%;
  animation: pc-bounce 1.2s infinite;
}
.pc-typing span:nth-child(2) { animation-delay: .2s }
.pc-typing span:nth-child(3) { animation-delay: .4s }

.pc-starter {
  font-family: var(--font-body);
  font-size: 12px;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--text-body);
  background: var(--pc-white);
}
.pc-starter:hover { border-color: var(--pc-blue-primary); color: var(--pc-blue-primary); background: #e8f0fa }

/* Flag swatch wrapper used by law/source lists. */
.pc-flag {
  border-radius: var(--radius-xs);
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .08);
  display: inline-flex;
  flex-shrink: 0;
}

/* Respect reduced-motion for the decorative loops. */
@media (prefers-reduced-motion: reduce) {
  .pc-ticktrack,
  .pc-tick__dot,
  .pc-typing span,
  .pc-modal { animation: none !important }
}
