/* Companion Planter. Uses the design tokens in /assets/css/site.css; everything is scoped to the tool. */

.cp-intro { margin-top: 1.25rem; display: flex; flex-direction: column; align-items: flex-start; gap: .75rem; }
.cp-legend { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .5rem 1.4rem; font: 500 .92rem var(--font-display); color: var(--ink); }
.cp-legend li { display: flex; align-items: center; gap: .45rem; }
.cp-key { display: inline-block; width: 22px; height: 22px; border-radius: 6px; }
.cp-howto { max-width: 46rem; }
.cp-howto summary { cursor: pointer; font: 600 .95rem var(--font-display); color: var(--green); }
.cp-howto p { margin: .7rem 0 0; font-size: .96rem; }
.cp-star-dot { color: #E0A100; font-size: .95em; line-height: 1; }

.cp-tabs { display: inline-flex; gap: .25rem; padding: .3rem; border-radius: 999px; background: var(--paper-alt); border: 1.5px solid var(--line-soft); margin-bottom: 1.25rem; }
.cp-tabs [role="tab"] {
  border: 0; background: transparent; cursor: pointer; padding: .6rem 1.2rem; border-radius: 999px;
  font: 600 .98rem var(--font-display); color: var(--muted);
}
.cp-tabs [role="tab"][aria-selected="true"] { background: var(--green); color: #fff; }
.cp-error { padding: 1rem 1.2rem; border-radius: var(--r); background: var(--sun-soft); border: 1.5px solid var(--ink); color: var(--ink); }
.cp-loading .cp-panel { opacity: .4; }

/* Search comboboxes */
.cp-search { position: relative; max-width: 26rem; }
.cp-search label { display: block; font: 600 .9rem var(--font-display); color: var(--ink); margin-bottom: .4rem; }
.cp-search input {
  width: 100%; padding: .75rem 1rem; border-radius: 999px; border: 1.5px solid rgba(31, 59, 42, .3);
  background: #fff; color: var(--ink); font: 400 1rem var(--font-body);
}
.cp-search input:focus { outline: 3px solid var(--sky); outline-offset: 1px; border-color: var(--ink); }
.cp-options {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 6px); margin: 0; padding: .35rem; list-style: none;
  background: #fff; border: 1.5px solid var(--line-soft); border-radius: 16px; box-shadow: var(--shadow); max-height: 340px; overflow-y: auto;
}
.cp-options li { display: flex; align-items: center; gap: .6rem; padding: .4rem .6rem; border-radius: 10px; cursor: pointer; font: 500 .98rem var(--font-display); color: var(--ink); }
.cp-options li[aria-selected="true"], .cp-options li:hover { background: var(--leaf-pale); }
.cp-options .cp-opt-empty { cursor: default; color: var(--muted); }
.cp-noicon { display: inline-block; flex: none; border-radius: 8px; background: var(--leaf-pale) url("../../assets/images/leaf-outline.svg") center / 60% no-repeat; }

/* ---------------- Plan a bed ---------------- */
.cp-plan-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: clamp(1.25rem, 3vw, 2.5rem); align-items: start; }
@media (max-width: 900px) { .cp-plan-grid { grid-template-columns: 1fr; } }
.cp-picker { position: sticky; top: calc(var(--header-h) + 1rem); }
@media (max-width: 900px) { .cp-picker { position: static; } }
.cp-or { margin: 1rem 0 .6rem; font-size: .92rem; color: var(--muted); }
.cp-chips { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .4rem; max-height: 60vh; overflow-y: auto; padding-right: .25rem; }
@media (max-width: 900px) { .cp-chips { max-height: 17rem; } }
.cp-chip {
  display: inline-flex; align-items: center; gap: .4rem; padding: .3rem .8rem .3rem .35rem; border-radius: 999px; cursor: pointer;
  border: 1.5px solid var(--line-soft); background: var(--card); color: var(--ink); font: 500 .9rem var(--font-display);
  transition: border-color .15s, background-color .15s;
}
.cp-chip img, .cp-chip .cp-noicon { border-radius: 50%; background-color: var(--paper-alt); }
.cp-chip:hover { border-color: var(--ink); }
.cp-chip[aria-pressed="true"] { background: var(--leaf-soft); border-color: var(--ink); }
.cp-chip[aria-pressed="true"]::after { content: "✓"; font-weight: 700; color: var(--green); }

