/*! widget-embed.bundle.css — the embeddable surf forecast widget.
    One stylesheet owns two surfaces:

      .tgzw*          the panel inside /widget/embed.php. That document renders
                      inside somebody else's page, so it carries its own tokens
                      (--tgzw-*) on .tgzwDoc and never reads the site's. Dark
                      follows the viewer's OS preference, or ?theme= when the
                      host pins one.
      .tgzwb*         the /widget/ snippet builder on our own site. That one uses
                      the site's --tgz-ui-* tokens, so light and dark come out of
                      the same theme switch as every other page.

    The two namespaces never touch, so nothing here needs !important. */

/* ============================================================ embed panel == */

.tgzwDoc {
  --tgzw-bg: #fffaf1;
  --tgzw-surface: #f4eadc;
  --tgzw-text: #172235;
  --tgzw-muted: #647083;
  --tgzw-line: #e4d4bf;
  --tgzw-accent: #0c7a76;
  --tgzw-brand: #10233a;
  color-scheme: light;
}

/* System preference, unless the host pinned a theme with ?theme=light. */
@media (prefers-color-scheme: dark) {
  .tgzwDoc:not([data-theme="light"]) {
    --tgzw-bg: #0d1a22;
    --tgzw-surface: #132530;
    --tgzw-text: #f7efe3;
    --tgzw-muted: #b7c2c4;
    --tgzw-line: #29404b;
    --tgzw-accent: #71d7c2;
    --tgzw-brand: #f7efe3;
    color-scheme: dark;
  }
}

.tgzwDoc[data-theme="dark"] {
  --tgzw-bg: #0d1a22;
  --tgzw-surface: #132530;
  --tgzw-text: #f7efe3;
  --tgzw-muted: #b7c2c4;
  --tgzw-line: #29404b;
  --tgzw-accent: #71d7c2;
  --tgzw-brand: #f7efe3;
  color-scheme: dark;
}

.tgzwDoc,
.tgzwDoc body {
  margin: 0;
  padding: 0;
}

.tgzwDoc body {
  background: var(--tgzw-bg);
  color: var(--tgzw-text);
  font: 400 13px/1.35 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}

.tgzw {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 100vh;
  box-sizing: border-box;
  padding: 10px 11px;
}

.tgzw__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--tgzw-line);
  padding-bottom: 7px;
}

.tgzw__spot {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.tgzw__spot a {
  color: inherit;
  text-decoration: none;
}

.tgzw__spot a:hover,
.tgzw__spot a:focus-visible {
  text-decoration: underline;
}

.tgzw__kicker {
  flex: 0 0 auto;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tgzw-muted);
}

/* Stats read one metric per cell, label above value, aligned in columns. */
.tgzw__stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 10px;
  margin: 0;
}

.tgzw__stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.tgzw__label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--tgzw-muted);
}

.tgzw__value {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.tgzw__value--score {
  color: var(--tgzw-accent);
}

.tgzw__window {
  background: var(--tgzw-surface);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  align-items: baseline;
}

.tgzw__window b {
  font-weight: 700;
}

/* --tgzw-muted is tuned against --tgzw-bg; on the --tgzw-surface pill it lands
   under 4.5:1 at this size. Pull the label back toward the body colour so it
   stays secondary to the value without dropping below AA — the same fix
   css/deposit.bundle.css makes for this token pair on .tgzDeposit__facts dt. */
.tgzw__window .tgzw__label {
  color: color-mix(in srgb, var(--tgzw-text, #172235) 72%, var(--tgzw-muted, #647083));
}

.tgzw__foot {
  margin-top: auto;
  padding-top: 6px;
  border-top: 1px solid var(--tgzw-line);
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 10px;
  line-height: 1.3;
  color: var(--tgzw-muted);
}

.tgzw__foot a {
  color: inherit;
  text-decoration: underline;
}

/* The brand link sits in a footer line beside plain text. In dark the brand
   token IS the body colour, so weight was the only thing marking it as a link —
   which is not a distinguishing signal on its own. It carries a resting
   underline like every other link in this foot. */
.tgzw__brand {
  font-weight: 700;
  color: var(--tgzw-brand);
  text-decoration: underline;
}

.tgzw__brand:hover,
.tgzw__brand:focus-visible {
  text-decoration-thickness: 2px;
}

.tgzw__note {
  font-size: 11px;
  color: var(--tgzw-muted);
  margin: 0;
}

/* Arabic has no letter case and no tracking convention; the uppercase-label
   letter-spacing set above breaks the cursive joins between letters, which is a
   legibility failure rather than a style choice. Same for the builder's block
   titles on /ar/widget/. */
[dir="rtl"] .tgzw__kicker,
[dir="rtl"] .tgzw__label,
[dir="rtl"] .tgzwb__blockTitle {
  letter-spacing: normal;
}

/* A 320px-wide frame is the narrowest we promise; below ~260 the two-column
   stat grid stops being readable, so it becomes one column. */
@media (max-width: 259px) {
  .tgzw__stats { grid-template-columns: minmax(0, 1fr); }
  .tgzw__head { flex-direction: column; align-items: flex-start; gap: 2px; }
}

@media (prefers-reduced-motion: no-preference) {
  .tgzw__brand,
  .tgzw__spot a { transition: color 120ms cubic-bezier(.2,.8,.2,1); }
}

/* ========================================================= snippet builder == */

.tgzwb {
  display: flex;
  flex-direction: column;
  gap: var(--tgz-ui-space-lg, 20px);
}

.tgzwb__lead {
  margin: 0;
  max-width: 62ch;
  color: var(--tgz-ui-muted);
  font-size: 0.98rem;
  line-height: 1.55;
}

.tgzwb__block {
  display: flex;
  flex-direction: column;
  gap: var(--tgz-ui-space-sm, 10px);
  border-top: 1px solid var(--tgz-ui-line);
  padding-top: var(--tgz-ui-space-md, 14px);
}

.tgzwb__blockTitle {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tgz-ui-muted);
}

/* Controls stack on a phone and sit in a row from the tablet width up. */
.tgzwb__controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--tgz-ui-space-sm, 10px);
}

