/*
 * Shared chrome for every page under /tools.
 *
 * Layer: components. Prefix: .tool-  (see .claude/rules/css.md)
 * Load order: css/style.css -> this file -> css/tools/<slug>.css
 *
 * Deliberately does NOT load css/page.css: that sheet is quarantined (its
 * default link colour fails AA, it sets overflow-x:hidden on html, and it
 * hard-codes text-align:right for the Hebrew legal pages).
 */

/* Tool pages are a flex column so the workspace can grow to fill the viewport. */
.tool-page main {
  flex: 1 0 auto;
  width: 100%;
}

.tool-skip-link {
  position: absolute;
  /* Logical, so it parks off the reading-start edge in RTL as well as LTR. */
  inset-inline-start: -9999px;
  inset-block-start: 0;
  z-index: 10;
  padding: var(--space-3, 0.75rem) var(--space-4, 1rem);
  background: var(--white-color, #fff);
  color: var(--secondary-color, #005B95);
  border-radius: 0 0 var(--border-radius, 8px) 0;
}

.tool-skip-link:focus {
  inset-inline-start: 0;
}

/* Keeps a control in the accessibility tree while hiding it visually, so a
   hidden file input is still reachable by assistive tech and by tooling. */
.tool-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* --- header ------------------------------------------------------------ */

/*
 * A compact bar rather than the marketing .header: that one runs a 6s shimmer
 * animation, which is wrong above a text editor, and its tagline styling lives
 * only in the quarantined page.css.
 */
.tool-header {
  background: var(--secondary-color, #005B95);
  padding-block: clamp(0.6rem, 2.5vw, 0.9rem);
}

.tool-header .wrapper {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3, 0.75rem);
}

.tool-header .logo-top img {
  width: clamp(96px, 20vw, 130px);
  margin: 0;
}

.tool-breadcrumb {
  color: var(--white-color, #fff);
  font-size: var(--text-sm, 0.9375rem);
}

.tool-breadcrumb a {
  color: var(--white-color, #fff);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.tool-breadcrumb .tool-breadcrumb-sep {
  opacity: 0.7;
  padding-inline: 0.35em;
}

/* --- page intro -------------------------------------------------------- */

.tool-intro {
  padding-block: clamp(1rem, 4vw, 1.75rem) clamp(0.5rem, 2vw, 0.75rem);
}

.tool-title {
  font-size: clamp(26px, 7vw, 34px);
  line-height: 1.2;
  color: var(--secondary-color, #005B95);
  margin-bottom: clamp(0.5rem, 2vw, 0.75rem);
}

.tool-lead {
  font-size: clamp(16px, 4.4vw, 17.5px);
  line-height: 1.7;
  color: var(--text-color, #2D3748);
  max-width: 62ch;
  text-wrap: pretty;
}

.tool-note {
  font-size: clamp(14px, 3.8vw, 15px);
  color: var(--text-light, #4A5568);
  margin-top: var(--space-2, 0.5rem);
  max-width: 62ch;
}

/* --- toolbar ----------------------------------------------------------- */

.tool-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2, 0.5rem);
  align-items: center;
  padding-block: var(--space-3, 0.75rem);
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding-inline: clamp(0.75rem, 3vw, 1.1rem);
  font-family: inherit;
  font-size: clamp(15px, 3.9vw, 16px);
  font-weight: 500;
  color: var(--secondary-color, #005B95);
  background: transparent;
  border: 1px solid rgba(0, 91, 149, 0.35);
  border-radius: var(--border-radius, 8px);
  cursor: pointer;
  transition: background var(--transition, 200ms), border-color var(--transition, 200ms);
}

.tool-btn:hover:not(:disabled) {
  background: rgba(0, 91, 149, 0.09);
  border-color: rgba(0, 91, 149, 0.55);
}

.tool-btn--primary {
  /* #00719F, not --primary-color: white text measures 5.4:1 there. */
  background: #00719F;
  border-color: #00719F;
  color: var(--white-color, #fff);
}

.tool-btn--primary:hover:not(:disabled) {
  background: #005B95;
  border-color: #005B95;
}

/* A class that sets `display` outranks the UA's [hidden] { display: none },
   so a hidden button would otherwise still render. This must stay next to
   .tool-btn's own display declaration. */
.tool-btn[hidden] {
  display: none;
}

.tool-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Transparent outline becomes a system-colour ring under forced-colors, where
   box-shadow is dropped entirely. */
.tool-btn:focus-visible,
.tool-skip-link:focus-visible {
  outline: 2px solid transparent;
  outline-offset: 2px;
  box-shadow: 0 0 0 3px var(--secondary-color, #005B95);
}

/* --- status ------------------------------------------------------------ */

/* min-height reserves the line so an announcement cannot shift the layout. */
.tool-status {
  min-height: 1.6em;
  font-size: clamp(14px, 3.8vw, 15px);
  line-height: 1.6;
  color: var(--text-light, #4A5568);
}

.tool-status.is-error {
  color: #8A2B2B;
  font-weight: 500;
}

@media (hover: none) {
  .tool-btn:hover:not(:disabled) {
    background: transparent;
    border-color: rgba(0, 91, 149, 0.35);
  }
}

@media (forced-colors: active) {
  .tool-btn {
    border: 1px solid ButtonBorder;
  }

  .tool-btn:focus-visible {
    outline: 2px solid Highlight;
  }
}

/* Secondary section heading, same family as .tool-title one step down. */
.tool-title--sub {
  font-size: clamp(20px, 5vw, 25px);
}

/* Language switch, sat in the tool header next to the breadcrumb. */
.tool-lang-switch {
  color: var(--white-color, #fff);
  font-size: var(--text-sm, 0.9375rem);
  text-decoration: underline;
  text-underline-offset: 0.2em;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding-inline: var(--space-2, 0.5rem);
}

.tool-lang-switch:hover {
  color: var(--white-color, #fff);
  opacity: 0.9;
}

.tool-lang-switch:focus-visible {
  outline: 2px solid transparent;
  outline-offset: 2px;
  box-shadow: 0 0 0 3px var(--white-color, #fff);
  border-radius: 4px;
}

/* --- segmented control (radio group) ----------------------------------- */

/* A real fieldset/legend rather than aria-pressed buttons: the browser gives
   arrow-key selection and announces "1 of 3" for free. */
.tool-seg {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2, 0.5rem);
  margin: 0;
  padding: 0 0 0 var(--space-2, 0.5rem);
  border: 0;
  border-inline-start: 1px solid rgba(0, 91, 149, 0.25);
}

.tool-seg-legend {
  /* float:none keeps the legend in flow so the flex row lays out normally. */
  padding: 0;
  margin-inline-end: var(--space-1, 0.25rem);
  font-size: clamp(14px, 3.6vw, 15px);
  color: var(--text-light, #4A5568);
}

.tool-seg-option {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  min-height: 44px;
  padding-inline: var(--space-2, 0.5rem);
  font-size: clamp(14px, 3.7vw, 15px);
  color: var(--text-color, #2D3748);
  cursor: pointer;
  border-radius: var(--border-radius, 8px);
}

.tool-seg-option:hover {
  background: rgba(0, 91, 149, 0.06);
}

.tool-seg-option:has(input:checked) {
  background: rgba(0, 91, 149, 0.1);
  color: var(--secondary-color, #005B95);
  font-weight: 500;
}

/* The ring goes on the label so it surrounds the whole hit area. */
.tool-seg-option:has(input:focus-visible) {
  outline: 2px solid transparent;
  outline-offset: 2px;
  box-shadow: 0 0 0 3px var(--secondary-color, #005B95);
}

@media (forced-colors: active) {
  .tool-seg-option:has(input:checked) {
    outline: 2px solid Highlight;
  }
}

/* Narrow screens: the group drops onto its own line rather than squeezing. */
@media (max-width: 599px) {
  .tool-seg {
    flex-basis: 100%;
    padding-inline-start: 0;
    border-inline-start: 0;
    border-block-start: 1px solid rgba(0, 91, 149, 0.2);
    padding-block-start: var(--space-2, 0.5rem);
  }
}

/* --- hub cards --------------------------------------------------------- */

/* Reuses .items/.item from css/style.css; only the call to action is new. */
.hub-card-cta {
  margin-block-start: auto;
  text-align: center;
}

.hub-card-cta .tool-btn {
  text-decoration: none;
}

@media (min-width: 768px) {
  .tool-page .items {
    grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
  }
}

/* --- view mode buttons ------------------------------------------------- */

.tool-view {
  display: flex;
  gap: var(--space-1, 0.25rem);
  padding-inline-start: var(--space-2, 0.5rem);
  border-inline-start: 1px solid rgba(0, 91, 149, 0.25);
}

.tool-btn--view[aria-pressed="true"] {
  background: rgba(0, 91, 149, 0.12);
  border-color: rgba(0, 91, 149, 0.5);
  font-weight: 600;
}

/* Layout choice is meaningless when the panes are forced to stack. */
@media (max-width: 767px) {
  .tool-view {
    display: none;
  }
}

@media (max-width: 599px) {
  .tool-view {
    padding-inline-start: 0;
    border-inline-start: 0;
  }
}

@media (forced-colors: active) {
  .tool-btn--view[aria-pressed="true"] {
    outline: 2px solid Highlight;
  }
}

/* --- word count -------------------------------------------------------- */

/* Deliberately NOT a live region: announcing on every keystroke would make
   the page unusable with a screen reader. It carries an aria-label so it can
   still be read on demand. */
.tool-count {
  font-size: clamp(13px, 3.4vw, 14px);
  color: var(--text-light, #4A5568);
  margin-block-start: calc(var(--space-1, 0.25rem) * -1);
}

/* --- export buttons ---------------------------------------------------- */

.tool-export {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1, 0.25rem);
  padding-inline-start: var(--space-2, 0.5rem);
  border-inline-start: 1px solid rgba(0, 91, 149, 0.25);
}

@media (max-width: 599px) {
  .tool-export {
    flex-basis: 100%;
    padding-inline-start: 0;
    border-inline-start: 0;
  }
}

@media print {
  .tool-export {
    display: none !important;
  }
}
