/* Drive Image Search — styles (v3.1.0)
 * Version: 3.1.0
 * Themeable via CSS variables; override these in your child theme if needed.
 */
.dis-wrap {
	--dis-accent: #1a4f8b;
	--dis-accent-fg: #ffffff;
	--dis-fg: #1f2329;
	--dis-muted: #4a5568;
	--dis-border: #c8ccd2;
	--dis-bg: #ffffff;
	--dis-card-bg: #f5f8fb;
	--dis-radius: 10px;
	--dis-focus: #0b63ce;

	color: var(--dis-fg);
	max-width: 1100px;
	margin: 0 auto;

	/* NEW: consistent sizing + type baseline regardless of theme */
	box-sizing: border-box;
	font-size: 16px;
	line-height: 1.5;
	overflow-wrap: break-word; /* long names/URLs can never blow out layout */
}
.dis-wrap *,
.dis-wrap *::before,
.dis-wrap *::after {
	box-sizing: inherit; /* NEW: theme box-sizing quirks stay out */
}

/* NEW: neutralize theme button/input styling inside the widget */
.dis-wrap button {
	font: inherit;
	text-transform: none;
	letter-spacing: normal;
	box-shadow: none;
}
.dis-wrap input[type="search"] {
	font: inherit;
	box-shadow: none;
	-webkit-appearance: none;
	appearance: none;
}
.dis-wrap input[type="search"]::-webkit-search-cancel-button {
	-webkit-appearance: none; /* we have our own clear button */
}

/* NEW: hidden must always win, even against display:flex/grid rules */
.dis-wrap [hidden] { display: none !important; }

.dis-sr-only {
	position: absolute !important;
	width: 1px; height: 1px;
	padding: 0; margin: -1px;
	overflow: hidden; clip: rect(0 0 0 0);
	white-space: nowrap; border: 0;
}

/* ---- Search bar ---- */
.dis-title {
	margin: 0 0 .75rem;
	font-size: 1.5rem;
	line-height: 1.25; /* NEW: themes often set huge heading line-height */
}

.dis-search-inner {
	display: flex;
	align-items: center;
	gap: .5rem;
	border: 1px solid var(--dis-border);
	border-radius: var(--dis-radius);
	padding: .5rem .75rem;
	background: var(--dis-bg);
}
.dis-search-inner:focus-within {
	outline: 2px solid var(--dis-focus);
	outline-offset: 1px;
}
.dis-search-icon { color: var(--dis-muted); flex: 0 0 auto; }
.dis-search-input {
	flex: 1 1 auto;
	min-width: 0;           /* NEW: lets the input shrink on small screens */
	border: 0 !important;   /* NEW: !important beats theme input borders */
	font-size: 1rem;
	padding: .35rem .25rem;
	margin: 0;              /* NEW */
	background: transparent;
	color: var(--dis-fg);
	min-height: 24px;
}
.dis-search-input:focus {
	outline: none;
	box-shadow: none; /* NEW: themes often add focus glows on inputs */
}

.dis-clear-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 32px;
	min-height: 32px;
	padding: 0;      /* NEW */
	border: 0;
	border-radius: 6px;
	background: transparent;
	color: var(--dis-muted);
	cursor: pointer;
}
.dis-clear-btn:hover { color: var(--dis-fg); background: var(--dis-card-bg); }

.dis-search-tips {
	font-size: .8rem;
	color: var(--dis-muted);
	margin-top: .4rem;
}
.dis-search-tips code {
	background: var(--dis-card-bg);
	padding: 0 .25rem;
	border-radius: 4px;
	font-size: .8rem; /* NEW: theme code blocks can be oversized */
}

.dis-status-bar {
	font-size: .9rem;
	color: var(--dis-muted);
	margin: .75rem 0;
	min-height: 1.2em;
}

/* ---- Results grid ---- */
.dis-grid {
	display: grid;
	grid-template-columns: repeat( auto-fill, minmax( 160px, 1fr ) );
	gap: 1rem;
	margin: 0;      /* NEW: role="list" — themes may add list margins */
	padding: 0;     /* NEW */
	list-style: none; /* NEW */
}

.dis-card { display: grid; min-width: 0; height: 100%; } /* NEW min-width: grid children can't overflow */
.dis-card-btn {
	display: flex;
	flex-direction: column;
	width: 100%;
	min-width: 0;   /* NEW */
	padding: 0;
	border: 1px solid var(--dis-border);
	border-radius: var(--dis-radius);
	background: var(--dis-card-bg);
	color: var(--dis-fg);
	cursor: pointer;
	overflow: hidden;
	text-align: left;
}
.dis-card-btn:hover { border-color: var(--dis-accent); }
.dis-card-btn:focus-visible {
	outline: 3px solid var(--dis-focus);
	outline-offset: 2px;
}

