/* ==================================================================
   amirkral.ir — widget layer
   The six desktop cards: clock, weather, profile, news, quotes, rates.
   ================================================================== */

.widget {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ==================================================================
   Profile
   ================================================================== */
#profile-widget { width: 288px; }

.profile__body { padding: 0 1rem 1rem; }
.profile__head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.profile__avatar {
  width: 5rem;
  height: 5rem;
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.5);
  flex-shrink: 0;
}
.profile__name { font-size: 0.9rem; font-weight: 700; margin: 0; }
.profile__nick { font-size: 0.75rem; font-weight: 400; opacity: 0.9; }
.profile__title { font-size: 0.75rem; margin: 0.15rem 0 0; color: var(--text-soft); }
.profile__bio {
  font-size: 0.82rem;
  line-height: 1.85;
  text-align: justify;
  white-space: pre-line;
  margin: 0 0 1rem;
}
.profile__motto {
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  white-space: pre-line;
  margin: 0.85rem 0 0;
  padding-top: 0.85rem;
  border-top: 1px solid var(--divider);
}

/* ==================================================================
   News feed
   ================================================================== */
/* Matches the economic calendar beside it. */
#news-feed-widget-container { width: 300px; height: 245px; padding: 1rem 1rem 1.1rem; }

.news__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  cursor: grab;
}
.news__head h2 { font-size: 0.9rem; font-weight: 700; margin: 0; }
.news__source {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid rgba(128, 128, 128, 0.4);
  flex-shrink: 0;
}
.news__source img { width: 100%; height: 100%; object-fit: cover; }

.news__search {
  width: 100%;
  padding: 0.4rem 0.65rem;
  margin-bottom: 0.75rem;
  font-size: 0.78rem;
  border: 0;
  border-radius: 8px;
  background-color: rgba(255, 255, 255, 0.3);
  color: var(--text);
  outline: none;
  transition: background-color 0.25s ease;
}
html.dark .news__search { background-color: rgba(0, 0, 0, 0.2); }
.news__search:focus { background-color: rgba(255, 255, 255, 0.5); }
html.dark .news__search:focus { background-color: rgba(0, 0, 0, 0.3); }
.news__search::placeholder { color: var(--text-soft); opacity: 0.85; }

.news__list { flex: 1; padding-inline-end: 0.25rem; }

.news__item {
  display: block;
  padding: 0.5rem 0.4rem;
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
  transition: background-color 0.18s ease;
}
.news__item:last-child { border-bottom: 0; }
.news__item:hover { background-color: rgba(255, 255, 255, 0.12); }
html.dark .news__item:hover { background-color: rgba(0, 0, 0, 0.18); }

.news__title {
  font-weight: 500;
  font-size: 0.82rem;
  line-height: 1.6;
  transition: color 0.2s ease;
}
.news__item:hover .news__title { color: var(--brand); }

.news__date {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.66rem;
  opacity: 0.55;
}
.news__item:hover .news__date { opacity: 0.8; }

.news__state {
  text-align: center;
  padding: 1.25rem 0.5rem;
  font-size: 0.8rem;
  color: var(--text-soft);
}
.news__state .btn { margin-top: 0.6rem; padding: 0.35rem 1rem; font-size: 0.75rem; }

/* ==================================================================
   Quotes
   ================================================================== */
/* The card grows to fit its quote instead of scrolling: a quote that is
   cut off defeats the point of showing it. A minimum keeps short quotes
   from making the card look collapsed, and a maximum stops an unusually
   long one from running off the screen — at which point the text shrinks
   a step rather than becoming scrollable. */
/* A fixed box: the card sat in a column, and letting it grow with each
   quote pushed everything below it around every few seconds. Long quotes
   step down a size instead (see the is-long rules further down). */
#quotes-widget { width: 300px; height: 205px; padding-bottom: 0.35rem; }

/* A single column rather than two: the side panel took 40% of a 300px
   card and left the quote itself a narrow ribbon. Stacked, the quote gets
   the full width and the attribution sits quietly underneath. */
