/* ══════════════════════════════════════════════════════════
   FIELD SHELL + DATE RANGE PICKER
   Two things live here because they are one contract: `.field` is the
   shared input shell (leading icon, hidden label, tokenised placeholder)
   and `.drp` is the calendar popover that one of those fields opens.
   Both are page-agnostic — News is just the first caller.
   ══════════════════════════════════════════════════════════ */

/* ── the field shell ─────────────────────────────────────── */
/* The visible label is removed with `.vh` on the <label>, not display:none,
   so the control keeps its accessible name. The icon sits on the leading
   edge and the text is inset past it. */
.field{ position:relative; display:block; width:100%; }

.field-ico{
  position:absolute; left:15px; top:50%; translate:0 -50%;
  width:18px; height:18px; background:var(--fog);
  pointer-events:none;
  mask:center / contain no-repeat; -webkit-mask:center / contain no-repeat;
}
.field-ico--search{
  mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='6.5' fill='none' stroke='black' stroke-width='1.8'/%3E%3Cpath d='m16 16 5 5' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
  -webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='6.5' fill='none' stroke='black' stroke-width='1.8'/%3E%3Cpath d='m16 16 5 5' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
}
.field-ico--play{
  mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='9' fill='none' stroke='black' stroke-width='1.7'/%3E%3Cpath d='M10 8.5v7l6-3.5z' fill='black'/%3E%3C/svg%3E");
  -webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='9' fill='none' stroke='black' stroke-width='1.7'/%3E%3Cpath d='M10 8.5v7l6-3.5z' fill='black'/%3E%3C/svg%3E");
}
.field-ico--date{
  mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='3.5' y='5.5' width='17' height='15' rx='2' fill='none' stroke='black' stroke-width='1.7'/%3E%3Cpath d='M7 3.5v4M17 3.5v4M3.5 10h17' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round'/%3E%3C/svg%3E");
  -webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='3.5' y='5.5' width='17' height='15' rx='2' fill='none' stroke='black' stroke-width='1.7'/%3E%3Cpath d='M7 3.5v4M17 3.5v4M3.5 10h17' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round'/%3E%3C/svg%3E");
}

/* --flow-edge is the shared 3:1 control boundary — same token the contact
   form and the flow-chart nodes use. --line-2 is under 2:1 and fails 1.4.11. */
.field-input,.field-trigger{
  display:flex; align-items:center; width:100%; min-width:0; min-height:48px;
  padding:13px 16px 13px 45px;
  border:1px solid var(--field-outline); border-radius:var(--r-sm);
  background:var(--fill); color:var(--paper);
  font:14px/1.2 Inter,sans-serif; text-align:left; outline:none;
  transition:border-color .3s var(--ease),box-shadow .3s var(--ease),background .3s var(--ease);
}
.field-trigger{ cursor:pointer; padding-right:44px; }
/* A native <select> on the same shell. Native on purpose: it is keyboard
   operable, announces its own value and role, and gets the platform's own
   picker on touch — none of which a div-and-listbox reimplementation gets
   for free. Only the caret is ours. */
.field-select{
  appearance:none; -webkit-appearance:none; cursor:pointer;
  padding-right:42px;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5' fill='none' stroke='%23ffffff' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat:no-repeat; background-position:right 15px center; background-size:13px;
}
.field-input::placeholder{ color:var(--placeholder); opacity:1; }
.field-input:focus-visible,.field-trigger:focus-visible,
.field-input:focus,.field-trigger[aria-expanded="true"]{
  border-color:var(--focus-ring); box-shadow:none;
}
.field-input:focus-visible,.field-trigger:focus-visible{
  outline:2px solid var(--focus-ring); outline-offset:2px;
}
.field-trigger:hover{ background:var(--fill-hi); }
/* the trigger reads as a placeholder until a range is actually set */
.field-value[data-empty="true"]{ color:var(--placeholder); }

/* search inputs render a UA clear affordance; ours is the only one we style */
.field-input::-webkit-search-decoration,
.field-input::-webkit-search-cancel-button{ -webkit-appearance:none; }

.field-clear{
  position:absolute; right:7px; top:50%; translate:0 -50%;
  display:grid; place-items:center; width:34px; height:34px;
  border:0; border-radius:50%; background:transparent; color:var(--fog);
  font:16px/1 Inter,sans-serif; cursor:pointer;
  transition:background .25s var(--ease),color .25s var(--ease);
}
/* display:grid above outranks the UA's [hidden]{display:none} */
.field-clear[hidden]{ display:none; }
.field-clear:hover{ background:var(--fill-hi); color:var(--paper); }
.field-clear:focus-visible{ outline:2px solid var(--focus-ring); outline-offset:2px; }

/* ── the calendar popover ────────────────────────────────── */
/* Closed state is the `hidden` attribute, not opacity — that takes the whole
   subtree out of the tab order for free (2.4.3). */
.drp{
  position:absolute; z-index:60; top:calc(100% + 10px); right:0;
  width:min(620px,calc(100vw - 2 * var(--pad)));
  padding:18px 18px 14px;
  border:1px solid var(--line-2); border-radius:var(--r-md);
  background:var(--ink-2); box-shadow:var(--sh-float);
}
.drp[hidden]{ display:none; }
@media (prefers-reduced-motion:no-preference){
  .drp{ animation:drp-in .22s var(--ease) both; }
  @keyframes drp-in{ from{ opacity:0; translate:0 -6px; } to{ opacity:1; translate:0 0; } }
}

