/* ==========================================================================
   AMSI Compare Table — Frontend Styles
   Version: 1.0.6  |  Proper mobile scroll fix
   ========================================================================== */

/* ─── Design Tokens ──────────────────────────────────────────────────────── */
:root {
	--amsi-pink-bg:     #FDEEF0;
	--amsi-pink-border: #F5D2D7;
	--amsi-coral:       #E8516A;
	--amsi-teal:        #009B74;
	--amsi-mint:        #E5F7F1;
	--amsi-mint-alt:    #D8F3EB;
	--amsi-white:       #FFFFFF;
	--amsi-divider:     #E8E8E8;
	--amsi-text:        #3D3D3D;
	--amsi-radius:      16px;
}

/* ─── Outer shell ────────────────────────────────────────────────────────── */
.amsi-ct-outer {
	width: 100%;
	box-sizing: border-box;
}

/*
 * .amsi-ct-card — visual card (border, radius, background)
 *
 * KEY: overflow:hidden here clips the table corners at the border-radius.
 *      It does NOT block child scrolling — overflow:auto on a child element
 *      still creates a working scroll container within the clipped area.
 *      This is the standard browser-compatible pattern for scrollable tables
 *      inside rounded cards.
 */
.amsi-ct-card {
	width: 100%;
	background-color: var(--amsi-pink-bg);
	border: 1px solid var(--amsi-pink-border);
	border-radius: var(--amsi-radius);
	overflow: hidden;       /* clips corners — does NOT block child scroll */
	box-sizing: border-box;
	position: relative;
}

/*
 * .amsi-ct-scroll — scroll container (independent of card styling)
 * Scrolls horizontally when .amsi-ct--scrollable class is applied.
 */
.amsi-ct-scroll {
	width: 100%;
	position: relative;
}

.amsi-ct--scrollable {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch; /* iOS momentum scrolling */
	scrollbar-width: thin;
	scrollbar-color: var(--amsi-teal) var(--amsi-mint);
}

/* Styled scrollbar (Webkit) */
.amsi-ct--scrollable::-webkit-scrollbar        { height: 4px; }
.amsi-ct--scrollable::-webkit-scrollbar-track  { background: var(--amsi-mint); }
.amsi-ct--scrollable::-webkit-scrollbar-thumb  { background: var(--amsi-teal); border-radius: 2px; }

/* Fade hint on the right edge when content overflows */
.amsi-ct--scrollable::after {
	content: '';
	position: sticky;
	right: 0;
	top: 0;
	display: block;
	width: 40px;
	height: 100%;
	background: linear-gradient(to right, transparent, rgba(255,255,255,.75));
	pointer-events: none;
	float: right;
	margin-top: -100%;  /* overlay trick */
}

/* ─── Table
 *
 * min-width: 530px ensures the table NEVER squishes below this threshold.
 * When the viewport is narrower, .amsi-ct--scrollable scrolls horizontally.
 * Adjust min-width if you add many competitor columns.
 * ─────────────────────────────────────────────────────────────────────────── */
.amsi-ct-table {
	width: 100%;
	border-collapse: collapse;
	border-spacing: 0;
	table-layout: fixed;
	border: none;
	min-width: 530px;
}

/* ─── Column widths (Figma proportions) ──────────────────────────────────── */
.amsi-ct-header-cell--features,
.amsi-ct-cell--features   { width: 36%; }

.amsi-ct-header-cell--featured,
.amsi-ct-cell--featured   { width: 20%; }

/* Remaining ~44% split equally among competitor columns */
.amsi-ct-header-cell--competitor,
.amsi-ct-cell--competitor { width: auto; }

/* ─── Header cells ───────────────────────────────────────────────────────── */
.amsi-ct-header-cell {
	padding: 20px 16px;
	text-align: center;
	font-size: 1rem;
	font-weight: 700;
	vertical-align: middle;
	box-sizing: border-box;
	border: none;
	border-bottom: 1px solid var(--amsi-divider);
	white-space: nowrap;
}

.amsi-ct-header-cell--features {
	text-align: left;
	background-color: var(--amsi-pink-bg);
	color: var(--amsi-coral);
	font-weight: 700;
	letter-spacing: 0.01em;
	padding-left: 24px;
	white-space: normal;
}

.amsi-ct-header-cell--featured {
	background-color: var(--amsi-teal);
	color: var(--amsi-white);
	border-left:   2px solid var(--amsi-teal);
	border-right:  2px solid var(--amsi-teal);
	border-bottom: 1px solid var(--amsi-teal);
	white-space: normal;
}

.amsi-ct-header-cell--competitor {
	background-color: var(--amsi-pink-bg);
	color: var(--amsi-coral);
	font-weight: 700;
}

/* ─── Brand block ────────────────────────────────────────────────────────── */
.amsi-ct-brand-wrap {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
}

.amsi-ct-brand-logo {
	max-width: 72px;
	max-height: 52px;
	width: auto;
	height: auto;
	object-fit: contain;
	filter: brightness(0) invert(1);
}

.amsi-ct-brand-name {
	display: block;
	font-size: 0.95rem;
	font-weight: 700;
	line-height: 1.25;
	color: var(--amsi-white);
}

.amsi-ct-comp-logo {
	display: block;
	max-width: 56px;
	max-height: 34px;
	width: auto;
	height: auto;
	margin: 0 auto 4px;
	object-fit: contain;
}