.quote { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.quote__text-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 1rem 0.5rem;
  min-height: 0;
  overflow: hidden;
}
.quote__text {
  font-size: 0.78rem;
  line-height: 1.85;
  text-align: center;
  word-wrap: break-word;
  margin: 0;
  transition: opacity 0.4s ease;
  /* The box is fixed, so an unusually long quote is clipped at a whole
     line rather than being allowed to stretch the card. */
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.quote__text.is-fading { opacity: 0; }

html[lang='en'] .quote__text,
html[lang='tr'] .quote__text { font-size: 0.73rem; line-height: 1.7; }

/* Longer quotes step down a size so more of them fit those five lines. */
.quote__text.is-long { font-size: 0.72rem; line-height: 1.75; -webkit-line-clamp: 6; }
.quote__text.is-very-long { font-size: 0.66rem; line-height: 1.65; -webkit-line-clamp: 7; }

.quote__info {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.4rem;
  padding: 0 1rem 0.15rem;
  text-align: center;
  border-top: 1px solid var(--divider);
  padding-top: 0.5rem;
  margin: 0 1rem;
}
.quote__book { font-weight: 700; font-size: 0.74rem; }
.quote__author { font-size: 0.68rem; opacity: 0.75; }
html[lang='en'] .quote__book,
html[lang='tr'] .quote__book { font-size: 0.7rem; }

.quote__dots { display: flex; justify-content: center; gap: 0.25rem; padding: 0.35rem 0 0.75rem; }
.quote__dot {
  width: 0.3rem;
  height: 0.3rem;
  border-radius: 50%;
  background-color: var(--divider);
  transition: background-color 0.3s ease, transform 0.3s ease;
}
.quote__dot.is-active { background-color: var(--brand); transform: scale(1.35); }

/* ==================================================================
   Announcement banner
   ================================================================== */
.announcement {
  position: absolute;
  top: 0;
  inset-inline: 0;
  z-index: 950;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.55rem 2.5rem;
  font-size: 0.82rem;
  font-weight: 500;
  text-align: center;
  color: #fff;
  background: var(--announce-color, var(--brand));
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
  transition: transform 0.35s var(--ease), opacity 0.3s ease;
}
.announcement.is-hidden { transform: translateY(-100%); opacity: 0; pointer-events: none; }
.announcement--info    { --announce-color: #2563eb; }
.announcement--success { --announce-color: #16a34a; }
.announcement--warning { --announce-color: #d97706; }
.announcement--danger  { --announce-color: #dc2626; }

.announcement #announcement-close,
#announcement-close {
  position: absolute;
  inset-inline-end: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  color: #fff;
  font-size: 1.1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease;
}
#announcement-close:hover { background-color: rgba(255, 255, 255, 0.2); }

@media (max-width: 640px) {
  .announcement { padding-inline: 2.2rem; font-size: 0.76rem; }
}

/* ==================================================================
   Economic calendar
   ================================================================== */
.widget--calendar { width: 300px; height: 290px; padding-bottom: 0.5rem; }

/* Two rows of segmented controls rather than loose pills: the period and
   the impact are separate choices, and a segmented group makes it obvious
   that exactly one of each is active. */
.calendar__filters {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0 0.85rem 0.55rem;
}
.calendar__filter-row {
  display: flex;
  gap: 0.15rem;
  padding: 0.15rem;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.14);
}
.calendar__filter {
  flex: 1;
  padding: 0.3rem 0.4rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text-soft);
  transition: background-color 0.16s var(--ease), color 0.16s var(--ease);
}
.calendar__filter:hover { color: var(--text); }
.calendar__filter.is-active {
  background: var(--glass-bg);
  color: var(--text-strong);
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

/* The impact row keeps a small colour cue, matching the bars in the list
   below, without turning the whole control into a block of colour. */
.calendar__filter--impact.is-active::before {
  content: '';
  display: inline-block;
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  margin-inline-end: 0.25rem;
  vertical-align: middle;
}
.calendar__filter--high.is-active::before { background: #ef4444; }
.calendar__filter--medium.is-active::before { background: #f59e0b; }
.calendar__filter--low.is-active::before { background: #22c55e; }

.calendar__list { flex: 1; padding: 0 0.75rem 0.35rem; }

.calendar__day {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 0.5rem 0 0.35rem;
  padding: 0.2rem 0.35rem;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-soft);
  background: var(--glass-bg);
  backdrop-filter: blur(6px);
}

.calendar__row {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.5rem 0.35rem;
  border-bottom: 1px solid var(--divider);
}
.calendar__row:last-child { border-bottom: 0; }

.calendar__when { flex-shrink: 0; width: 3.1rem; text-align: center; }
.calendar__time {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  direction: ltr;
  unicode-bidi: isolate;
  font-variant-numeric: tabular-nums;
}
.calendar__ccy {
  display: inline-block;
  margin-top: 0.15rem;
  padding: 0.05rem 0.35rem;
  border-radius: 5px;
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--text-soft);
  background: rgba(148, 163, 184, 0.18);
  direction: ltr;
}

.calendar__body { flex: 1; min-width: 0; }
.calendar__title { display: block; font-size: 0.76rem; line-height: 1.6; }
.calendar__figures { display: flex; gap: 0.6rem; margin-top: 0.2rem; flex-wrap: wrap; }
.calendar__figure { font-size: 0.64rem; color: var(--text-soft); }
.calendar__figure i { font-style: normal; opacity: 0.75; }
.calendar__figure b {
  margin-inline-start: 0.2rem;
  font-weight: 700;
  color: var(--text);
  direction: ltr;
  unicode-bidi: isolate;
}

/* Impact is a colour bar rather than a word, as on the reference
   calendars — it scans faster in a dense list. */
.calendar__impact {
  width: 0.25rem;
  align-self: stretch;
  border-radius: 999px;
  flex-shrink: 0;
  background: var(--divider);
}
.calendar__row--high .calendar__impact { background: #ef4444; }
.calendar__row--medium .calendar__impact { background: #f59e0b; }
.calendar__row--low .calendar__impact { background: #22c55e; }
.calendar__row--holiday .calendar__impact { background: #8f9bb3; }

.calendar__empty, .calendar__foot {
  padding: 1.5rem 1rem;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-soft);
}
.calendar__foot:empty { display: none; padding: 0; }

/* ==================================================================
   Central bank rates — compact slideshow
   Matches the live-rates card above it in width, one bank at a time.
   ================================================================== */
#central-rates-widget { width: 288px; padding-bottom: 0.35rem; }

.central__stage { padding: 0 1rem; min-height: 3.4rem; }

.central__panel {
  text-align: center;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.35s var(--ease), transform 0.35s var(--ease);
}
.central__panel.is-in { opacity: 1; transform: none; }

.central__bank { display: flex; align-items: center; justify-content: center; gap: 0.45rem; min-width: 0; margin-bottom: 0.35rem; }
.central__ccy {
  padding: 0.05rem 0.35rem;
  border-radius: 5px;
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--text-soft);
  background: rgba(148, 163, 184, 0.18);
  direction: ltr;
  flex-shrink: 0;
}
.central__name {
  font-size: 0.8rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.central__value { display: flex; align-items: baseline; justify-content: center; gap: 0.5rem; }
.central__rate {
  font-size: 1.35rem;
  font-weight: 800;
  direction: ltr;
  unicode-bidi: isolate;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

@media (max-width: 767px) {
  #market-hours-widget, #central-rates-widget, .widget--calendar { width: 100% !important; }
}

/* ==================================================================
   Data cards (any admin-registered API source)
   ================================================================== */
.widget--data { width: 288px; padding: 0 0 0.25rem; }

.datacard__list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding: 0.25rem 1rem 0.75rem;
  font-size: 0.8rem;
}

.datacard__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.datacard__label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 600;
  min-width: 0;
}
.datacard__label img { width: 1.15rem; height: 1.15rem; object-fit: contain; flex-shrink: 0; }
.datacard__label span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.datacard__value {
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.datacard__num { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; }
.datacard__unit { font-size: 0.68rem; font-weight: 400; opacity: 0.75; }

.datacard__foot {
  padding: 0.55rem 1rem 0.35rem;
  margin-top: auto;
  border-top: 1px solid var(--divider);
  font-size: 0.7rem;
  text-align: center;
  color: var(--text-soft);
}
.datacard__foot:empty { display: none; }

.datacard__state {
  padding: 1.25rem 0.5rem;
  text-align: center;
  color: var(--text-soft);
  font-size: 0.8rem;
  margin: 0;
}

@media (max-width: 767px) {
  .widget--data { width: 100% !important; }
}

/* ==================================================================
   Custom (admin-authored) cards
   ================================================================== */
.widget--custom { width: 288px; max-height: 380px; }
.widget--custom__body {
  flex: 1;
  padding: 0 1rem 1rem;
  font-size: 0.82rem;
  line-height: 1.85;
}
.widget--custom__body :first-child { margin-top: 0; }
.widget--custom__body img { border-radius: var(--radius-sm); max-width: 100%; }
.widget--custom__body a { color: var(--brand); text-decoration: underline; }

@media (max-width: 767px) {
  .widget--custom { width: 100% !important; max-height: none; }
}

/* ==================================================================
   Live rates
   ================================================================== */
#rates-widget { width: 288px; padding: 1rem; }

.rates__list { flex: 1; display: flex; flex-direction: column; gap: 0.75rem; font-size: 0.78rem; min-height: 200px; }

.rate {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.rate__label { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; }
.rate__label img { width: 1.25rem; height: 1.25rem; object-fit: contain; flex-shrink: 0; }
/* Follows the page direction so the unit sits where Persian expects it
   (to the left of the figure). Only the numeral itself is isolated LTR. */
.rate__value {
  font-weight: 700;
  font-size: 0.85rem;
  text-align: end;
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 0.25rem;
}
.rate__num { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; }
.rate__unit { font-size: 0.68rem; font-weight: 400; opacity: 0.75; }
.rate__change { font-size: 0.66rem; font-weight: 500; margin-inline-start: 0.3rem; }
.rate__change--up { color: var(--up); }
.rate__change--down { color: var(--down); }

.rates__foot {
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--divider);
  font-size: 0.7rem;
  text-align: center;
  color: var(--text-soft);
}

/* ==================================================================
   Persian text inside Latin interfaces
   Feeds and weather descriptions stay Persian even in EN/TR, so keep
   them readable with the right font and direction.
   ================================================================== */
html[lang='en'] #news-feed-widget-container,
html[lang='tr'] #news-feed-widget-container,
html[lang='en'] .weather__condition,
html[lang='tr'] .weather__condition {
  font-family: 'Vazirmatn', sans-serif;
}
html[lang='en'] .news__list,
html[lang='tr'] .news__list { direction: rtl; text-align: right; }

/* ==================================================================
   Mobile card sizing
   ================================================================== */
@media (max-width: 767px) {
  #wave-clock-widget,
  #weather-widget,
  #profile-widget,
  #rates-widget,
  #quotes-widget,
  #news-feed-widget-container {
    width: 100% !important;
    height: auto;
  }
  #quotes-widget { min-height: 215px; }
  #news-feed-widget-container { height: 320px; }

  /* Clock and weather sit side by side at the top on phones */
  .mobile-row { display: flex; gap: 0.75rem; width: 100%; }
  .mobile-row > * { flex: 1; min-width: 0; }
  .mobile-row .clock__face { height: 150px; --cy: 75px; }
  .mobile-row .clock__marker { transform-origin: 50% 65px; }
  .mobile-row .clock__hand--hour { height: 38px; }
  .mobile-row .clock__hand--minute { height: 56px; }
  .mobile-row .clock__hand--second { height: 63px; }
  .mobile-row .weather__icon { width: 4.5rem; height: 4.5rem; }
  .mobile-row .weather__temp { font-size: 2.25rem; }
}

@media (min-width: 768px) {
  .mobile-row { display: contents; }
}

/* The currency row can be long, so it scrolls rather than wrapping into
   a second line and pushing the list down. */
.calendar__filter-row--scroll {
  overflow-x: auto;
  scrollbar-width: none;
  border-radius: 999px;
}
.calendar__filter-row--scroll::-webkit-scrollbar { display: none; }
.calendar__filter--ccy {
  flex: 0 0 auto;
  padding-inline: 0.55rem;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.64rem;
  letter-spacing: 0.02em;
}

/* Owner-written header and footer, around any card. Each is removed
   entirely when empty, so a card using one or two of the three parts
   does not carry a blank strip. */
.card__header-html {
  padding: 0.15rem 1rem 0.6rem;
  font-size: 0.76rem;
  line-height: 1.8;
  color: var(--text-soft);
}
.card__footer-html {
  margin-top: auto;
  padding: 0.6rem 1rem 0.75rem;
  border-top: 1px solid var(--divider);
  font-size: 0.72rem;
  line-height: 1.8;
  color: var(--text-soft);
}
.card__header-html:empty, .card__footer-html:empty { display: none; }
.card__header-html p, .card__footer-html p { margin: 0; }