.dis-card-img-wrap {
	display: block;
	width: 100%;    /* NEW */
	aspect-ratio: 1 / 1;
	background: var(--dis-border);
	overflow: hidden; /* NEW */
}
.dis-card-img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}
.dis-card-img.dis-img-error { opacity: .35; }

.dis-card-name {
	display: -webkit-box;            /* NEW: clamp long names to 2 lines */
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
	padding: .5rem .6rem;
	font-size: .9rem;
	line-height: 1.3;
	font-weight: 600;
	word-break: break-word;          /* NEW: unbroken strings still wrap */
}

/* ---- Load more (NEW: was completely unstyled) ---- */
.dis-load-more {
	display: block;
	margin: 1.5rem auto 0;
	padding: .6rem 1.5rem;
	border: 1px solid var(--dis-border);
	border-radius: var(--dis-radius);
	background: var(--dis-bg);
	color: var(--dis-accent);
	font-weight: 600;
	cursor: pointer;
}
.dis-load-more:hover { border-color: var(--dis-accent); background: var(--dis-card-bg); }
.dis-load-more:focus-visible { outline: 3px solid var(--dis-focus); outline-offset: 2px; }

/* ---- Empty state ---- */
.dis-empty {
	text-align: center;
	color: var(--dis-muted);
	padding: 2.5rem 1rem;
}
.dis-empty svg { color: var(--dis-border); }

/* ---- Lightbox ---- */
.dis-lightbox {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1rem;
}
.dis-lightbox[hidden] { display: none !important; } /* NEW: !important */
.dis-lightbox-backdrop {
	position: absolute;
	inset: 0;
	background: rgba( 0, 0, 0, .82 );
}
.dis-lightbox-inner {
	position: relative;
	z-index: 1;
	max-width: 1100px;
	width: 100%;
	max-height: 92vh;
	background: var(--dis-bg);
	border-radius: var(--dis-radius);
	overflow: hidden;
	display: flex;
	flex-direction: column;
}
.dis-lightbox-content {
	display: grid;
	grid-template-columns: minmax( 0, 2fr ) minmax( 220px, 1fr );
	gap: 0;
	overflow: auto;
	min-height: 0; /* NEW: lets the flex parent actually constrain height */
}
@media ( max-width: 700px ) {
	.dis-lightbox-content { grid-template-columns: 1fr; }
}
.dis-lightbox-img-wrap {
	display: flex;
	align-items: center;
	justify-content: center;
	background: #000;
	min-height: 240px;
	min-width: 0; /* NEW */
}
.dis-lightbox-img { max-width: 100%; max-height: 80vh; display: block; }

.dis-lightbox-meta {
	padding: 1.25rem;
	min-width: 0;                 /* NEW */
	overflow-wrap: break-word;    /* NEW: long names wrap in the sidebar too */
}
.dis-lightbox-name { margin: 0 0 .5rem; font-size: 1.2rem; line-height: 1.3; }
.dis-lightbox-desc { margin: 0 0 1rem; color: var(--dis-muted); }
.dis-lightbox-tags { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.dis-tag {
	font-size: .8rem;
	background: var(--dis-card-bg);
	border: 1px solid var(--dis-border);
	border-radius: 999px;
	padding: .15rem .6rem;
}
.dis-lightbox-link {
	display: inline-flex;
	align-items: center;
	gap: .35rem;
	color: var(--dis-accent);
	font-weight: 600;
	text-decoration: none;
}
.dis-lightbox-link:hover { text-decoration: underline; }

.dis-lightbox-close,
.dis-lightbox-prev,
.dis-lightbox-next {
	position: absolute;
	z-index: 2;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0; /* NEW */
	border: 0;
	border-radius: 50%;
	background: rgba( 0, 0, 0, .55 );
	color: #fff;
	cursor: pointer;
}
.dis-lightbox-close { top: .5rem; right: .5rem; }
.dis-lightbox-prev { top: 50%; left: .5rem; transform: translateY( -50% ); }
.dis-lightbox-next { top: 50%; right: .5rem; transform: translateY( -50% ); }
.dis-lightbox-close:hover,
.dis-lightbox-prev:hover,
.dis-lightbox-next:hover { background: rgba( 0, 0, 0, .8 ); }
.dis-lightbox-close:focus-visible,
.dis-lightbox-prev:focus-visible,
.dis-lightbox-next:focus-visible {
	outline: 3px solid #fff;
	outline-offset: 2px;
}
.dis-lightbox-prev[disabled],
.dis-lightbox-next[disabled] { opacity: .35; cursor: default; }

body.dis-lb-open { overflow: hidden; }

@media ( prefers-reduced-motion: reduce ) {
	.dis-wrap * { transition: none !important; animation: none !important; }
}