/**
 * Typography Styles
 *
 * Medieval-inspired typography using Metamorphous font throughout.
 */

/* Base Typography */
body {
    font-family: 'Metamorphous', Georgia, 'Times New Roman', serif;
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--ink-black);
    text-align: justify;
    text-justify: inter-word;
    -webkit-hyphens: none;
    -ms-hyphens: none;
    hyphens: none;
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Metamorphous', serif;
    font-weight: normal;
    line-height: 1.3;
    margin: 0 0 1rem 0;
    color: var(--ink-brown);
    text-align: center;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
}

h2 {
    font-size: 1.75rem;
}

h3 {
    font-size: 1.375rem;
}

/* Book Title */
.book-title {
    font-family: 'Metamorphous', serif;
    font-size: 3rem;
    font-weight: normal;
    color: var(--ink-red);
    margin-bottom: 0.5rem;
    letter-spacing: 0.05em;
}

.book-subtitle {
    font-family: 'Metamorphous', serif;
    font-size: 1rem;
    font-style: italic;
    color: var(--ink-faded);
    margin: 0;
}

/* Section Title */
.section-title {
    font-size: 1.5rem;
    color: var(--ink-red);
    text-align: center;
    margin-bottom: 0.75rem;
}

.section-intro {
    text-align: center;
    color: var(--ink-faded);
    font-style: italic;
    margin-bottom: 2rem;
}

/* Paragraphs */
p {
    margin: 0 0 1rem 0;
}

p:last-child {
    margin-bottom: 0;
}

/* Links */
a {
    color: var(--ink-red);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s ease;
}

a:hover {
    border-bottom-color: var(--ink-red);
}

/* Drop Cap Image for DM Messages */
.drop-cap-image {
    float: left;
    width: 5.5rem;
    height: 5.5rem;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    margin-right: 0.6rem;
    margin-top: 0.15rem;
    margin-bottom: 0.3rem;
    /* iOS Safari PWA fix: ensure drop cap stays above text */
    position: relative;
    z-index: 10;
}

/* iOS Safari PWA: ensure text wraps around float */
.dm-message .message-text {
    overflow: hidden;
}

/* Message Text */
.message-text {
    margin: 0;
    /* Subtle text shadow for fresh ink look */
    text-shadow: 0 0 0.5px rgba(62, 39, 35, 0.25);
}

/* Paragraph breaks within messages */
.message-text p.message-paragraph {
    margin-top: 1rem;
    text-indent: 1.5rem;
}

/* Player Message Styling */
.player-message .message-text {
    color: var(--ink-faded);
    font-style: italic;
}

/* Oracle icon in player messages */
.oracle-prompt-icon {
    height: 1.1em;
    width: auto;
    vertical-align: middle;
    margin-right: 0.3rem;
    opacity: 0.7;
    transform: translateY(-1px);
}

