/* ==========================================================================
   Cyber Defense Genius — phone & tablet layer (Innovation Matrix 1.4.53)
   Loaded after the theme's main.css on every front-end page. Desktop is untouched: every rule
   here lives inside a max-width media query except the few safety rules at the top, which only
   stop long words/URLs from pushing a page wider than the screen.
   ========================================================================== */

/* ---- Safety: nothing may make the page wider than the phone -------------------------------- */
.cdi-main h1, .cdi-main h2, .cdi-main h3, .cdi-main p, .cdi-main li, .cdi-main dd, .cdi-main td, .cdi-main a { overflow-wrap: break-word; }
.cdi-main dd, .cdi-main dt { min-width: 0; }
.cdi-main img, .cdi-main video, .cdi-main iframe, .cdi-main canvas, .cdi-main svg { max-width: 100%; }
.cdi-main canvas { height: auto; }

/* ---- Tablets and below ---------------------------------------------------------------------- */
@media (max-width: 900px) {
	/* CISO Portal review form: fixed 320px column + content column never stacked, which made the
	   whole portal twice as wide as a phone. */
	.cdi-portal-grid { grid-template-columns: 1fr; gap: 24px; }
	.cdi-portal-grid > * { min-width: 0; }
}

/* ---- Phones ---------------------------------------------------------------------------------- */
@media (max-width: 720px) {
	/* Header: finger-sized menu and search buttons */
	.cdi-nav-toggle { min-width: 44px; min-height: 44px; align-items: center; justify-content: center; padding: 10px; }
	.cdi-search-toggle, #cdi-theme-toggle, .cdi-theme-toggle { min-width: 44px; min-height: 44px; }
	.cdi-mobile-nav .cdi-nav-list-mobile a { min-height: 48px; display: flex; align-items: center; }
	.cdi-mobile-nav .cdi-nav-cta { justify-content: center; margin-top: 8px; border-radius: 999px; }

	/* Forms: 16px text stops iPhone from zooming in on every field; 44px tall targets */
	.cdi-main input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="hidden"]):not([type="submit"]):not([type="button"]),
	.cdi-main select,
	.cdi-main textarea,
	.cdi-quick-search-form input[type="search"] { font-size: 16px; min-height: 44px; max-width: 100%; box-sizing: border-box; }
	.cdi-main button, .cdi-main input[type="submit"], .cdi-main input[type="button"] { min-height: 44px; }
	.cdi-main .cdi-linklike { min-height: 0; padding: 6px 0; }

	/* Small text links that act as buttons ("View All →", "See all →", "Source") */
	.cdi-main a.cdi-link { display: inline-flex; align-items: center; min-height: 40px; }
	.cdi-hero-portal-link, .cdi-profile-portal-link { display: inline-flex; align-items: center; min-height: 44px; }

	/* Share buttons */
	.cdi-share-btn { min-height: 40px; padding: 8px 14px; font-size: 0.85rem; }
	.cdi-share-x, .cdi-share-facebook { min-width: 40px; justify-content: center; }
	.cdi-share-row-compact .cdi-share-btn { padding: 8px 12px; font-size: 0.8rem; }

	/* CISO Portal "Your Requests": long status text wrapped off-screen (white-space: nowrap) */
	.cdi-request-row { align-items: flex-start; }
	.cdi-request-row > * { min-width: 0; }
	.cdi-request-status { white-space: normal; flex: 1 1 100%; }

	/* Innovator / admin portal company-preview form */
	.cdi-admin-preview-form { align-items: stretch; }
	.cdi-admin-preview-form > *, .cdi-admin-preview-form .cdi-claim-company-field { min-width: 0; width: 100%; flex: 1 1 100%; }
	.cdi-admin-preview-form label { white-space: normal; }

	/* Investor fact lists: label column could force the card wider than the phone */
	.cdi-inv-facts { grid-template-columns: minmax(0, max-content) minmax(0, 1fr); }
	.cdi-inv-hub { grid-template-columns: 1fr; }
	.cdi-inv-hub-card li span { float: none; display: block; }

	/* Footer legal links */
	.cdi-footer-legal a, .cdi-footer-legal .cdi-linklike { display: inline-flex; align-items: center; min-height: 40px; }

	/* Methodology dimensions table: let the description wrap instead of widening the page */
	.cdi-methodology-table { table-layout: fixed; }
	.cdi-methodology-table th, .cdi-methodology-table td { white-space: normal; padding: 10px 8px; vertical-align: top; }
	.cdi-methodology-table th:first-child, .cdi-methodology-table td:first-child { width: 38%; font-weight: 700; }
}

