/**
 * World Info — front end styles.
 * Every colour comes from a custom property set on .wi-root, so the
 * Appearance settings can change the look without touching this file.
 */

.wi-root {
	position: relative;
	display: inline-block;
	max-width: 100%;
	font-size: 14px;
	line-height: 1.5;
	text-align: left;
}

.wi-align-center { display: block; text-align: center; }
.wi-align-right  { display: block; text-align: right; }

/* ---------- the chip ---------- */

.wi-chip {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	margin: 0;
	padding: 8px 14px;
	border: 0;
	border-radius: var(--wi-chip-radius, 999px);
	background: var(--wi-accent, #0f6e6a);
	color: #fff;
	font: inherit;
	font-size: 13.5px;
	font-weight: 600;
	line-height: 1.2;
	cursor: pointer;
	box-shadow: 0 2px 8px rgba(16, 24, 40, .18);
	-webkit-appearance: none;
	appearance: none;
}

.wi-chip:hover  { filter: brightness(1.07); }
.wi-chip:focus-visible { outline: 2px solid var(--wi-accent, #0f6e6a); outline-offset: 3px; }

.wi-chip-dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: rgba(255, 255, 255, .75);
	flex: none;
}

.wi-root.is-open .wi-chip-dot { background: #fff; }

/* ---------- the panel ---------- */

.wi-panel {
	position: absolute;
	z-index: 9999;
	top: calc(100% + 10px);
	left: 0;
	width: var(--wi-width, 330px);
	max-width: calc(100vw - 24px);
	background-color: var(--wi-panel-bg, #fff);
	background-image: var(--wi-panel-image, none);
	background-size: cover;
	background-position: center;
	border: 1px solid var(--wi-line, #e3eaea);
	border-radius: var(--wi-radius, 14px);
	box-shadow: var(--wi-shadow, 0 18px 46px rgba(16, 24, 40, .18));
	color: var(--wi-text, #33414d);
	overflow: hidden;
	text-align: left;

	/* The weather tab is the tallest. Cap the frame and let the middle
	   section scroll, so a long list can never run off the screen. The
	   cap itself is set on the Appearance tab. */
	display: flex;
	flex-direction: column;
	max-height: var(--wi-max-height, 560px);
	max-height: min(82vh, var(--wi-max-height, 560px));
}

.wi-panel[hidden] { display: none; }

.wi-head,
.wi-tabs,
.wi-foot { flex: 0 0 auto; }

.wi-align-center .wi-panel { left: 50%; transform: translateX(-50%); }
.wi-align-right  .wi-panel { left: auto; right: 0; }

.wi-panel.wi-flip-up { top: auto; bottom: calc(100% + 10px); }

.wi-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 12px 14px;
	background: var(--wi-header-bg, #0f6e6a);
	color: var(--wi-header-text, #fff);
}

.wi-title { font-size: 14px; font-weight: 600; }

.wi-close {
	border: 0;
	background: none;
	color: inherit;
	opacity: .8;
	font-size: 15px;
	line-height: 1;
	padding: 2px 4px;
	cursor: pointer;
}
.wi-close:hover { opacity: 1; }

/*
 * Themes style buttons heavily, and a bolder weight on the chosen tab can
 * pull a different font file with different metrics, which pushed one tab
 * lower than the others. Centring each tab inside a box of its own removes
 * any dependence on text baselines, so the three always line up.
 */
.wi-tabs {
	display: flex;
	align-items: stretch;
	border-bottom: 1px solid var(--wi-line, #e3eaea);
	background: rgba(0, 0, 0, .015);
}

.wi-tab {
	flex: 1 1 0;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 40px;
	margin: 0;
	padding: 10px 4px;
	border: 0;
	border-bottom: 2px solid transparent;
	border-radius: 0;
	background: none;
	color: var(--wi-muted, #7b8798);
	font: inherit;
	font-size: 12.5px;
	line-height: 1.2;
	text-align: center;
	text-transform: none;
	letter-spacing: normal;
	vertical-align: middle;
	box-shadow: none;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
}

.wi-tab.is-on {
	color: var(--wi-headline, #0f2a2e);
	font-weight: 600;
	border-bottom-color: var(--wi-accent, #0f6e6a);
	background: var(--wi-panel-bg, #fff);
}

.wi-body {
	padding: 14px 16px 16px;
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	/* Momentum scrolling on iOS, and a scroll that stops at the ends
	   instead of dragging the page behind it. */
	-webkit-overflow-scrolling: touch;
	overscroll-behavior: contain;
}

.wi-loading,
.wi-empty {
	margin: 0;
	padding: 14px 0;
	color: var(--wi-muted, #7b8798);
	font-size: 13px;
	text-align: center;
}

.wi-foot {
	display: flex;
	justify-content: space-between;
	gap: 10px;
	padding: 8px 14px;
	border-top: 1px solid var(--wi-line, #e3eaea);
	background: rgba(0, 0, 0, .015);
	font-size: 10.5px;
	color: var(--wi-muted, #7b8798);
}

.wi-stale { color: #b06a1a; }

/* ---------- rows shared by the tabs ---------- */

.wi-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 7px 0;
	border-bottom: 1px solid var(--wi-line, #e3eaea);
}
.wi-row:last-child { border-bottom: 0; }

.wi-row-name { font-size: 13px; }
.wi-row-name small {
	display: block;
	font-size: 10.5px;
	letter-spacing: .02em;
	color: var(--wi-muted, #7b8798);
}

.wi-row-value {
	font-size: 14px;
	font-weight: 600;
	color: var(--wi-headline, #0f2a2e);
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}
.wi-row-value small {
	font-size: 11px;
	font-weight: 400;
	color: var(--wi-muted, #7b8798);
}

/* ---------- time ---------- */

.wi-home {
	padding: 2px 0 12px;
	margin-bottom: 10px;
	border-bottom: 1px dashed var(--wi-line, #e3eaea);
}

.wi-home-label {
	font-size: 12.5px;
	font-weight: 600;
	color: var(--wi-headline, #0f2a2e);
	margin-bottom: 3px;
}

.wi-home-time {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	flex-wrap: wrap;
}

.wi-clock {
	font-size: 34px;
	font-weight: 600;
	letter-spacing: -.02em;
	line-height: 1;
	color: var(--wi-headline, #0f2a2e);
	font-variant-numeric: tabular-nums;
}

.wi-home-meta { font-size: 12px; color: var(--wi-muted, #7b8798); padding-bottom: 3px; }

/* ---------- currency ---------- */

.wi-amount {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-bottom: 12px;
	padding: 8px 11px;
	border: 1px solid var(--wi-line, #e3eaea);
	border-radius: 9px;
	background: rgba(0, 0, 0, .02);
}

.wi-amount input {
	width: 90px;
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	color: var(--wi-headline, #0f2a2e);
	font: inherit;
	font-size: 17px;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
	box-shadow: none;
}
.wi-amount input:focus { outline: none; }
.wi-amount input[readonly] { cursor: default; }

.wi-amount-base {
	padding: 4px 9px;
	border-radius: 6px;
	background: var(--wi-accent, #0f6e6a);
	color: #fff;
	font-size: 12.5px;
	font-weight: 600;
}

.wi-amount-hint {
	margin-left: auto;
	font-size: 11px;
	color: var(--wi-muted, #7b8798);
}

/* ---------- weather ---------- */

.wi-place + .wi-place {
	margin-top: 14px;
	padding-top: 12px;
	border-top: 1px dashed var(--wi-line, #e3eaea);
}

.wi-now {
	display: flex;
	align-items: center;
	gap: 12px;
	padding-bottom: 12px;
	margin-bottom: 8px;
	border-bottom: 1px dashed var(--wi-line, #e3eaea);
}

.wi-now-temp {
	font-size: 32px;
	font-weight: 600;
	line-height: 1;
	letter-spacing: -.02em;
	color: var(--wi-headline, #0f2a2e);
	font-variant-numeric: tabular-nums;
}

.wi-now-where {
	margin-left: auto;
	text-align: right;
	font-size: 12.5px;
	font-weight: 600;
	color: var(--wi-headline, #0f2a2e);
}
.wi-now-where small {
	display: block;
	font-weight: 400;
	font-size: 11px;
	color: var(--wi-muted, #7b8798);
}

.wi-day {
	display: grid;
	grid-template-columns: 42px 24px 1fr auto;
	align-items: center;
	gap: 9px;
	padding: 7px 0;
	border-bottom: 1px solid var(--wi-line, #e3eaea);
}
.wi-day:last-child { border-bottom: 0; }

.wi-day-date { font-size: 11.5px; color: var(--wi-muted, #7b8798); }
.wi-day-date b {
	display: block;
	font-size: 12.5px;
	font-weight: 600;
	color: var(--wi-headline, #0f2a2e);
}

.wi-day-desc {
	font-size: 12px;
	color: var(--wi-muted, #7b8798);
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.wi-day-temp {
	font-size: 13px;
	font-weight: 600;
	color: var(--wi-headline, #0f2a2e);
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}
.wi-day-temp i { font-style: normal; font-weight: 400; color: var(--wi-muted, #7b8798); }

.wi-icon { display: block; width: 22px; height: 22px; }

.wi-admin-note {
	padding: 8px 12px;
	border-left: 3px solid #d8a13a;
	background: #fffaf0;
	color: #6b4f18;
	font-size: 13px;
}

/* ---------- the floating icon ---------- */

/*
 * A separate way in, on top of the button in the text. The icon stays on
 * screen while the visitor scrolls, and the frame opens beside it.
 */
.wi-root.wi-float {
	position: fixed;
	z-index: 99998;
	display: block;
	right: 16px;
}

/*
 * Centred with a negative margin rather than a transform on purpose. A
 * transform here would become the reference point for the frame inside it,
 * which would then measure itself against a 52px icon instead of the
 * screen. Half the icon height does the same job with no side effects.
 */
.wi-float-middle-right { top: 50%; margin-top: -26px; }
.wi-float-bottom-right { bottom: 20px; }
.wi-float-top-right    { top: 20px; }

.wi-float .wi-chip {
	width: 52px;
	height: 52px;
	padding: 0;
	border-radius: 50%;
	justify-content: center;
	box-shadow: 0 4px 14px rgba(16, 24, 40, .28);
}

.wi-float .wi-chip-dot { display: none; }
.wi-float .wi-chip-text { display: none; }

.wi-float-icon {
	width: 26px;
	height: 26px;
	display: block;
	flex: none;
}

/* The frame opens to the left of the icon, and keeps its own alignment. */
.wi-float .wi-panel {
	position: fixed;
	top: auto;
	left: auto;
	right: 80px;
	transform: none;
}

.wi-float-middle-right .wi-panel { top: 50%; transform: translateY(-50%); }
.wi-float-bottom-right .wi-panel { bottom: 20px; }
.wi-float-top-right .wi-panel    { top: 20px; }

.wi-float .wi-panel.wi-flip-up { top: auto; bottom: auto; }
.wi-float-middle-right .wi-panel.wi-flip-up { top: 50%; }

/*
 * On a phone the frame used to be pinned to the screen with position:fixed.
 * That broke in two ways: a tall weather list ran off the top with no way to
 * scroll it, and any themed wrapper using a CSS transform silently changes
 * what "fixed" is measured against. It now sits in the page like it does on
 * a laptop, narrowed to fit, and scrolls inside itself.
 */
@media (max-width: 480px) {
	.wi-panel {
		width: min( var(--wi-width, 330px), calc(100vw - 24px) );
		/* Whichever is smaller: your height setting, or most of the screen. */
		max-height: min(78vh, var(--wi-max-height, 560px));
		max-height: min(78dvh, 78vh, var(--wi-max-height, 560px));
	}
	/* Never let the frame hang off the right edge of a narrow screen. */
	.wi-root:not(.wi-align-right):not(.wi-align-center):not(.wi-float) .wi-panel {
		left: 0;
		right: auto;
		max-width: calc(100vw - 24px);
	}

	/* The floating icon shrinks, and its frame spans the screen instead of
	   trying to squeeze in beside it. */
	.wi-root.wi-float { right: 12px; }
	.wi-float-middle-right { margin-top: -23px; }
	.wi-float .wi-chip { width: 46px; height: 46px; }
	.wi-float-icon { width: 23px; height: 23px; }

	.wi-float .wi-panel {
		left: 12px;
		right: 12px;
		width: auto;
		max-width: none;
	}
	.wi-float-bottom-right .wi-panel { bottom: 78px; }
	.wi-float-top-right .wi-panel    { top: 78px; }
}
