/*
 * cards.css: shared styles for the card pages of the In-Kind Program site
 * (Telescope Access, Datasets and Software).
 *
 * Sphinx adds this file to every page of the site (see conf.py), so every
 * selector here starts with the `ikp-` prefix and cannot match anything on a
 * page that does not use those classes.
 *
 * The Computing Resources (IDAC) page keeps its own inline styles and does not
 * use this file.
 *
 * Layout of this file:
 *   1. Colour variables (light mode, then the dark-mode block)
 *   2. Shared pieces: filter bar, action bar, tables, badges, buttons, cards
 *   3. Telescope Access page only (ikp-map-*, ikp-opp-*)
 *   4. Datasets and Software pages only (expand controls, "Also see" link,
 *      the "Highlighted" teaser row)
 */

/* ---------------------------------------------------------------------------
 * 1. Colour variables
 *
 * These variables hold the colours used by the rules in this file, including
 * the map's (the template's SVG carries classes, not colours).
 * --------------------------------------------------------------------------- */
:root {
  --ikp-green: #1a5c33;              /* accents, highlight outline */
  --ikp-green-link: #145c33;         /* links inside opportunity cards */
  --ikp-green-tint: #f3faf6;         /* opportunity card background */
  --ikp-green-on-dark: #7fd6a0;      /* the green used for text and outlines in dark mode */
  --ikp-pill-hover: #e6e6e6;         /* outlined pill, hovered */
  --ikp-pill-hover-on-dark: rgba(255, 255, 255, 0.1);  /* outlined pill, hovered, dark mode */
  --ikp-text: #1a1a1a;
  --ikp-control-border: #999;        /* the search box */
  --ikp-table-border: #ddd;
  --ikp-map-background: #eef2f0;
  --ikp-map-land: #d7ded9;
  --ikp-map-land-stroke: #c3ccc5;
  --ikp-map-marker-available: #1a5c33;
  --ikp-map-marker-past: #a12626;
  --ikp-map-marker-future: #8a5a00;
  --ikp-map-marker-hover: #1a1a1a;   /* outline of a hovered marker */

  --ikp-badge-success-bg: #d9f2e3;
  --ikp-badge-success-text: #1a5c33;
  --ikp-badge-muted-bg: #e6e6e6;
  --ikp-badge-muted-text: #555;
  --ikp-badge-warning-bg: #fdeecb;
  --ikp-badge-warning-text: #8a5a00;
  --ikp-badge-danger-bg: #fbdcdc;
  --ikp-badge-danger-text: #a12626;

  --ikp-also-see-bg: #e6e6e6;
  --ikp-also-see-bg-hover: #d9d9d9;
  --ikp-also-see-text: #333;

  --ikp-teaser-bg: #f3faf6;          /* the "Highlighted" row */
  --ikp-teaser-border: #b7dcc5;
  --ikp-teaser-heading-text: #1a5c33;
  --ikp-teaser-link-text: #145c33;
  --ikp-teaser-reason-bg: #d9f2e3;
  --ikp-teaser-reason-text: #1a5c33;

  --ikp-milestone-approx: #666;
  --ikp-milestone-passed: #888;
  --ikp-milestone-passed-label: #a12626;
  --ikp-opp-warning-border: #8a5a00;
  --ikp-opp-warning-bg: #fdeecb;
  --ikp-opp-status-text: #1a1a1a;    /* status line of a banner that is upcoming or open */
  --ikp-opp-deadline-text: #1a5c33;  /* the deadline line of an open banner, emphasized */
  --ikp-opp-muted-border: #a9b3ad;   /* banner under review or closed */
  --ikp-opp-muted-bg: #f4f5f4;
  --ikp-opp-muted-text: #555;
  --ikp-opp-related-text: #666;      /* the "Related facility" line */
  --ikp-siblings-text: #555;
}

/* Dark mode. pydata-sphinx-theme sets data-theme="dark" on <html>; redefining the
 * light-only variables here makes our badges, pills, banners and map follow it.
 * Every text colour below reaches at least 4.5:1 against the background it is
 * drawn on, and the map markers at least 3:1 against the map panel and land
 * (tests/test_card_page_dark_mode.py checks this). The theme's own page and card
 * backgrounds are #14181e and #222832.
 * Variables not redefined here are listed, with reasons, in
 * tests/test_card_page_dark_mode.py. */
