/*
 * converter.css — styles for the `.cw` live currency-converter widget
 * (see build.py: build_converter_widget, and shared/converter.js).
 *
 * Visual language matches `.answer-box` in site.css: white card, gold
 * inline-start accent, soft shadow, same radius/spacing tokens. Relies on
 * the :root custom properties defined in site.css (--red, --gold, --dark,
 * --surface, --border, --radius, --shadow) — this file is always loaded
 * alongside site.css by build.py, never standalone.
 *
 * Logical properties (inline-start/end) are used throughout instead of
 * left/right so the widget mirrors correctly on the site's RTL locales.
 */

.cw {
  background: #fff;
  border-inline-start: 4px solid var(--gold);
  border-radius: 0 var(--radius) var(--radius) 0;
  box-shadow: var(--shadow);
  padding: 1.5rem 1.75rem;
  margin: 1.5rem 0 2rem;
  /* Reserve space for the tallest state (interactive form) up front so
     revealing it after JS init never shifts the rest of the page (CLS). */
  min-height: 320px;
}

.cw__heading {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--dark);
  margin-bottom: 0.6rem;
  line-height: 1.25;
}

.cw__intro {
  font-size: 0.95rem;
  color: #444;
  line-height: 1.6;
  margin-bottom: 0.9rem;
}

.cw__static {
  font-size: 1.02rem;
  color: var(--dark);
  line-height: 1.6;
}

/* --- interactive form ----------------------------------------------------- */

.cw__form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin-top: 0.25rem;
}
/* Must win over the flex display above whenever the [hidden] attribute is
   set (progressive-enhancement toggle in converter.js) — same-specificity
   author rules would otherwise beat the UA's `[hidden]{display:none}`. */
.cw__form[hidden] {
  display: none;
}

.cw__row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.85rem;
}

.cw__field {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.cw__label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #555;
  margin-bottom: 0.35rem;
}

.cw__inputwrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 4px);
  padding: 0.65rem 0.85rem;
}

.cw__input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--dark);
  font-family: inherit;
}
.cw__input:focus {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
  border-radius: 4px;
}

.cw__unit {
  flex-shrink: 0;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #666;
}

.cw__result {
  flex: 1;
  min-width: 0;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--red);
  overflow-wrap: anywhere;
}

.cw__swap {
  flex-shrink: 0;
  align-self: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  border: 2px solid var(--red);
  background: #fff;
  color: var(--red);
  font-size: 1.2rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.15s;
}
.cw__swap:hover {
  background: var(--red);
  color: #fff;
}
.cw__swap:active {
  transform: scale(0.94);
}
.cw__swap:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.cw__rate-line {
  font-size: 0.85rem;
  color: #555;
}

.cw__notice {
  font-size: 0.85rem;
  color: #6b5900;
  background: #fff7e0;
  border: 1px solid #f0dda0;
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
}

.cw__source,
.cw__disclaimer {
  font-size: 0.8rem;
  color: #555;
}

/* --- responsive: horizontal row once there's room for input | swap | result --- */
@media (min-width: 560px) {
  .cw { min-height: 260px; }
  .cw__row {
    flex-direction: row;
    align-items: flex-end;
    gap: 0.75rem;
  }
  .cw__swap { align-self: flex-end; margin-bottom: 0.1rem; }
}

/* --- RTL mirror, matching .answer-box's pattern in site.css --- */
[dir="rtl"] .cw {
  border-radius: var(--radius) 0 0 var(--radius);
}
