/* História Social (scripts/features/utilities/story.js). */
body.utility-locked .utility-unlocked-only {
  display: none !important;
}

.story-icon-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 50px;
  padding: 0 16px;
}

.story-icon-button svg,
.story-nav-button svg,
.story-exit svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.story-empty-image {
  display: grid;
  justify-items: center;
  gap: 4px;
  color: #64748b;
  font-weight: 800;
}

.story-empty-image b {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #e6f4fe;
  color: var(--app-blue, #1ca7f2);
  font-size: 2.2rem;
  line-height: 1;
}

/* Lista */
.story-list-page {
  display: grid;
  gap: 18px;
}

.story-list-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.story-list-header h3 {
  margin: 0;
  color: #172033;
  font-size: clamp(1.4rem, 3vw, 2rem);
  font-weight: 900;
}

.story-list-header .primary-button {
  min-height: 54px;
  padding: 0 22px;
}

.story-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.story-tile {
  display: grid;
  gap: 6px;
  padding: 10px 10px 14px;
  border: 2px solid #dce9f2;
  border-radius: 22px;
  background: #ffffff;
  box-shadow: 0 6px 0 #e3eef6;
  color: #172033;
  font: inherit;
  text-align: center;
  cursor: pointer;
}

.story-tile-cover {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  border-radius: 14px;
  background: #f7fbff;
  overflow: hidden;
}

.story-tile-cover img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.story-tile strong {
  font-size: 1.05rem;
  font-weight: 900;
}

.story-tile small {
  color: #64748b;
  font-weight: 700;
}

.story-list-empty {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 48px 20px;
  border: 2px dashed #cfe2ef;
  border-radius: 24px;
  background: #ffffff;
  color: #64748b;
  text-align: center;
}

.story-list-empty strong {
  color: #172033;
  font-size: 1.25rem;
}

.story-list-empty p {
  margin: 0;
  font-weight: 700;
}

/* Editor */
.story-editor {
  display: grid;
  gap: 14px;
}

.story-editor-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.story-editor-spacer {
  flex: 1;
}

.story-pages {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 2px 8px;
}

.story-page-thumb,
.story-page-add {
  flex: none;
  width: 92px;
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 6px;
  border: 2px solid #dce9f2;
  border-radius: 14px;
  background: #ffffff;
  color: #475569;
  font: inherit;
  cursor: pointer;
}

.story-page-thumb.is-selected {
  border-color: var(--app-blue, #1ca7f2);
  box-shadow: 0 0 0 3px rgba(28, 167, 242, 0.25);
}

.story-thumb-image {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 8px;
  background: #f7fbff;
  overflow: hidden;
}

.story-thumb-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.story-thumb-image .story-empty-image {
  display: none;
}

.story-page-thumb small,
.story-page-add small {
  font-weight: 900;
}

.story-page-add {
  align-content: center;
  border-style: dashed;
  background: #f7fbff;
}

.story-page-add b {
  color: var(--app-blue, #1ca7f2);
  font-size: 1.8rem;
  line-height: 1;
}

.story-page-editor {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  align-items: start;
  gap: clamp(14px, 2.4vw, 26px);
}

.story-image-button {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 4 / 3;
  padding: 12px;
  border: 3px dashed #cfe2ef;
  border-radius: 22px;
  background: #f7fbff;
  font: inherit;
  cursor: pointer;
}

.story-image-button img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.story-image-button:has(img) {
  border-style: solid;
  border-color: #dce9f2;
  background: #ffffff;
}

.story-fields {
  display: grid;
  gap: 14px;
}

.story-fields label {
  display: grid;
  gap: 6px;
  color: #475569;
  font-size: 0.85rem;
  font-weight: 800;
}

.story-fields input,
.story-fields textarea {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid #dce9f2;
  border-radius: 14px;
  background: #ffffff;
  color: #172033;
  font: inherit;
  font-size: 1.1rem;
  box-sizing: border-box;
}

.story-fields input {
  min-height: 52px;
  font-weight: 800;
}

.story-fields textarea {
  resize: vertical;
  line-height: 1.45;
}

.story-page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.story-page-actions button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 46px;
  padding: 0 14px;
}

.story-page-actions svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (orientation: portrait) {
  .story-page-editor {
    grid-template-columns: 1fr;
  }
}

/* Apresentação: uma página por vez, grande. */
.story-presentation {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 16px;
  min-height: calc(100dvh - 120px);
}

body:is(.utility-focus, .utility-locked) .story-presentation {
  min-height: calc(100dvh - 24px);
  padding-bottom: 18px;
  box-sizing: border-box;
}

.story-exit {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border: 0;
  border-radius: 50%;
  background: #e8f1f8;
  color: #334155;
  cursor: pointer;
}

.story-slide {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  align-items: center;
  gap: clamp(18px, 4vw, 48px);
  padding: 0 clamp(8px, 3vw, 40px);
}

.story-slide-image {
  display: grid;
  place-items: center;
  height: min(62dvh, 560px);
  padding: 14px;
  border-radius: 28px;
  background: #ffffff;
  box-shadow: 0 8px 0 #e3eef6, 0 18px 36px rgba(32, 71, 98, 0.1);
}

.story-slide-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.story-slide-copy h3 {
  margin: 0 0 14px;
  color: #172033;
  font-size: clamp(1.8rem, 4vw, 3rem);
  font-weight: 900;
  line-height: 1.15;
}

.story-slide-copy p {
  margin: 0;
  color: #1f2f44;
  font-size: clamp(1.3rem, 2.8vw, 2rem);
  line-height: 1.45;
  white-space: pre-line;
}

.story-presentation.is-cover .story-slide {
  grid-template-columns: 1fr;
  justify-items: center;
  text-align: center;
}

.story-presentation.is-cover .story-slide-image {
  width: min(100%, 720px);
  height: min(56dvh, 520px);
}

.story-slide-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.story-nav-button {
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  border: 0;
  border-radius: 50%;
  background: var(--app-blue, #1ca7f2);
  box-shadow: 0 5px 0 var(--app-blue-dark, #0f78b5);
  color: #ffffff;
  cursor: pointer;
}

.story-nav-button svg {
  width: 30px;
  height: 30px;
}

.story-nav-button.is-speak {
  background: #ffb020;
  box-shadow: 0 5px 0 #d98a14;
}

.story-nav-button:disabled {
  opacity: 0.3;
  cursor: default;
}

.story-slide-count {
  min-width: 70px;
  color: #475569;
  font-size: 1.2rem;
  font-weight: 900;
  text-align: center;
}

@media (orientation: portrait) {
  .story-slide {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .story-slide-image {
    height: min(44dvh, 520px);
  }
}

/* A figura fica sempre inteira dentro do cartão, seja foto alta, larga ou quadrada (antes, numa foto
   alta a imagem passava da borda do cartão). A figura ocupa a área interna e se ajusta sem cortar. */
:is(.story-tile-cover, .story-thumb-image, .story-image-button, .story-slide-image):has(> img) {
  position: relative;
  overflow: hidden;
}

:is(.story-tile-cover, .story-thumb-image) > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.story-image-button > img {
  position: absolute;
  inset: 12px;
  width: calc(100% - 24px);
  height: calc(100% - 24px);
}

.story-slide-image > img {
  position: absolute;
  inset: 14px;
  width: calc(100% - 28px);
  height: calc(100% - 28px);
}