/* ─── Body cells ─────────────────────────────────────────────────────────── */
.amsi-ct-row:last-child .amsi-ct-cell { border-bottom: none; }

.amsi-ct-cell {
	padding: 18px 16px;
	text-align: center;
	vertical-align: middle;
	box-sizing: border-box;
	border: none;
	border-bottom: 1px solid var(--amsi-divider);
	transition: background-color 0.18s ease;
}

.amsi-ct-cell--features {
	text-align: left;
	background-color: var(--amsi-white);
	padding-left: 24px;
}

.amsi-ct-feature-label {
	display: block;
	font-size: 0.90rem;
	font-weight: 400;
	color: var(--amsi-text);
	line-height: 1.5;
	white-space: normal;
	word-break: break-word;
	overflow-wrap: break-word;
}

.amsi-ct-cell--featured {
	background-color: var(--amsi-mint);
	border-left:   2px solid var(--amsi-teal);
	border-right:  2px solid var(--amsi-teal);
	border-bottom: 1px solid var(--amsi-divider);
}
.amsi-ct-row:nth-child(even) .amsi-ct-cell--featured { background-color: var(--amsi-mint-alt); }
.amsi-ct-row:last-child      .amsi-ct-cell--featured  { border-bottom: 2px solid var(--amsi-teal); }

.amsi-ct-cell--competitor { background-color: var(--amsi-white); }

/* ─── Row hover ──────────────────────────────────────────────────────────── */
.amsi-ct-row:hover .amsi-ct-cell--features   { background-color: #F9F9F9; }
.amsi-ct-row:hover .amsi-ct-cell--competitor { background-color: #FDF5F6; }
.amsi-ct-row:hover .amsi-ct-cell--featured   { background-color: #C8EDE2; }
.amsi-ct-row:hover .amsi-ct-icon             { transform: scale(1.12); }

/* ─── Icons ──────────────────────────────────────────────────────────────── */
.amsi-ct-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 22px;
	height: 22px;
	font-size: 22px;
	line-height: 1;
	transition: transform 0.2s ease;
}
.amsi-ct-icon svg         { width: 1em; height: 1em; display: block; flex-shrink: 0; }
.amsi-ct-icon i           { font-size: inherit; line-height: 1; }
.amsi-ct-icon--img        { width: auto; height: auto; }
.amsi-ct-icon--img img    { width: 22px; height: 22px; object-fit: contain; display: block; }

/* Check teal */
.amsi-ct-cell--featured   .amsi-ct-icon--check,
.amsi-ct-cell--competitor .amsi-ct-icon--check          { color: var(--amsi-teal); }
.amsi-ct-cell--featured   .amsi-ct-icon--check svg path,
.amsi-ct-cell--competitor .amsi-ct-icon--check svg path { stroke: var(--amsi-teal); }

/* Cross coral */
.amsi-ct-cell--featured   .amsi-ct-icon--cross,
.amsi-ct-cell--competitor .amsi-ct-icon--cross          { color: var(--amsi-coral); }
.amsi-ct-cell--featured   .amsi-ct-icon--cross svg path,
.amsi-ct-cell--competitor .amsi-ct-icon--cross svg path { stroke: var(--amsi-coral); }

/* ─── Custom text ────────────────────────────────────────────────────────── */
.amsi-ct-custom-text { font-size: 0.875rem; font-weight: 600; }

/* ─── Accessibility ──────────────────────────────────────────────────────── */
.amsi-ct-table:focus { outline: 2px solid var(--amsi-teal); outline-offset: 2px; }

/* =========================================================================
   RESPONSIVE
   The table has min-width: 530px.
   .amsi-ct-card has overflow:hidden (clips rounded corners).
   .amsi-ct--scrollable scrolls within the clipped card — this works correctly
   in all browsers because overflow:hidden on a parent does NOT block
   overflow:auto on a child.
   ========================================================================= */

@media screen and (max-width: 1024px) {
	.amsi-ct-header-cell, .amsi-ct-cell { padding: 15px 12px; }
	.amsi-ct-header-cell--features,
	.amsi-ct-cell--features             { padding-left: 18px; }
}

@media screen and (max-width: 768px) {
	.amsi-ct-header-cell, .amsi-ct-cell { padding: 12px 10px; font-size: 0.82rem; }
	.amsi-ct-header-cell--features,
	.amsi-ct-cell--features             { padding-left: 14px; }
	.amsi-ct-feature-label              { font-size: 0.82rem; }
	.amsi-ct-brand-logo                 { max-width: 50px; max-height: 36px; }
	.amsi-ct-brand-name                 { font-size: 0.80rem; }
	.amsi-ct-icon                       { width: 18px; height: 18px; font-size: 18px; }
	.amsi-ct-icon--img img              { width: 18px; height: 18px; }
}

@media screen and (max-width: 480px) {
	.amsi-ct-header-cell, .amsi-ct-cell { padding: 10px 7px; font-size: 0.76rem; }
	.amsi-ct-header-cell--features,
	.amsi-ct-cell--features             { padding-left: 10px; }
	.amsi-ct-feature-label              { font-size: 0.76rem; }
	.amsi-ct-brand-logo                 { max-width: 38px; max-height: 28px; }
	.amsi-ct-brand-name                 { font-size: 0.70rem; }
	.amsi-ct-icon                       { width: 15px; height: 15px; font-size: 15px; }
	.amsi-ct-icon--img img              { width: 15px; height: 15px; }
}