.drp-head{ display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:14px; }
.drp-title{ flex:1; text-align:center; color:var(--paper); font:600 14px/1.2 var(--font-display); letter-spacing:-.01em; }
.drp-nav{
  flex:0 0 auto; display:grid; place-items:center; width:40px; height:40px;
  border:1px solid var(--flow-edge); border-radius:var(--r-sm);
  background:transparent; color:var(--paper); cursor:pointer;
  transition:background .25s var(--ease),border-color .25s var(--ease);
}
.drp-nav:hover:not([disabled]){ background:var(--fill-hi); border-color:var(--flame); }
.drp-nav:focus-visible{ outline:2px solid var(--focus-ring); outline-offset:2px; }
.drp-nav[disabled]{ opacity:.38; cursor:default; }
.drp-nav svg{ width:16px; height:16px; }

.drp-months{ display:grid; grid-template-columns:1fr 1fr; gap:20px; }
.drp-cap{ margin-bottom:8px; color:var(--fog); font:600 11px/1.2 'JetBrains Mono',monospace; letter-spacing:.12em; text-transform:uppercase; text-align:center; }
.drp-grid{ width:100%; border-collapse:collapse; table-layout:fixed; }
.drp-grid th{ padding-bottom:6px; color:var(--fog-dim); font:500 11px/1.2 'JetBrains Mono',monospace; letter-spacing:.06em; }
.drp-grid th abbr{ text-decoration:none; }

/* 2.5.8 wants 24px; 40 gives a comfortable pointer target and lets the
   range bar read as a continuous rule. */
.drp-cell{
  position:relative; height:40px; border-radius:var(--r-sm);
  color:var(--paper); font:500 13px/40px Inter,sans-serif;
  text-align:center; cursor:pointer; user-select:none;
  transition:background .18s var(--ease),color .18s var(--ease);
}
.drp-cell:hover{ background:var(--fill-hi); }
.drp-cell:focus-visible{ outline:2px solid var(--focus-ring); outline-offset:-2px; }
.drp-cell[aria-disabled="true"]{ color:var(--fog-dim); opacity:.45; cursor:default; }
.drp-cell[aria-disabled="true"]:hover{ background:transparent; }

/* today */
.drp-cell[aria-current="date"]{ box-shadow:inset 0 0 0 1.5px var(--flame); }

/* The range band carries a 2px flame rule as well as a tint: a 14%-alpha
   fill alone is nowhere near the 3:1 that 1.4.11 asks of a state indicator,
   and the rule joins up across the span so it reads as one bar. */
.drp-cell[data-range]::after{
  content:''; position:absolute; left:0; right:0; bottom:5px;
  height:2px; background:var(--flame);
}
.drp-cell[data-range="inside"]{ background:var(--flame-dim); }
.drp-cell[data-range="start"]::after{ left:50%; border-radius:2px 0 0 2px; }
.drp-cell[data-range="end"]::after{ right:50%; border-radius:0 2px 2px 0; }
.drp-cell[data-range="only"]::after{ left:30%; right:30%; border-radius:2px; }

/* Endpoints invert rather than take a flame fill: white on flame is 3.5:1,
   under the 4.5:1 this text needs. --paper on --ink-2 flips with the theme
   and clears 14:1 either way.
   Keyed on data-range, NOT aria-selected — every day in the range carries
   aria-selected="true" so screen readers read the whole span, and styling
   off it filled the entire band solid. */
.drp-cell[data-range="start"],.drp-cell[data-range="end"],.drp-cell[data-range="only"]{
  background:var(--paper); color:var(--ink-2); font-weight:700;
}
.drp-cell[data-range="start"]::after,
.drp-cell[data-range="end"]::after,
.drp-cell[data-range="only"]::after{ background:var(--ink-2); }
.drp-cell[data-range="start"]:hover,.drp-cell[data-range="end"]:hover,.drp-cell[data-range="only"]:hover{ background:var(--paper); }

.drp-foot{ display:flex; align-items:center; justify-content:space-between; gap:12px; margin-top:12px; padding-top:12px; border-top:1px solid var(--line); }
.drp-status{ flex:1; min-width:0; color:var(--fog); font:12px/1.4 Inter,sans-serif; }
.drp-actions{ display:flex; flex:0 0 auto; gap:8px; }
.drp-btn{
  min-height:40px; padding:10px 18px;
  border:1px solid var(--flow-edge); border-radius:999px;
  background:transparent; color:var(--paper);
  font:600 13px/1.2 var(--font-display); cursor:pointer;
  transition:background .25s var(--ease),border-color .25s var(--ease);
}
.drp-btn:hover{ background:var(--fill-hi); border-color:var(--flame); }
.drp-btn:focus-visible{ outline:2px solid var(--focus-ring); outline-offset:2px; }
/* --action, matching .btn-flame in components.css, which despite its name
   is navy. White on --flame is 3.49:1 and fails 1.4.3; on --action it is
   11.9:1, and it keeps the primary button consistent with the rest of the
   site rather than inventing a second one. */
.drp-btn--primary{ border-color:var(--action); background:var(--action); color:var(--ai-card-white); }
.drp-btn--primary:hover{ background:var(--ai-card-start); border-color:var(--ai-card-start); }
.drp-btn--primary:focus-visible{ outline-color:var(--focus-on-action); }

@media (max-width:640px){
  /* right:0 would hang the popover off the left edge once it is wider than
     the field, so it anchors left and fills the field instead */
  .drp{ left:0; right:auto; width:100%; padding:16px 14px 12px; }
  .drp-months{ grid-template-columns:1fr; gap:16px; }
  /* with one month on screen the caption just repeats the dialog title.
     It stays in the DOM: aria-labelledby still resolves through display:none. */
  .drp-cap{ display:none; }
  .drp-foot{ flex-direction:column; align-items:stretch; }
  .drp-actions .drp-btn{ flex:1; }
}
