/* static/css/years-index.css
   Years index page styles (no inline <style> needed)
   - Uses site-wide tokens (ink, line, etc.) from site.css
   - Only styles elements within .years-index
*/

/* Base helpers */
.years-index * { box-sizing: border-box; }
.years-index a { color:#0b57d0; text-decoration:none; }
.years-index a:hover { text-decoration: underline; }
.years-index .muted { color: var(--muted, #666); }

/* Page rhythm */
.years-index { }
.years-index .shelf {
  margin: 18px 0 22px;
}
.years-index .shelf-title {
  margin: 0 0 8px;
  font-size: 16px;       /* hooks into your heading font via site.css */
  font-weight: 700;
}

/* 10-column grid of year “pills” */
.years-index .row {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 8px;
  position: relative;
}

.years-index .pill-cell{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

/* Optional era ribbons (kept for future use; currently not rendered)
   Uncomment the markup in the template if you want them back. */
.years-index .ribbons {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 8px;
  align-items: end;
  margin: 2px 0 10px;
  height: 6px;
  position: relative;
}
.years-index .ribbon {
  grid-column: var(--start) / var(--end);
  height: 6px;
  border-radius: 999px;
  opacity: .35;
}

/* Year pills */
.years-index .pill {
  display: flex;
  flex-direction: column;       /* number + tiny percentage stacked */
  align-items: center;
  justify-content: center;
  gap: 2px;

  width: 100%;                  /* fill the grid cell width */
  min-height: 40px;
  border: 1px solid var(--line, #e7e7eb);
  border-radius: 10px;
  background: var(--pill-bg, #fff);
  color: var(--pill-ink, #111);
  font-family: var(--font-sans);   /* match linked pill font */
  font-weight: 600;
  position: relative;
  overflow: hidden;

  /* defaults for mix vars */
  --fill: 0;
  --share-consul: 0;
  --share-praetor: 0;
  --share-aedile: 0;
  --share-quaestor: 0;
  --share-consul-end: 0;
  --share-praetor-end: 0;
  --share-aedile-end: 0;
  --share-quaestor-end: 0;

  transition:
    transform .06s ease,
    box-shadow .12s ease,
    border-color .12s ease,
    background .12s ease;
}

/* Active vs inactive years */
.years-index .pill[data-active="true"]{
  --pill-active: #0b57d0;
  border-color: var(--pill-active);
  box-shadow: 0 1px 0 rgba(0,0,0,.03), 0 2px 10px rgba(0,0,0,.06);
}
.years-index .pill[data-active="true"]:hover {
  transform: translateY(-1px);
  text-decoration: none;
}
.years-index .pill[data-active="false"]{
  color: var(--pill-muted, #9ca3af);
  background: #fafafa;
  cursor: default;
}

/* === Pill magistrate mix visualization ================================== */

/* Shared base for pseudo-element */
.years-index--vertical .pill::before,
.years-index--horizontal .pill::before{
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  pointer-events: none;
  opacity: .80;  /* soften colours so year numbers stay legible */
}

/* Vertical stacking: fill from bottom up */
.years-index--vertical .pill::before{
  width: 100%;
  height: calc(100% * var(--fill, 0));
  background:
    linear-gradient(
      to top,
      var(--color-consul, #991b1b) 0 calc(var(--share-consul-end, 0) * 100%),
      var(--color-praetor, #7c3aed) calc(var(--share-consul-end, 0) * 100%) calc(var(--share-praetor-end, 0) * 100%),
      var(--color-aedile, #15803d) calc(var(--share-praetor-end, 0) * 100%) calc(var(--share-aedile-end, 0) * 100%),
      var(--color-quaestor, #0369a1) calc(var(--share-aedile-end, 0) * 100%) calc(var(--share-quaestor-end, 0) * 100%),
      var(--color-tribune, #f59e0b) calc(var(--share-quaestor-end, 0) * 100%) calc(var(--share-tribune-end, 0) * 100%)
    );
}

/* Horizontal stacking: fill from left to right (toggle by switching container class) */
.years-index--horizontal .pill::before{
  height: 100%;
  width: calc(100% * var(--fill, 0));
  background:
    linear-gradient(
      to right,
      var(--color-consul, #991b1b) 0 calc(var(--share-consul-end, 0) * 100%),
      var(--color-praetor, #7c3aed) calc(var(--share-consul-end, 0) * 100%) calc(var(--share-praetor-end, 0) * 100%),
      var(--color-aedile, #15803d) calc(var(--share-praetor-end, 0) * 100%) calc(var(--share-aedile-end, 0) * 100%),
      var(--color-quaestor, #0369a1) calc(var(--share-aedile-end, 0) * 100%) calc(var(--share-quaestor-end, 0) * 100%),
      var(--color-tribune, #f59e0b) calc(var(--share-quaestor-end, 0) * 100%) calc(var(--share-tribune-end, 0) * 100%)
    );
}

/* Inner pill text */
.years-index .pill-main { line-height: 1; }

/* Mobile: tighter gaps and slightly shorter pills */
@media (max-width: 700px){
  .years-index .row,
  .years-index .ribbons { gap: 6px; }
  .years-index .pill { min-height: 36px; }
  .years-index .pill-main{ font-size: 0.9em; }  /* slightly smaller year number on mobile */
}

/* Center the whole shelf block to the same axis as other pages */
.years-index .shelf,
.years-index .row,
.years-index .ribbons {
  max-width: var(--wrap, 980px);
  margin-left: auto;
  margin-right: auto;
  padding-left: 0;   /* the .wrap padding handles overall gutter */
  padding-right: 0;
  padding-bottom: 1px;
}

/* levels to change vertical stacking */
.years-index .ribbon { position: relative; }

/* Totals table above shelves */
.years-index__mag-totals{
  max-width: var(--wrap, 980px);
  margin: 0 auto 6px;           /* centered under intro */
  padding: 0 0 4px;
  font-family: var(--font-body);
  font-size: 1.02rem;           /* match home-intro__body */
  line-height: 1.55;
  color: var(--ink, #222);
}
.years-index__mag-totals .mag-totals-header{
  font-weight: 600;
  margin-bottom: 2px;
}
.years-index__mag-totals table{
  border-collapse: collapse;
}
.years-index__mag-totals th,
.years-index__mag-totals td{
  padding: 2px 6px;
  text-align: right;
  white-space: nowrap;
}
.years-index__mag-totals th:first-child,
.years-index__mag-totals td:first-child{
  text-align: left;
}

/* Mobile stacked version of totals (hidden on desktop) */
.years-index__mag-totals .mag-totals-mobile{
  display: none;
  width: 75%;                  /* narrower, sized to content */
  border-collapse: collapse;
  margin-top: 4px;
}
.years-index__mag-totals .mag-totals-mobile th,
.years-index__mag-totals .mag-totals-mobile td{
  padding: 2px 4px;
  text-align: left;
}
.years-index__mag-totals .mag-totals-mobile th{
  font-weight: 500;
  white-space: nowrap;
}
.years-index__mag-totals .mag-totals-mobile td{
  text-align: right;   /* right-align counts on mobile */
}
.years-index__mag-totals .mag-totals-mobile .mag-line--total th{
  font-weight: 600;
}

/* Office colour legend */
  .years-index__legend{
    max-width: var(--wrap, 980px);
    margin: 0 auto 12px;
    padding: 0 0 4px;
    font-family: var(--font-body);
    font-size: 1.02rem;           /* match home-intro__body */
    line-height: 1.55;
    color: var(--ink, #222);
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    align-items: center;
    position: sticky;
    top: calc(var(--topbar-offset, 0px) + var(--mobile-info-bar-height, 0px) + 12px);
    background: #fff;
    padding: .5rem 0 8px;
    z-index: 5;
    border-bottom: 1px solid #e7e7ea;
  }
.years-index__legend .legend-label{
  font-weight: 600;
  margin-right: 4px;
}
  .years-index__legend .legend-item{
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    border: none;
    background: transparent;
    padding: 0;
    margin: 0;
    font: inherit;
    color: inherit;
    cursor: pointer;
    transition: opacity .2s ease;
  }
  .years-index__legend .legend-swatch{
    width: 14px;
    height: 8px;
    border-radius: 999px;
    border: 1px solid rgba(0,0,0,.12);
  }
  .years-index__legend .legend-item:focus-visible{
    outline: 2px solid rgba(0,0,0,.6);
    border-radius: 999px;
  }
  .years-index__legend .legend-item--inactive{
    opacity: .45;
  }
  .years-index__legend .legend-item--inactive .legend-swatch{
    background: #fff;
    border-color: rgba(0,0,0,.18);
  }

/* Helper text under legend (from SiteAbout "Colours") */
.years-index__legend-help{
  max-width: var(--wrap, 980px);
  margin: 4px auto 12px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--muted, #555);
}
.years-index__legend-help .legend-help-header{
  font-weight: 600;
  margin: 0;
  color: var(--ink, #222);
}
.years-index__legend-help .legend-help-body p:first-child{
  margin: .25rem 0 0;  /* same spacing as .page-sub */
}

@media (max-width: 700px){
  .years-index__mag-totals table{
    display: none;
  }
  .years-index__mag-totals .mag-totals-mobile{
    display: table;
  }
}


/* Wider ribbons styled by admin-defined colors */
.years-index .ribbons {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 8px;
  align-items: center;
  margin: 4px 0 12px;
  height: 20px;
  position: relative;
}

.years-index .ribbon {
  grid-column: var(--start) / var(--end);
  height: 20px;
  border-radius: 999px;
  opacity: 0.95;
  display: flex;
  align-items: center;
  padding-left: 6px;
  overflow: hidden;
  position: relative;
  background: var(--ribbon-color, #ddd); /* fallback just in case */
}

/* Label text — black, small, aligned left */
.years-index .ribbon-label {
  font-size: 12px;
  font-weight: 500;
  color: #000;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

/* === Mobile: make ribbons taller and allow text inside === */
@media (max-width: 700px) {
    
  .years-index .shelf {
    margin: 4px 0 6px;
  }

  .years-index .ribbons {
    /* let the row grow to the tallest ribbon */
    height: auto;                 /* was a fixed height */
    min-height: 20px;             /* ensure some space even with short labels */
    margin: 6px 0 12px;           /* a bit more breathing room under pills */
    align-items: stretch;         /* items set their own height */
    gap: 3px;                     /* tighter column gap */
    padding-bottom: 1px;
  }

  .years-index .ribbon {
    /* make each ribbon tall enough to contain text comfortably */
    height: 24px;                 /* ↑ taller than desktop */
    padding-left: 6px;
    padding-right: 6px;
    border-radius: 999px;
    opacity: 0.95;
    display: flex;
    align-items: center;          /* center label vertically within the taller bar */
    overflow: hidden;
  }

  .years-index .ribbon-label {
    font-size: 11px;              /* a touch bigger so it’s readable */
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;      /* truncate long labels neatly */
    pointer-events: none;
  }
}

/* Very narrow devices: keep the taller bar but shrink text slightly */
@media (max-width: 420px) {
  .years-index .ribbon { height: 26px; }   /* a hair taller for low-DPI phones */
  .years-index .ribbon-label { font-size: 10px; }
}


.tap-tooltip {
  position: fixed;              /* viewport-based; no scrollY */
  z-index: 9999;
  background: rgba(0,0,0,.92);
  color: #fff;
  font-size: 12px;
  line-height: 1.25;
  padding: 6px 8px;
  border-radius: 6px;
  white-space: nowrap;
  box-shadow: 0 2px 10px rgba(0,0,0,.25);
  pointer-events: none;
  transform: translate(-50%, 0); /* centered at x; y is exact 'top' we set */
}

/* Default arrow: pointing UP toward the ribbon (tooltip below ribbon) */
.tap-tooltip::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 100%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-bottom-color: rgba(0,0,0,.92);
}

/* When flipped above the ribbon, arrow points DOWN */
.tap-tooltip.above::after {
  bottom: auto;
  top: 100%;
  border: 6px solid transparent;
  border-top-color: rgba(0,0,0,.92);
}


/* === Ribbon toggle button === */
.ribbon-toggle-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  max-width: var(--wrap, 980px);
  margin: 0 auto 8px;
  padding-right: 4px;
}

.ribbon-toggle-bar .chip {
  background: #f8f9fa;               /* soft neutral background */
  border: 1px solid #d0d0d0;         /* light grey border */
  border-radius: 999px;
  font-size: 12px;
  color: #000;                       /* <<< black text */
  font-weight: 500;
  min-width: 110px;
  text-align: center;
  padding: 4px 12px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}

.ribbon-toggle-bar .chip:hover {
  background: #e5e7eb;               /* slightly darker on hover */
  border-color: #c0c0c0;
  color: #000;                       /* keep black text even on hover */
}


/* When ribbons are hidden */
body.ribbons-off .ribbons {
  display: none !important;
}


/* ==== Years page intro section ==== */
.years-head {
  display: grid;
  grid-template-columns: 1.4fr auto;
  gap: 1rem;
  align-items: start;
  margin: .75rem 0 1.25rem;
}


.home-intro__title {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: clamp(1.1rem, 1.4vw, 1.35rem);
  margin: 0;  /* use paragraph margin for spacing */
}

.home-intro__body {
  font-family: var(--font-body);
  color: var(--ink, #222);
  line-height: 1.55;
  font-size: 1.02rem;
}
/* Match about page spacing between title and body */
.home-intro__body p:first-child{
  margin: .25rem 0 0;   /* like .page-sub */
}
}