html[data-theme=dark] {
  --ikp-green: #7fd6a0;              /* accents: banner border, jump-highlight outline, expand pills */
  --ikp-green-link: #8fe0ae;
  --ikp-green-tint: #14281d;         /* opportunity card background */
  --ikp-text: #e8eaed;
  --ikp-table-border: #364150;       /* the theme's own table-border grey */

  /* Status badges: a dark tint of the hue, with light text of the same hue. */
  --ikp-badge-success-bg: #1f4a31;
  --ikp-badge-success-text: #bfeccf;
  --ikp-badge-muted-bg: #3a3f44;
  --ikp-badge-muted-text: #d8dce0;
  --ikp-badge-warning-bg: #4d3a0c;
  --ikp-badge-warning-text: #f5d68a;
  --ikp-badge-danger-bg: #5a2222;
  --ikp-badge-danger-text: #ffc4c4;

  --ikp-also-see-bg: #3a3f44;
  --ikp-also-see-bg-hover: #4a5056;
  --ikp-also-see-text: #e6e8ea;

  /* The "Highlighted" row: translucent green over the page background. */
  --ikp-teaser-bg: rgba(127, 214, 160, 0.08);
  --ikp-teaser-border: rgba(127, 214, 160, 0.4);
  --ikp-teaser-heading-text: var(--ikp-green-on-dark);
  --ikp-teaser-link-text: var(--ikp-green-on-dark);
  --ikp-teaser-reason-bg: rgba(127, 214, 160, 0.18);
  --ikp-teaser-reason-text: #d4f2e0;

  /* Opportunity banners: dark background, coloured border, light text. */
  --ikp-milestone-approx: #aab0b5;
  --ikp-milestone-passed: #959ca2;
  --ikp-milestone-passed-label: #ff9a9a;
  --ikp-opp-warning-border: #d9a441;
  --ikp-opp-warning-bg: #33270a;
  --ikp-opp-status-text: #e8eaed;
  --ikp-opp-deadline-text: var(--ikp-green-on-dark);
  --ikp-opp-muted-border: #6b756f;
  --ikp-opp-muted-bg: #23272b;
  --ikp-opp-muted-text: #c9cdd1;
  --ikp-opp-related-text: #aab0b5;
  --ikp-siblings-text: #b0b5ba;

  /* The map: a dark panel with dim land, so the brighter markers stand out. */
  --ikp-map-background: #1c232c;
  --ikp-map-land: #2f3a46;
  --ikp-map-land-stroke: #3d4a58;
  --ikp-map-marker-available: #4fd47e;
  --ikp-map-marker-past: #ff6b6b;
  --ikp-map-marker-future: #f0b429;
  --ikp-map-marker-hover: #ffffff;
}

/* ---------------------------------------------------------------------------
 * 2. Shared pieces
 * --------------------------------------------------------------------------- */

/* Row of filter drop-downs above the table. */
.ikp-filterbar { display: flex; flex-wrap: wrap; gap: 1rem; margin-bottom: 1rem; }
.ikp-filterbar label { font-size: 0.9em; }

/* Row holding the search box. The Telescope Access page adds
   `ikp-actionbar-spaced` for more space below. */