.cp-results-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }
.cp-results-head h2 { font-size: 1.5rem; margin: 0; }
.cp-empty { padding: 1.5rem; border-radius: var(--r-lg); border: 1.5px dashed var(--line-soft); color: var(--muted); background: var(--card); }
.cp-summary { margin: 0 0 1rem; padding: .8rem 1.1rem; border-radius: var(--r); background: var(--leaf-pale); color: var(--ink); font-family: var(--font-display); }
.cp-suggest { margin-bottom: 1.25rem; }
.cp-suggest h3 { font-size: 1.02rem; margin-bottom: .55rem; }
.cp-suggest ul { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .5rem; }
.cp-sg {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .55rem; width: 100%; padding: .45rem .7rem .45rem .45rem;
  border-radius: 14px; border: 1.5px solid var(--line-soft); background: var(--card); cursor: pointer; text-align: left; color: var(--ink);
}
.cp-sg:hover { border-color: var(--ink); }
.cp-sg img, .cp-sg .cp-noicon { border-radius: 50%; background-color: var(--paper-alt); }
.cp-sg strong { display: block; font: 600 .92rem var(--font-display); }
.cp-sg small { display: block; font-size: .78rem; color: var(--muted); line-height: 1.3; }
.cp-add { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--leaf-soft); font-weight: 700; color: var(--green); }
.cp-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.cp-card { background: var(--card); border: 1.5px solid var(--line-soft); border-radius: var(--r-lg); padding: 1rem 1.1rem 1.1rem; display: flex; flex-direction: column; gap: .7rem; }
.cp-card header { display: flex; align-items: center; gap: .65rem; }
.cp-card header h3 { flex: 1; margin: 0; font-size: 1.12rem; }
.cp-remove { width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid var(--line-soft); background: transparent; cursor: pointer; font-size: 1.1rem; line-height: 1; color: var(--muted); }
.cp-remove:hover { border-color: var(--ink); color: var(--ink); }
.cp-card-star { margin: 0; font-size: .92rem; color: var(--ink); }
.cp-pairs h4 { display: flex; align-items: center; gap: .35rem; font-size: .88rem; letter-spacing: .02em; margin-bottom: .4rem; }
.cp-pairs ul { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.cp-pairs li { display: flex; gap: .55rem; align-items: flex-start; }
.cp-pairs li div { display: flex; flex-direction: column; font-size: .9rem; }
.cp-pairs li strong { font-family: var(--font-display); font-weight: 600; color: var(--ink); }
.cp-pairs li span { color: var(--muted); font-size: .84rem; }
.cp-good h4 { color: var(--green); }
.cp-bad h4 { color: #B3261E; }
.cp-neutral { margin: 0; font-size: .85rem; color: var(--muted); }
.cp-more { align-self: flex-start; margin-top: auto; background: none; border: 0; padding: 0; cursor: pointer; font-size: .92rem; }
.cp-mark { width: 16px; height: 16px; flex: none; }

/* ---------------- Chart ---------------- */
/* The matrix breaks out past the page column, short of the window edges so the page can still be scrolled
   beside it (cqi = the section's width). --cp-bleed is its margin on each side. */
.tool-body { container-type: inline-size; }
.cp { --cp-gutter: 1rem; --cp-bleed: calc(60% - 50cqi + var(--cp-gutter)); --cp-panel-w: 460px; --cp-blue: #0B74AC; --cp-blue-pale: #E8F5FC; --cp-red: #B3261E; --cp-red-deep: #7A1712; --cp-red-soft: #F8D3CD; --cp-red-pale: #FDF1EE; }
@media (max-width: 600px) { .cp { --cp-gutter: .5rem; } }
.cp-chart-bar { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem 2rem; margin-bottom: 1rem; }
.cp-hint { margin: 0; font-size: .9rem; color: var(--muted); }
.cp-chart-scroll {
  /* position: relative keeps the cells' visually hidden labels inside the scroller, not widening the page. */
  position: relative; margin-inline: var(--cp-bleed);
  overflow: auto; max-height: calc(100vh - var(--header-h) - 2rem); min-height: min(70vh, 640px); border: 1.5px solid var(--line-soft); border-radius: var(--r-lg);
  background: #fff; overscroll-behavior: contain; cursor: grab; scroll-padding-top: 76px; transition: margin-right .3s var(--ease);
}
@media (min-width: 1100px) { .cp-docked .cp-chart-scroll { margin-right: calc(var(--cp-bleed) + var(--cp-panel-w)); } }
.cp-chart-scroll.cp-dragging { cursor: grabbing; user-select: none; }
.cp-table { border-collapse: separate; border-spacing: 0; font-size: .9rem; }
.cp-table th, .cp-table td { border-right: 1px solid rgba(31, 59, 42, .08); border-bottom: 1px solid rgba(31, 59, 42, .08); }
/* All-star plants are good near almost anything, so their whole column carries a sun tint. */
.cp-table .cp-allstar-col { background: #FFF9DF; }
.cp-table thead th { position: sticky; top: 0; z-index: 2; background: var(--paper); padding: .4rem .2rem; min-width: 60px; text-align: center; vertical-align: bottom; border-bottom: 1.5px solid var(--line-soft); }
.cp-table thead th img, .cp-table thead th .cp-noicon { display: block; margin: 0 auto; width: 52px; height: 52px; }
.cp-table thead th.cp-allstar { position: sticky; background: var(--sun-soft); }
.cp-table thead th .cp-star-dot { position: absolute; top: 3px; right: 5px; font-size: .8rem; }
.cp-table thead th.cp-colhover { background: var(--sky-soft); }
.cp-table tbody th { position: sticky; left: 0; z-index: 1; background: var(--paper); padding: 0; text-align: left; border-right: 1.5px solid var(--line-soft); }
.cp-table .cp-corner { left: 0; z-index: 3; text-align: left; vertical-align: bottom; font: 600 .74rem/1.3 var(--font-display); color: var(--muted); padding: .5rem .7rem; min-width: 170px; border-right: 1.5px solid var(--line-soft); }
.cp-table .cp-corner span { display: block; }
.cp-rowbtn {
  display: flex; align-items: center; gap: .5rem; width: 100%; min-width: 170px; padding: .3rem .7rem; border: 0; background: transparent;
  cursor: pointer; font: 500 .92rem var(--font-display); color: inherit; text-align: left; white-space: nowrap;
}
.cp-rowbtn:focus-visible { outline: 3px solid var(--sky); outline-offset: -3px; }
.cp-table tbody tr { cursor: pointer; }
.cp-table td { width: 60px; height: 40px; min-width: 60px; padding: 0; background-position: center; background-repeat: no-repeat; background-size: 18px; }
.cp-g, .cp-key.cp-g { background-color: #E4F4DC; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.2 4.2L19 7' fill='none' stroke='%23255F18' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.cp-b, .cp-key.cp-b { background-color: #FBE3DF; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6.5 6.5l11 11M17.5 6.5l-11 11' fill='none' stroke='%23B3261E' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E"); }
.cp-key { background-position: center; background-repeat: no-repeat; background-size: 14px; }
/* The shorthand resets the icon sizing above, so the hatch fills the whole cell. */
.cp-table td.cp-self { background: repeating-linear-gradient(45deg, var(--paper-alt) 0 4px, #E4DDCB 4px 6px); }
/* Crosshair: hovered row and column. */
.cp-table tbody tr:hover td { box-shadow: inset 0 0 0 999px rgba(49, 175, 242, .07); }
.cp-table tbody tr:hover th { background: var(--sky-soft); }
.cp-table .cp-colhover { box-shadow: inset 0 0 0 999px rgba(49, 175, 242, .09); }
.cp-table tbody tr:hover td.cp-colhover { box-shadow: inset 0 0 0 999px rgba(49, 175, 242, .18); }
/* The row whose details are open. */
.cp-table tr.cp-row-open th { background: var(--cp-blue); color: #fff; }
.cp-table tbody tr.cp-row-open:hover th { color: var(--ink); }
.cp-table tr.cp-row-open td { box-shadow: inset 0 0 0 999px rgba(11, 116, 172, .1); }
.cp-table tr.cp-row-flash th, .cp-table tr.cp-row-flash td { animation: cp-flash 1.6s var(--ease); }
@keyframes cp-flash { 0%, 60% { box-shadow: inset 0 0 0 999px rgba(255, 199, 0, .35); } 100% { box-shadow: none; } }
@media (max-width: 600px) {
  .cp-table thead th { min-width: 46px; padding: .3rem .15rem; }
  .cp-table thead th img, .cp-table thead th .cp-noicon { width: 36px; height: 36px; }
  .cp-table td { width: 46px; min-width: 46px; height: 44px; }
  .cp-table .cp-corner { min-width: 118px; padding: .4rem .5rem; }
  .cp-rowbtn { min-width: 118px; max-width: 118px; padding: .25rem .5rem; gap: .35rem; font-size: .82rem; line-height: 1.15; white-space: normal; }
  .cp-rowbtn img, .cp-rowbtn .cp-noicon { width: 22px; height: 22px; flex: none; }
}
.cp-tip {
  position: fixed; z-index: 60; pointer-events: none; max-width: 16rem; padding: .35rem .65rem; border-radius: 8px;
  background: var(--ink); color: #fff; font: 500 .84rem/1.3 var(--font-display); box-shadow: 0 6px 16px -6px rgba(31, 59, 42, .5);
}
.cp-tip[hidden] { display: none; }

/* ---------------- Details panel ---------------- */
.cp-details {
  position: fixed; inset: 0 0 0 auto; margin: 0; width: min(var(--cp-panel-w, 460px), 100vw); max-width: 100vw; height: 100dvh; max-height: 100dvh;
  padding: 0; border: 0; border-left: 1.5px solid var(--ink); background: var(--paper); color: var(--text); box-shadow: -20px 0 40px -24px rgba(31, 59, 42, .4);
  --cp-blue: #0B74AC; --cp-red: #B3261E; --cp-red-deep: #7A1712; --cp-red-soft: #F8D3CD; --cp-red-pale: #FDF1EE;
}
.cp-details::backdrop { background: rgba(22, 48, 31, .28); }
.cp-details[open] { animation: cp-slide .3s var(--ease); }
@keyframes cp-slide { from { transform: translateX(40px); opacity: 0; } }
/* Docked beside the chart: under the site header, no backdrop, the chart stays usable. */
.cp-details.cp-details--docked { top: var(--header-h); height: calc(100dvh - var(--header-h)); max-height: none; z-index: 40; }
.cp-details-close {
  position: absolute; top: .9rem; right: .9rem; z-index: 2; width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
  border: 1.5px solid var(--line-soft); background: var(--card); color: var(--ink); display: grid; place-items: center;
}
.cp-details-close svg { width: 18px; height: 18px; }
.cp-details-body { height: 100%; overflow-y: auto; padding: 1.1rem 1.1rem 2.5rem; display: flex; flex-direction: column; gap: .8rem; }
.cp-details-body > * { flex: none; }
.cp-dhead { display: flex; align-items: center; gap: .8rem; padding-right: 3rem; }
.cp-dhead h2 { font-size: 1.75rem; line-height: 1.1; margin: 0; }
.cp-dhead img, .cp-dhead .cp-noicon { flex: none; }

/* Label/value tables: tinted labels, white values. */
.cp-ftable { margin: 0; border: 1.5px solid var(--line-soft); border-radius: var(--r); overflow: hidden; background: #fff; }
.cp-dcard .cp-ftable { border: 0; border-radius: 0; }
.cp-fact { display: grid; grid-template-columns: 8.5rem 1fr; font-size: .92rem; }
.cp-fact + .cp-fact { border-top: 1px solid var(--line-soft); }
.cp-fact dt { display: flex; align-items: center; padding: .45rem .7rem; background: var(--sky-soft); font: 600 .84rem/1.25 var(--font-display); color: var(--ink); }
.cp-fact dd { margin: 0; padding: .45rem .75rem; line-height: 1.4; }

/* Good and bad companions, side by side. */
.cp-pair { display: grid; grid-template-columns: 1fr 1fr; border: 1.5px solid var(--line-soft); border-radius: var(--r); overflow: hidden; }
.cp-col { min-width: 0; }
.cp-col-good { background: var(--leaf-pale); border-right: 1.5px solid var(--line-soft); }
.cp-col-bad { background: var(--cp-red-pale); }
.cp-col h3 { display: flex; align-items: center; justify-content: center; gap: .4rem; margin: 0; padding: .55rem .5rem; font-size: 1.02rem; text-align: center; }
.cp-col-good h3 { background: var(--leaf-soft); color: var(--green); }
.cp-col-bad h3 { background: var(--cp-red-soft); color: var(--cp-red-deep); }
.cp-comp { list-style: none; padding: 0; margin: 0; }
.cp-comp > li + li { border-top: 1px solid rgba(31, 59, 42, .08); }
.cp-none { margin: 0; padding: .7rem; font-size: .88rem; color: var(--muted); text-align: center; }
.cp-why summary {
  display: flex; align-items: center; gap: .5rem; cursor: pointer; list-style: none; padding: .35rem .5rem .35rem .45rem;
  font: 500 .92rem/1.2 var(--font-display); color: var(--ink);
}
.cp-why summary::-webkit-details-marker { display: none; }
.cp-why summary img, .cp-why summary .cp-noicon { flex: none; }
.cp-why summary span { flex: 1; min-width: 0; }
.cp-why summary::after {
  content: ""; flex: none; width: 14px; height: 14px; opacity: .55; transition: transform .2s var(--ease);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6' fill='none' stroke='%231F3B2A' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
.cp-why[open] summary::after { transform: rotate(180deg); }
.cp-why summary:hover { background: rgba(255, 255, 255, .6); }
.cp-why ul { list-style: none; margin: 0; padding: 0 .6rem .2rem 2.2rem; font-size: .84rem; line-height: 1.35; }
.cp-why li { position: relative; padding: .12rem 0 .12rem 1.1rem; }
.cp-why li::before { content: ""; position: absolute; left: 0; top: .32rem; width: 12px; height: 12px; background: center / contain no-repeat; }
.cp-col-good .cp-why li::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.2 4.2L19 7' fill='none' stroke='%23255F18' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.cp-col-bad .cp-why li::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6.5 6.5l11 11M17.5 6.5l-11 11' fill='none' stroke='%23B3261E' stroke-width='3.5' stroke-linecap='round'/%3E%3C/svg%3E"); }
.cp-why .cp-link { display: inline-block; margin: .15rem 0 .55rem 2.2rem; font-size: .82rem; }

/* Colored section cards: a header band, then content on white. */
.cp-dcard { border: 1.5px solid var(--line-soft); border-radius: var(--r); overflow: hidden; background: #fff; }
.cp-dcard h3 { display: flex; align-items: center; justify-content: center; gap: .45rem; margin: 0; padding: .55rem .75rem; font-size: 1.08rem; }
.cp-dcard-info h3 { background: var(--cp-blue); color: #fff; }
.cp-dcard-pest h3 { background: var(--sun-soft); color: var(--ink); }
.cp-dcard-help h3 { background: var(--leaf-soft); color: var(--green); }
.cp-dcard-star { background: #FFFAE6; }
.cp-dcard-star h3 { background: var(--sun); color: var(--ink); }
.cp-dcard-star .cp-mark { color: var(--ink); }
.cp-dnote { margin: 0; padding: .75rem .9rem; font-size: .92rem; }
.cp-art { display: flex; align-items: center; gap: .7rem; margin: 0; padding: .55rem .8rem; font-size: .9rem; line-height: 1.4; }
.cp-art + .cp-art { border-top: 1px solid var(--line-soft); }
.cp-art img { flex: none; }
.cp-art strong { font-family: var(--font-display); font-weight: 600; }
.cp-warn {
  display: inline-block; width: 20px; height: 20px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 3.2 22 20.5H2z' fill='%23FFC700' stroke='%231F3B2A' stroke-width='1.8' stroke-linejoin='round'/%3E%3Cpath d='M12 9.5v5' stroke='%231F3B2A' stroke-width='2.2' stroke-linecap='round'/%3E%3Ccircle cx='12' cy='17.6' r='1.25' fill='%231F3B2A'/%3E%3C/svg%3E") center / contain no-repeat;
}
@media (max-width: 900px) {
  .cp-details { inset: auto 0 0 0; width: 100vw; height: 86dvh; border-left: 0; border-top: 1.5px solid var(--ink); border-radius: 22px 22px 0 0; }
  .cp-details[open] { animation-name: cp-rise; }
  @keyframes cp-rise { from { transform: translateY(40px); opacity: 0; } }
}
@media (max-width: 420px) {
  .cp-details-body { padding-inline: .75rem; }
  .cp-fact { grid-template-columns: 7rem 1fr; }
  .cp-why summary { gap: .35rem; font-size: .86rem; padding-inline: .35rem; }
  .cp-why summary img, .cp-why summary .cp-noicon { width: 24px; height: 24px; }
  .cp-why ul { padding-left: .9rem; }
  .cp-why .cp-link { margin-left: .9rem; }
}