/* ---- Phones: wide data tables become cards ------------------------------------------------- */
/* Deal Tracker, VC & Funding Activity and the investor rankings were 7–8 column tables: on a phone
   only Date + Company were visible and everything else needed sideways scrolling. Each row now
   becomes a card; labels come from the table header (data-label, added by cdi-mobile.js). */
@media (max-width: 640px) {
	.cdi-table-scroll:has(> .cdi-deals-table), .cdi-table-scroll:has(> .cdi-inv-table) { overflow: visible; }
	.cdi-deals-table, .cdi-inv-table,
	.cdi-deals-table tbody, .cdi-inv-table tbody { display: block; width: 100%; }
	.cdi-deals-table thead, .cdi-inv-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
	.cdi-deals-table tbody tr, .cdi-inv-table tbody tr {
		display: grid;
		grid-template-columns: 1fr 1fr;
		gap: 10px 14px;
		padding: 14px 16px;
		margin: 0 0 10px;
		background: var(--cdi-surface) !important;
		border: 1px solid var(--cdi-border);
		border-radius: 12px;
	}
	.cdi-deals-table td, .cdi-inv-table td { display: block; padding: 0; border: 0; white-space: normal; min-width: 0; font-size: 0.92rem; }
	.cdi-deals-table td[data-label]::before, .cdi-inv-table td[data-label]::before {
		content: attr(data-label);
		display: block;
		margin-bottom: 2px;
		font-size: 0.75rem;
		font-weight: 700;
		letter-spacing: 0.04em;
		text-transform: uppercase;
		color: var(--cdi-text-muted);
	}
	/* Company / firm name leads the card, full width, no label */
	.cdi-deals-table td.cdi-table-name-cell, .cdi-inv-table td.cdi-table-name-cell { grid-column: 1 / -1; order: -1; font-size: 1.05rem; font-weight: 700; }
	.cdi-deals-table td.cdi-table-name-cell::before, .cdi-inv-table td.cdi-table-name-cell::before { display: none; }
	/* Unlabelled cells (e.g. the "Source" link) span the card */
	.cdi-deals-table td:not([data-label]), .cdi-inv-table td:not([data-label]) { grid-column: 1 / -1; }
	/* The theme hides every table's 3rd column on phones (meant for the company list); in card
	   form there's room, and that column is the Acquirer / Score, so bring it back. */
	.cdi-deals-table td:nth-child(3), .cdi-inv-table td:nth-child(3) { display: block; }
	.cdi-deals-table td:empty, .cdi-inv-table td:empty { display: none; }
	.cdi-deal-entity { display: inline-flex; align-items: center; gap: 8px; }
}

/* ---- Phones: final touches --------------------------------------------------------------- */
@media (max-width: 720px) {
	/* CISO Portal company search: the results dropdown was absolutely positioned relative to a wider
	   ancestor and ran off the right edge. Flow it under the search box instead. */
	#cdi-portal-company-results.cdi-compare-results { position: static; width: 100%; max-width: 100%; }
	.cdi-compare-result { min-height: 44px; }
	/* Card names and category pills: finger-sized */
	.cdi-deals-table td.cdi-table-name-cell a, .cdi-inv-table td.cdi-table-name-cell a { display: inline-flex; align-items: center; min-height: 36px; }
	.cdi-main a.cdi-pill { display: inline-flex; align-items: center; min-height: 36px; padding: 6px 14px; }
	/* Investor stat labels were 10.5px */
	.cdi-inv-stats span { font-size: 0.75rem; }
}

/* ---- Company profile header on phones ---------------------------------------------------- */
@media (max-width: 560px) {
	/* Logo sat in its own column and squeezed the name/description into ~250px. Stack it. */
	.cdi-profile-identity { flex-direction: column; align-items: flex-start; gap: 12px; }
	.cdi-profile-identity > * { min-width: 0; max-width: 100%; }
	.cdi-profile-logo { width: 64px; height: 64px; }
	.cdi-profile-header .cdi-score-badge { width: 100%; box-sizing: border-box; }
	.cdi-profile-actions { display: flex; flex-wrap: wrap; gap: 10px; }
	.cdi-profile-actions > * { flex: 1 1 auto; justify-content: center; text-align: center; }
}

/* ---- Small phones ---------------------------------------------------------------------------- */
@media (max-width: 380px) {
	.cdi-container { padding-left: 16px; padding-right: 16px; }
	.cdi-deals-table tbody tr, .cdi-inv-table tbody tr { padding: 12px; gap: 8px 10px; }
}