.ikp-actionbar { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.ikp-actionbar input[type="text"] { flex: 1; min-width: 220px; padding: 0.4em 0.6em; border: 1px solid var(--ikp-control-border); border-radius: 0.3em; font-size: 0.9em; }
.ikp-actionbar-spaced { margin-bottom: 1.5rem; }

/* The three card tables share one look; each page has its own class name. */
.ikp-telescopes-table,
.ikp-datasets-table,
.ikp-sw-table { width: 100%; border-collapse: collapse; margin-bottom: 2rem; }
.ikp-telescopes-table th, .ikp-telescopes-table td,
.ikp-datasets-table th, .ikp-datasets-table td,
.ikp-sw-table th, .ikp-sw-table td { text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid var(--ikp-table-border); }
.ikp-telescopes-table th,
.ikp-datasets-table th,
.ikp-sw-table th { cursor: pointer; user-select: none; }

/* Status badges in the tables. The Telescope Access page adds
   `ikp-badge-spaced`, a small margin so several badges can sit side by side;
   Datasets and Software use plain `ikp-badge`. The colour classes are shared. */
.ikp-badge { display: inline-block; padding: 0.15em 0.6em; border-radius: 1em; font-size: 0.85em; }
.ikp-badge-spaced { margin: 0 0.2em 0.2em 0; }
.ikp-badge-success { background: var(--ikp-badge-success-bg); color: var(--ikp-badge-success-text); }
.ikp-badge-muted { background: var(--ikp-badge-muted-bg); color: var(--ikp-badge-muted-text); }
.ikp-badge-warning { background: var(--ikp-badge-warning-bg); color: var(--ikp-badge-warning-text); }
.ikp-badge-danger { background: var(--ikp-badge-danger-bg); color: var(--ikp-badge-danger-text); }

/* A table row's title, a button styled to look like plain text. */
.ikp-title-link { color: inherit; text-decoration: none; cursor: pointer; background: none; border: none; padding: 0; font: inherit; text-align: left; }
.ikp-title-link:hover { text-decoration: underline; }

/* Outline shown briefly on a card after its title or map marker is clicked. */
.ikp-card.ikp-highlight .sd-card { outline: 3px solid var(--ikp-green); outline-offset: 2px; transition: outline-color 1.2s ease; }

/* ---------------------------------------------------------------------------
 * 3. Telescope Access page
 * --------------------------------------------------------------------------- */

/* Observing-opportunity cards above the filters. */
.ikp-opp-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.ikp-opp-card { border: 2px solid var(--ikp-green); border-radius: 0.75rem; padding: 1rem 1.25rem; background: var(--ikp-green-tint); color: var(--ikp-text); }
.ikp-opp-title { font-weight: 600; margin: 0 0 0.4em; color: var(--ikp-text); }
.ikp-opp-milestones { list-style: none; margin: 0.6em 0; padding: 0; font-size: 0.9em; }
.ikp-opp-milestones li { padding: 0.15em 0; }
.ikp-opp-milestones .approx::after { content: " (approx.)"; color: var(--ikp-milestone-approx); }
.ikp-opp-milestones .passed { text-decoration: line-through; color: var(--ikp-milestone-passed); }
/* A passed milestone shows only "(passed)", even when it is also approximate: this
   rule comes after the "(approx.)" rule above and replaces its content. The
   inline-block stops the strike-through of the milestone text from running
   through the label; a margin gives the gap instead of a leading space, so a
   label that wraps to a new line starts almost flush (a 0.3em indent). */
.ikp-opp-milestones .passed::after { content: "(passed)"; display: inline-block; margin-left: 0.3em; text-decoration: none; color: var(--ikp-milestone-passed-label); }
.ikp-opp-links a { margin-right: 1em; font-size: 0.9em; color: var(--ikp-green-link); }
.ikp-opp-card-warning { border-color: var(--ikp-opp-warning-border); background: var(--ikp-opp-warning-bg); }
/* "Related facility" links at the foot of a banner. */
.ikp-opp-related { font-size: 0.85em; color: var(--ikp-opp-related-text); margin-top: 0.6em; }
/* The status line under the title. An open banner emphasizes its deadline. */
.ikp-opp-status { margin: 0 0 0.6em; color: var(--ikp-opp-status-text); }
.ikp-opp-phase-open .ikp-opp-status { font-weight: 700; color: var(--ikp-opp-deadline-text); }
/* A banner under review or closed is muted. This rule comes after the accent
   rule above, so it also overrides the warning colours. The colours come from the
   variables, so dark mode restyles every banner through the block at the top. */
.ikp-opp-card-muted { border-color: var(--ikp-opp-muted-border); background: var(--ikp-opp-muted-bg); color: var(--ikp-opp-muted-text); }
.ikp-opp-card-muted .ikp-opp-title,
.ikp-opp-card-muted .ikp-opp-status { color: var(--ikp-opp-muted-text); }

/* World map. */
.ikp-map-wrap { margin-bottom: 1.5rem; border-radius: 0.5rem; overflow: hidden; background: var(--ikp-map-background); }
.ikp-map-marker { cursor: pointer; }
.ikp-map-marker:hover { stroke: var(--ikp-map-marker-hover); stroke-width: 1.5; }
/* The map's colours live here, not in the SVG, so dark mode can change them. */
.ikp-map-bg { fill: var(--ikp-map-background); }
.ikp-map-land { fill: var(--ikp-map-land); stroke: var(--ikp-map-land-stroke); }
.ikp-map-marker-available { fill: var(--ikp-map-marker-available); }
.ikp-map-marker-past { fill: var(--ikp-map-marker-past); }
.ikp-map-marker-future { fill: var(--ikp-map-marker-future); }

/* "Also available under this contribution" note on a telescope card. */
.ikp-siblings { font-size: 0.85em; color: var(--ikp-siblings-text); margin-top: 0.6em; }

/* ---------------------------------------------------------------------------
 * 4. Datasets and Software pages
 * --------------------------------------------------------------------------- */

/* Datasets: the extra fields hidden behind "Show more". */
.ikp-more-fields { display: none; }
.ikp-more-fields.ikp-expanded { display: block; }

/* The expand toggles (Datasets "Show more details", Software "Read full
   description") share one look: an outlined pill in the accent green. */
.ikp-more-btn,
.ikp-expand-btn { border: 1px solid var(--ikp-green); border-radius: 1em; background: none; color: var(--ikp-green); font-size: 0.85em; padding: 0.25em 0.9em; cursor: pointer; }
.ikp-more-btn:hover,
.ikp-expand-btn:hover { background: var(--ikp-pill-hover); }
/* In dark mode --ikp-green is the light green, so the pill needs no colour override;
   only the hover tint changes, because the light grey would be a bright patch. */
html[data-theme=dark] .ikp-more-btn:hover,
html[data-theme=dark] .ikp-expand-btn:hover { background: var(--ikp-pill-hover-on-dark); }
.ikp-more-btn { margin: 0.4em 0; }

/* Software: the description, clamped to three lines behind its toggle. It sits
   below the short rows, so the toggle needs room beneath it. */
.ikp-desc { -webkit-line-clamp: 3; display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; margin-bottom: 1em; }
.ikp-desc.ikp-expanded { -webkit-line-clamp: unset; display: block; overflow: visible; }
.ikp-expand-btn { margin: 0 0 1em; }
/* Fade the last clamped line into the card background. A mask (not a gradient
   painted in a colour) works in light and dark mode alike. */
.ikp-desc:not(.ikp-expanded) { -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 1.8em), transparent); mask-image: linear-gradient(to bottom, #000 calc(100% - 1.8em), transparent); }

/* "Also see" link between a dataset and its software (and back). A block that
   is only as wide as its text, so each link starts its own line (it does not
   sit beside a toggle button above it) and several links stack. */
.ikp-also-see { display: block; width: fit-content; background: var(--ikp-also-see-bg); color: var(--ikp-also-see-text); font-size: 0.85em; padding: 0.3em 0.8em; border-radius: 1em; margin-top: 1em; text-decoration: none; }
.ikp-also-see + .ikp-also-see { margin-top: 0.4em; }
.ikp-also-see:hover { background: var(--ikp-also-see-bg-hover); }

/* The "Highlighted" row above the filters: a small heading, then up to three
   compact teasers that each link to a card on this page. The names start with
   `ikp-teaser-` because `ikp-highlight` is the outline shown after a jump. The
   row sits outside the filtered table and grid, so the filters never hide it. */
.ikp-teasers { margin-bottom: 1.5rem; padding: 0.6em 1em 0.8em; border: 1px solid var(--ikp-teaser-border); border-radius: 0.5rem; background: var(--ikp-teaser-bg); }
.ikp-teaser-heading { margin: 0 0 0.4em; font-size: 0.8em; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ikp-teaser-heading-text); }
/* One column on a phone; side by side, wrapping, from tablet width up. */
.ikp-teaser-list { display: flex; flex-direction: column; gap: 0.4em 2em; margin: 0; padding: 0; list-style: none; }
.ikp-teaser { margin: 0; }
.ikp-teaser-link { color: var(--ikp-teaser-link-text); font-weight: 600; overflow-wrap: anywhere; }
.ikp-teaser-reason { display: inline-block; padding: 0.1em 0.6em; border-radius: 1em; font-size: 0.8em; background: var(--ikp-teaser-reason-bg); color: var(--ikp-teaser-reason-text); }
@media (min-width: 40em) {
  .ikp-teaser-list { flex-direction: row; flex-wrap: wrap; }
}
