:root{
  --bleed:57px;
  --card-w:1125px;   /* swap with --card-h if you want horizontal */
  --card-h:750px;
}

*{
  box-sizing:border-box;
}

body{
  margin:0;
  font-family:system-ui,Arial,sans-serif;
  background:#f0f0f0;
  color:#111;
}

/* ───── Toolbar ───── */

.toolbar{
  position:sticky;
  top:0;
  z-index:10;
  display:flex;
  align-items:center;
  gap:12px;
  padding:10px 12px;
  background:#fff;
  border-bottom:1px solid #ddd;
}

.toolbar button{
  padding:8px 14px;
  border:0;
  border-radius:8px;
  cursor:pointer;
  background:#2f7d32;
  color:#fff;
  font-weight:600;
}

.apikey,
.writekey{
  margin-left:auto;
  display:flex;
  align-items:center;
  gap:8px;
}

.writekey{
  margin-left:0;
}

.toolbar label{
  font-size:0.9rem;
  white-space:nowrap;
}

.toolbar input{
  padding:6px 8px;
  width:240px;
  border:1px solid #ccc;
  border-radius:6px;
}

/* ───── Deck layout ───── */

.deck{
  display:flex;
  flex-wrap:wrap;
  justify-content:center;
  gap:20px;
  padding:16px;
}

/* ───── Card base with full-bleed background image ───── */

.card{
  width:var(--card-w);
  height:var(--card-h);
  padding:var(--bleed);
  border:none;
  border-radius:0;
  background:#ddd;               /* fallback if no image */
  box-shadow:0 4px 8px rgba(0,0,0,.12);
  position:relative;
  overflow:hidden;
  display:flex;
  flex-direction:column;
  justify-content:flex-start;

  /* background image comes from inline style; these are safe defaults */
  background-size:cover;
  background-position:center;
  background-repeat:no-repeat;
}

/* light wash over the art so it’s already muted */
.card::before{
  content:"";
  position:absolute;
  inset:0;
  background:rgba(255,255,255,0.4);  /* first fade */
  pointer-events:none;
  z-index:0;
}

/* ensure children are above the wash */
.card > *{
  position:relative;
  z-index:1;
}

/* ───── Giant text box ───── */

.text-area{
  background:rgba(255,255,250,0.67);  /* heavy fade over the art */
  border-radius:18px;
  padding:16px 18px;
  flex:1;
  display:flex;
  flex-direction:column;
  justify-content:flex-start;
  overflow:hidden;
}

/* Title lives inside the box now */
.card-title{
  margin:0 0 12px;
  text-align:center;
  font-size:3.0em;
  line-height:1.1;
}

/* Main rules text */
.text-area .description{
  flex:1;
  font-size:24px;
  line-height:1.15;
  white-space:pre-wrap;
  word-wrap:break-word;
  overflow:hidden;
  position:relative; /* for badges */
}

/* Optional headings in description */
.text-area .description h1,
.text-area .description h2{
  margin:0 0 6px;
  font-size:1.2em;
}

/* Old “Class” line (not really used now, but safe to keep) */
.class{
  font-size:27px;
  margin:6px 0 4px;
}

/* ───── Controls (bottom-right) ───── */

.controls{
  position:absolute;
  bottom:calc(var(--bleed) + 6px);
  right:calc(var(--bleed) + 6px);
  display:flex;
  flex-direction:column;
  gap:6px;
  z-index:2;
}

.controls button{
  padding:6px 10px;
  border-radius:6px;
  border:0;
  font-size:0.85rem;
  cursor:pointer;
  background:#555;
  color:#fff;
}

/* Button variants */
.btn-export{
  background:#1976d2;
}

.btn-next.secondary{
  background:#555;
}

.btn-gen.success{
  background:#2e7d32;
}

.btn-set.warning{
  background:#f9a825;
}

.btn-edit.secondary{
  background:#757575;
}

/* ───── Footer ───── */

.footnote{
  text-align:center;
  padding:8px 12px 16px;
  font-size:0.8rem;
  color:#555;
}

/* ───── Badge system (corner labels inside description) ───── */

.text-area .description var,
.text-area .description samp{
  position:absolute;
  display:inline-block;
  padding:2px 8px;
  border-radius:999px;
  font-size:0.8em;
  font-style:normal;
  background:rgba(0,0,0,0.75);
  color:#fff;
  pointer-events:none;
  white-space:nowrap;
}

/* default top-left */
.text-area .description var,
.text-area .description samp{
  top:6px;
  left:6px;
}

/* top-left explicit */
.text-area .description var.tl,
.text-area .description samp.tl,
.text-area .description var[data-pos="tl"],
.text-area .description samp[data-pos="tl"]{
  top:6px;
  left:6px;
  right:auto;
  bottom:auto;
}

/* top-right */
.text-area .description var.tr,
.text-area .description samp.tr,
.text-area .description var[data-pos="tr"],
.text-area .description samp[data-pos="tr"]{
  top:6px;
  right:6px;
  left:auto;
  bottom:auto;
}

/* bottom-left */
.text-area .description var.bl,
.text-area .description samp.bl,
.text-area .description var[data-pos="bl"],
.text-area .description samp[data-pos="bl"]{
  bottom:6px;
  left:6px;
  top:auto;
  right:auto;
}

/* bottom-right */
.text-area .description var.br,
.text-area .description samp.br,
.text-area .description var[data-pos="br"],
.text-area .description samp[data-pos="br"]{
  bottom:6px;
  right:6px;
  top:auto;
  left:auto;
}

/* extra padding when a TOP badge exists */
.text-area .description:has(
  var:not(.bl):not([data-pos="bl"]):not(.br):not([data-pos="br"]),
  samp:not(.bl):not([data-pos="bl"]):not(.br):not([data-pos="br"])
){
  padding-top:44px;
}

/* extra padding when a BOTTOM badge exists */
.text-area .description:has(
  var.bl, var[data-pos="bl"], var.br, var[data-pos="br"],
  samp.bl, samp[data-pos="bl"], samp.br, samp[data-pos="br"]
){
  padding-bottom:44px;
}