.tgzwb__field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.tgzwb__field > span {
  font-size: 0.78rem;
  font-weight: 650;
  color: var(--tgz-ui-muted);
}

.tgzwb__field select {
  width: 100%;
  box-sizing: border-box;
  min-height: var(--tgz-ui-control-min, 44px);
  padding: 8px 10px;
  border: 1px solid var(--tgz-ui-line);
  border-radius: var(--tgz-ui-radius-sm, 12px);
  background: var(--tgz-ui-card);
  color: var(--tgz-ui-text);
  font: 600 0.9rem/1.2 Inter, system-ui, sans-serif;
}

.tgzwb__field select:focus-visible {
  outline: 2px solid var(--tgz-ui-focus);
  outline-offset: 1px;
}

.tgzwb__preview {
  display: flex;
  flex-direction: column;
  gap: var(--tgz-ui-space-sm, 10px);
}

.tgzwb__frame {
  width: 100%;
  max-width: 320px;
  height: 260px;
  border: 1px solid var(--tgz-ui-line);
  border-radius: var(--tgz-ui-radius-sm, 12px);
  background: var(--tgz-ui-card);
}

.tgzwb__badge {
  display: block;
  width: 100%;
  max-width: 420px;
  height: auto;
  border: 1px solid var(--tgz-ui-line);
  border-radius: var(--tgz-ui-radius-sm, 12px);
}

/* The attribution pair the snippet places outside the frame. It is shown here at
   full size on purpose: it is the part that must survive a copy-paste. */
.tgzwb__attrib {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--tgz-ui-text);
}

/* The snippet is HTML the host pastes verbatim. On /ar/widget/ the page
   direction is rtl, which reorders the neutral characters that make up almost
   all of that markup — the reader sees `>"lmth.xedni/"=ferh a<` shaped output
   and cannot check what they are about to paste. The box is pinned ltr and
   isolated from the surrounding paragraph direction. */
.tgzwb__code {
  direction: ltr;
  text-align: left;
  unicode-bidi: isolate;
  width: 100%;
  box-sizing: border-box;
  min-height: 132px;
  resize: vertical;
  padding: 10px 12px;
  border: 1px solid var(--tgz-ui-line);
  border-radius: var(--tgz-ui-radius-sm, 12px);
  background: var(--tgz-ui-surface-alt);
  color: var(--tgz-ui-text);
  font: 400 0.78rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
}

.tgzwb__code:focus-visible {
  outline: 2px solid var(--tgz-ui-focus);
  outline-offset: 1px;
}

.tgzwb__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--tgz-ui-space-xs, 6px);
  align-items: center;
}

.tgzwb__copy {
  appearance: none;
  min-height: var(--tgz-ui-control-min, 44px);
  padding: 8px 16px;
  border: 1px solid var(--tgz-ui-line-strong);
  border-radius: var(--tgz-ui-radius-pill, 999px);
  background: var(--tgz-ui-primary);
  color: var(--tgz-ui-primary-text);
  font: 700 0.85rem/1.1 Inter, system-ui, sans-serif;
  cursor: pointer;
}

.tgzwb__copy:hover,
.tgzwb__copy:focus-visible {
  background: var(--tgz-ui-primary-hover);
  outline: none;
}

.tgzwb__copy:focus-visible {
  outline: 2px solid var(--tgz-ui-focus);
  outline-offset: 2px;
}

.tgzwb__status {
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--tgz-ui-success);
}

/* One item per line, aligned columns — the rules list and the spot table. */
.tgzwb__rules {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
}

.tgzwb__rules li {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px;
  padding: 8px 0;
  border-bottom: 1px solid var(--tgz-ui-line);
  font-size: 0.9rem;
  line-height: 1.45;
}

.tgzwb__rules li:last-child {
  border-bottom: 0;
}

.tgzwb__rules b {
  font-weight: 700;
}

@media (min-width: 560px) {
  .tgzwb__controls { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tgzwb__rules li { grid-template-columns: minmax(9rem, 15rem) minmax(0, 1fr); gap: 4px 16px; }
}

@media (min-width: 860px) {
  .tgzwb__preview { flex-direction: row; align-items: flex-start; gap: var(--tgz-ui-space-lg, 20px); }
  .tgzwb__previewPane { flex: 0 0 320px; }
  .tgzwb__previewNotes { flex: 1 1 auto; min-width: 0; }
}