/* Roll submission styling */
.player-roll .message-text {
    font-style: normal;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.player-roll::before {
    content: 'Roll';
}

.roll-icon {
    height: 1.4em;
    width: auto;
    vertical-align: middle;
    opacity: 0.8;
}

.roll-value {
    font-family: 'Pirata One', cursive;
    font-size: 1.5rem;
    color: var(--ink-brown);
    line-height: 1;
}

/* Skill check styling */
.player-skill-check .message-text {
    font-style: italic;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.player-skill-check::before {
    content: 'Skill Check';
}

.skill-icon {
    height: 1.6em;
    width: auto;
    vertical-align: middle;
    opacity: 0.85;
}

.skill-context {
    color: var(--ink-faded);
}

/* Combat message styling */
.player-combat .message-text {
    font-style: normal;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.player-combat::before {
    content: 'Combat';
}

.combat-msg-icon {
    height: 1.6em;
    width: auto;
    vertical-align: middle;
    opacity: 0.85;
}

/* Dungeon action message styling (centered, thematic) */
.dungeon-action-message {
    text-align: center;
    border-left: none;
    padding-left: 0;
    margin: 2.5rem 0;
    transition: opacity 0.5s ease;
}

.dungeon-action-message::before {
    display: none;
}

.dungeon-action-text {
    font-family: 'Metamorphous', serif;
    font-size: 0.88rem;
    color: var(--ink-faded);
    font-style: italic;
    margin: 0;
    transition: color 0.5s ease;
}

.dungeon-action-text strong {
    font-family: 'Pirata One', cursive;
    font-size: 1.21rem;
    color: var(--ink-brown);
    font-style: normal;
    font-weight: normal;
    margin-left: 0.3rem;
    transition: color 0.5s ease;
}

/* Dungeon entry has slightly more emphasis */
.dungeon-entry-message .dungeon-action-text {
    font-size: 1.1rem;
}

.dungeon-entry-message .dungeon-action-text strong {
    font-size: 1.32rem;
}

/* Dungeon exit matches entry styling */
.dungeon-exit-message .dungeon-action-text {
    font-size: 1.1rem;
}

.dungeon-exit-message .dungeon-action-text strong {
    font-size: 1.32rem;
}

/* Inventory change indicator (e.g., "-1 Torch") */
.inventory-change {
    display: inline-block;
    font-family: 'Crimson Text', serif;
    font-size: 0.75rem;
    font-style: normal;
    color: var(--ink-faded);
    margin-left: 0.6rem;
    padding: 0.1rem 0.4rem;
    border-left: 1px solid var(--ink-faded);
    opacity: 0.7;
}

/* Roll message (centered with dice) */
.roll-message {
    margin: 1.5rem 0;
}

.roll-result {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.roll-message-icon {
    width: 28px;
    height: 28px;
    opacity: 0.8;
}

.roll-message-value {
    font-family: 'Pirata One', cursive;
    font-size: 2rem;
    color: var(--ink-brown);
    font-style: normal;
}

.roll-message-type {
    font-family: 'Crimson Text', serif;
    font-size: 0.9rem;
    color: var(--ink-faded);
    font-style: italic;
    margin-left: 0.25rem;
}

/* Blocked navigation - strikethrough with brush */
.dungeon-action-message.blocked {
    opacity: 0.5;
}

.dungeon-action-message.blocked .dungeon-action-text {
    position: relative;
    display: inline-block;
    color: var(--ink-faded);
}

.dungeon-action-message.blocked .dungeon-action-text strong {
    color: var(--ink-faded);
}

.dungeon-action-message.blocked .dungeon-action-text::after {
    content: '';
    position: absolute;
    top: calc(50% + 4px);
    left: -8px;
    right: -8px;
    height: 9px;
    background: url('/static/images/divider-red.png') center center / 100% 100% no-repeat;
    transform-origin: left center;
    transform: translateY(-50%) scaleX(0);
    animation: strikethrough-draw 0.4s ease-out 0.1s both;
}

@keyframes strikethrough-draw {
    0% {
        transform: translateY(-50%) scaleX(0);
        opacity: 0;
    }
    100% {
        transform: translateY(-50%) scaleX(1);
        opacity: 1;
    }
}

/* Trader Wares Display */
.trader-wares-container {
    margin: 1rem auto 2rem;
    max-width: 400px;
    background: linear-gradient(
        135deg,
        rgba(139, 109, 79, 0.08) 0%,
        rgba(107, 77, 48, 0.12) 100%
    );
    border: 1px solid var(--border-ornate);
    border-radius: 4px;
    padding: 1rem 1.5rem;
    box-shadow:
        inset 0 1px 3px rgba(255, 255, 255, 0.1),
        0 2px 4px rgba(0, 0, 0, 0.1);
}

.trader-wares-header {
    font-family: 'Metamorphous', serif;
    font-size: 0.9rem;
    color: var(--ink-brown);
    text-align: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-ornate);
}

.trader-wares-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Crimson Text', serif;
    font-size: 0.9rem;
}

.trader-wares-table tr {
    border-bottom: 1px dotted rgba(139, 109, 79, 0.3);
}

.trader-wares-table tr:last-child {
    border-bottom: none;
}

.trader-wares-item {
    padding: 0.4rem 0;
    color: var(--ink-dark);
}

.trader-wares-price {
    padding: 0.4rem 0;
    text-align: right;
    color: var(--ink-brown);
    font-weight: 600;
    white-space: nowrap;
}

/* Combat modal header icon */
.combat-icon {
    height: 0.85em;
    width: auto;
    vertical-align: middle;
    margin-right: 0.3rem;
    opacity: 0.5;
}

.player-message::before {
    content: 'You';
    display: block;
    font-family: 'Metamorphous', serif;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--border-ornate);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.25rem;
}

/* DM Message Styling */
.dm-message::before {
    content: '';
    /* DM messages don't need a label - they're the main narrative */
}

/* Oracle Result Badge - inline with text */
.oracle-badge {
    display: inline-block;
    font-family: 'Metamorphous', serif;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    margin-right: 0.5rem;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    vertical-align: middle;
    background: rgba(139, 115, 85, 0.15);
    color: var(--ink-brown);
}

/* Yes outcomes - green tint */
.oracle-badge.oracle-yes {
    background: rgba(45, 90, 39, 0.15);
    color: #2d5a27;
}

/* No outcomes - red tint */
.oracle-badge.oracle-no {
    background: rgba(139, 0, 0, 0.12);
    color: var(--ink-red);
}

/* Emphasis */
em {
    font-style: italic;
    color: var(--ink-brown);
}

strong {
    font-weight: 600;
    color: var(--ink-red);
}

/* Return direction highlighting (the way back) */
strong.return-direction {
    color: #2e5d8c;
}

/* Surface command highlighting (dungeon exit option) */
strong.surface-command {
    color: #2e5d8c;
}

/* Clickable keywords in DM messages */
.clickable-keyword {
    cursor: pointer;
    transition: all 0.15s ease;
    border-bottom: 1px dashed currentColor;
}

.clickable-keyword:hover {
    filter: brightness(1.2);
    border-bottom-style: solid;
}

/* Clickable direction keywords */
.clickable-direction {
    color: var(--ink-red);
}

.clickable-direction:hover {
    color: #a01010;
    text-shadow: 0 0 1px rgba(139, 0, 0, 0.3);
}

/* Clickable monster names */
.clickable-monster {
    color: var(--ink-red);
    font-weight: 600;
}

.clickable-monster:hover {
    color: #a01010;
    text-shadow: 0 0 1px rgba(139, 0, 0, 0.3);
}

/* Quotes / Dialogue */
blockquote {
    margin: 1rem 0;
    padding-left: 1.5rem;
    border-left: 3px solid var(--border-ornate);
    font-style: italic;
    color: var(--ink-brown);
}

/* Discover Meaning Result */
.discover-meaning {
    background: rgba(139, 115, 85, 0.1);
    padding: 1rem 1.5rem;
    border-radius: 4px;
    margin: 1rem 0;
    text-align: center;
}

.discover-meaning-label {
    font-family: 'Metamorphous', serif;
    font-size: 0.875rem;
    color: var(--ink-faded);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.5rem;
}

.discover-meaning-words {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--ink-brown);
}

