/*
 * Editor layout rows and blocks. Colors come from tokens only, so everything
 * here reads on both the dark surface and a sand surface.
 */

/* ---------- Rows and columns (12-column grid) ---------- */

.layout-row {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--grid-gap);
}

.layout-row + .layout-row {
  margin-top: var(--section-gap);
}

.layout-col {
  grid-column: span var(--span, 12);
  min-width: 0;
}

.layout-col > * + * {
  margin-top: var(--space-16);
}

/* Column themes (row settings, per column position): none has no attribute and
   no styling; light adds data-surface="sand" next to data-theme, so the sand
   tokens (text, links, border, buttons, focus) switch with it. The card look is
   the same as .card: card surface, text and border roles. */
.layout-col[data-theme] {
  padding: var(--space-24);
  background: var(--surface-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
}

/* Stacked on phones the cards keep their padding and sit one gap apart. */
@media (max-width: 640px) {
  .layout-col[data-theme] {
    padding: var(--space-20);
  }
}

/* Tablet: "Tablet behavior" row setting, from phone width up to 1024px. */
@media (max-width: 1024px) {
  .layout-row[data-tablet="two"] > .layout-col {
    grid-column: span 6;
  }

  .layout-row[data-tablet="two"] > .layout-col:last-child:nth-child(odd) {
    grid-column: span 12;
  }

  .layout-row[data-tablet="stacked"] > .layout-col {
    grid-column: span 12;
  }
}

/* Phones always stack. */
@media (max-width: 640px) {
  .layout-row > .layout-col,
  .layout-row[data-tablet] > .layout-col {
    grid-column: span 12;
  }
}

/* ---------- Built-in blocks ---------- */

.layout-col h1 {
  font-size: var(--text-heading-page);
}

.layout-col h2 {
  font-size: var(--text-heading-section);
}

.layout-col h3 {
  font-size: var(--text-heading-title);
}

.layout-col h4,
.layout-col h5,
.layout-col h6 {
  font-size: var(--text-label);
  font-family: var(--font-body);
  font-weight: 700;
  letter-spacing: 0;
}

.layout-col p,
.layout-col li {
  max-width: 70ch;
}

.layout-col p + p {
  margin-top: var(--space-12);
}

.layout-col ul,
.layout-col ol {
  padding-left: 1.25em;
}

.layout-col li + li {
  margin-top: var(--space-6);
}

/* Alignment (text and heading blocks; left is the default and has no attribute).
   Paragraphs and list items are capped at 70ch, so the box moves too, not only
   the text. List markers sit inside so they stay with the text. */
.layout-col [data-align="center"] {
  text-align: center;
}

.layout-col [data-align="right"] {
  text-align: right;
}

.layout-col [data-align="center"] :is(p, li) {
  margin-inline: auto;
}

.layout-col [data-align="right"] :is(p, li) {
  margin-inline-start: auto;
}

.layout-col [data-align="center"] :is(ul, ol),
.layout-col [data-align="right"] :is(ul, ol) {
  padding-left: 0;
  list-style-position: inside;
}

.layout-col a:not(.button) {
  text-decoration: underline;
}

.layout-col blockquote {
  margin: 0;
  padding-left: var(--space-20);
  border-left: 2px solid var(--border-strong);
  font-size: var(--text-lead);
}

.layout-col blockquote footer {
  margin-top: var(--space-8);
  color: var(--text-muted);
  font-size: var(--text-small);
}

.layout-col hr {
  width: 100%;
  margin: 0;
  border: 0;
  border-top: 1px solid var(--border);
}

.layout-col figure {
  margin: 0;
}

.layout-col figure img {
  width: 100%;
  border-radius: var(--radius-card);
}

.layout-col figcaption {
  margin-top: var(--space-8);
  color: var(--text-caption);
  font-size: var(--text-small);
}

/* Gallery: Kirby wraps images in a list inside a figure. */
.layout-col figure.gallery ul,
.layout-col .gallery ul {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr));
  gap: var(--space-12);
  padding: 0;
  list-style: none;
}

.layout-col .gallery li {
  max-width: none;
  margin: 0;
}

/* Video: keep embeds responsive. */
.layout-col figure.video,
.layout-col .video {
  position: relative;
}

.layout-col .video iframe,
.layout-col .video video {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: var(--radius-card);
}

/* ---------- Callout ---------- */

.callout {
  --callout-accent: var(--status-info);
  display: flex;
  gap: var(--space-14);
  padding: var(--space-18);
  background: var(--surface-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-left: 4px solid var(--callout-accent);
  border-radius: var(--radius-card);
}

.callout--success {
  --callout-accent: var(--status-success);
}

.callout--warning {
  --callout-accent: var(--status-warning);
}

.callout--error {
  --callout-accent: var(--status-error);
}

/* The accent is the icon color so meaning never rests on color alone: the
   icon shape and the title still say what it is. */
.callout__icon {
  color: var(--callout-accent);
  padding-top: 0.1em;
}

[data-surface="sand"] .callout--info {
  --callout-accent: var(--status-info-on-sand);
}

[data-surface="sand"] .callout--success {
  --callout-accent: var(--status-success-on-sand);
}

[data-surface="sand"] .callout--warning {
  --callout-accent: var(--status-warning-on-sand);
}

[data-surface="sand"] .callout--error {
  --callout-accent: var(--status-error-on-sand);
}

.callout__title {
  font-weight: 700;
}

.callout__text > * + * {
  margin-top: var(--space-8);
}

.callout__text {
  color: var(--text-muted);
}

.callout__text a {
  text-decoration: underline;
}