.discover-meaning-plus {
    color: var(--ink-faded);
    margin: 0 0.5rem;
}

/* Form Typography */
label {
    display: block;
    font-family: 'Metamorphous', serif;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--ink-brown);
    margin-bottom: 0.375rem;
    letter-spacing: 0.025em;
}

input[type="text"],
input[type="number"],
select,
textarea {
    font-family: 'Metamorphous', serif;
    font-size: 1rem;
    color: var(--ink-black);
}

input::placeholder,
textarea::placeholder {
    color: var(--ink-faded);
    font-style: italic;
}

/* Field Description (helper text below form fields) */
.field-description {
    font-family: 'Metamorphous', serif;
    font-size: 0.8rem;
    color: var(--ink-faded);
    font-style: italic;
    margin-top: 0.375rem;
    margin-bottom: 0;
    line-height: 1.4;
    text-align: left;
}

/* Button Typography */
.btn {
    font-family: 'Metamorphous', serif;
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* Small Text */
small {
    font-size: 0.875rem;
    color: var(--ink-faded);
}

/* Code / Command */
code {
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    background: rgba(139, 115, 85, 0.1);
    padding: 0.1em 0.4em;
    border-radius: 3px;
}

/* Selection */
::selection {
    background: rgba(139, 0, 0, 0.2);
    color: var(--ink-black);
}

/* Error Text */
.error-text {
    color: var(--ink-red);
    font-style: italic;
}

/* Success Text */
.success-text {
    color: #2d5a27;
    font-style: italic;
}

/* Character Intro */
.character-intro {
    text-align: center;
    margin: 2rem 0 3rem 0;
}

.character-intro-name {
    font-family: 'Pirata One', cursive;
    font-size: 2.75rem;
    color: var(--ink-brown);
    letter-spacing: 0.02em;
    line-height: 1.2;
}

.character-intro-subtitle {
    font-family: 'Metamorphous', serif;
    font-size: 1.1rem;
    color: var(--ink-faded);
    margin-top: 0.25rem;
    font-style: italic;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 1000;
    display: flex;
    flex-direction: column-reverse;
    align-items: flex-end;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    background: var(--parchment-light, #f5f0e6);
    border: 1px solid var(--ink-faded, #8b7355);
    border-radius: 4px;
    padding: 0.75rem 1.25rem;
    font-family: 'Crimson Text', serif;
    font-size: 1rem;
    color: var(--ink-brown, #3d2914);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transform: translateX(1rem);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: auto;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast.hide {
    opacity: 0;
    transform: translateX(1rem);
}

.toast.error {
    border-color: var(--ink-red, #8b0000);
    color: var(--ink-red, #8b0000);
    font-style: italic;
}
