@charset "UTF-8";

/* --- Variables & Reset --- */
:root {
    --color-primary: #6f4e37;
    /* Coffee */
    --color-primary-dark: #5d4037;
    --color-bg: #f9f9f9;
    --color-surface: #ffffff;
    --color-text: #3e2723;
    --font-serif: "Noto Serif JP", "Yu Mincho", "Hiragino Mincho ProN", serif;
    --font-sans: "Roboto", "Helvetica Neue", Arial, sans-serif;
    --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.08);
    --shadow-hard: 0 4px 10px rgba(0, 0, 0, 0.15);
    --radius-md: 12px;
    --radius-sm: 8px;
}

.tateyomi-wrapper {
    font-family: var(--font-sans);
    background-color: var(--color-bg);
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--color-text);
}

/* --- Control Panel (Card Style) --- */
.tateyomi-wrapper .controls {
    background: var(--color-surface);
    padding: 30px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-soft);
    width: 100%;
    max-width: 800px;
    margin-bottom: 40px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-sizing: border-box;
}

.tateyomi-wrapper h1 {
    font-family: var(--font-serif);
    font-weight: 700;
    color: var(--color-primary);
    text-align: center;
    margin: 0 0 20px 0;
    font-size: 2rem;
    border-bottom: 2px solid #eaeaea;
    padding-bottom: 15px;
}

.tateyomi-wrapper textarea {
    width: 100%;
    height: 180px;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: var(--radius-sm);
    font-family: var(--font-serif);
    font-size: 1rem;
    line-height: 1.6;
    resize: vertical;
    transition: box-shadow 0.3s ease, border-color 0.3s ease;
    box-sizing: border-box;
}

.tateyomi-wrapper textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(111, 78, 55, 0.1);
}

/* Settings Groups */
.tateyomi-wrapper .settings-group {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
    justify-content: space-between;
    padding: 15px;
    background: #fdfdfd;
    border: 1px solid #eee;
    border-radius: var(--radius-sm);
}

.tateyomi-wrapper label {
    font-weight: 500;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

/* Inputs & Buttons */
.tateyomi-wrapper select,
.tateyomi-wrapper input[type="text"],
.tateyomi-wrapper input[type="color"] {
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.9rem;
    font-family: inherit;
}

.tateyomi-wrapper button#downloadBtn {
    background-color: var(--color-primary);
    color: white;
    padding: 10px 24px;
    border: none;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(111, 78, 55, 0.3);
    transition: transform 0.1s ease, background-color 0.2s ease, box-shadow 0.2s ease;
    margin-left: auto;
    /* Push to right in flex container */
}

.tateyomi-wrapper button#downloadBtn:hover {
    background-color: var(--color-primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(111, 78, 55, 0.4);
}

.tateyomi-wrapper button#downloadBtn:active {
    transform: translateY(0);
}

/* Custom File Upload */
.tateyomi-wrapper .custom-file-upload {
    display: inline-block;
    padding: 6px 12px;
    cursor: pointer;
    background: #e0e0e0;
    border-radius: 4px;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.tateyomi-wrapper .custom-file-upload:hover {
    background: #d0d0d0;
}

/* --- Preview Area --- */
#pagesContainer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40px;
    width: 100%;
}

.manuscript-paper {
    width: 600px;
    height: 800px;
    /* Standard A-ish ratio */
    background-color: #fff;
    background-size: cover;
    background-position: center;
    position: relative;
    overflow: hidden;
    /* Center the content area */
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
    /* Shadows for realistic paper feel */
    box-shadow:
        0 1px 1px rgba(0, 0, 0, 0.1),
        0 10px 30px rgba(0, 0, 0, 0.15),
        0 0 0 1px rgba(0, 0, 0, 0.05);
    /* Border hint */
    /* Padding to keep text away from the frame - ADJUSTED FOR NON-FRAME IMAGES */
    /* Default padding, might need JS adjustment or generic enough */
    padding: 130px 60px;
    transition: transform 0.3s ease;
}

/* Watermark for Sample Version */
.manuscript-paper::after {
    content: "";
    /* Empty content for image */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60%;
    /* Adjust size as needed */
    height: 60%;
    background-image: url('../images/watermark_hirona.png');
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    opacity: 0.15;
    /* Keep transparency */
    pointer-events: none;
    z-index: 100;
}

/* Hover effect on paper to make it interactive */
.manuscript-paper:hover {
    transform: scale(1.02);
    z-index: 5;
}

.page-number {
    position: absolute;
    bottom: 40px;
    right: 40px;
    left: auto;
    font-family: var(--font-serif);
    font-size: 14px;
    color: var(--color-text);
    z-index: 10;
}

.page-number.odd {
    left: 40px;
    right: auto;
}

.manuscript-content {
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    writing-mode: vertical-rl;

    font-family: var(--font-serif);
    font-size: 18px;
    /* Slightly larger for readability */
    line-height: 2.0;
    letter-spacing: 0.15em;
    color: var(--color-text);

    /* Subtle vertical lines for rows */
    background-image: linear-gradient(to left, rgba(111, 78, 55, 0.15) 1px, transparent 1px);
    background-size: 36px 100%;
    /* 18px * 2.0 = 36px */
    background-position: right top;

    overflow: hidden;
    white-space: pre-wrap;

    /* Text rendering optimization */
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

/* Marker */
.end-marker-container {
    display: flex;
    flex-direction: row;
    justify-content: flex-end;
    /* Bottom */
    height: 100%;
    width: 1em;
    margin-right: 2em;
    /* Gap from text */
    vertical-align: top;
}

.end-marker {
    display: block;
    writing-mode: vertical-rl;
    margin-bottom: 0.5rem;
    font-size: 0.9em;
}


/* Text Effects */
.text-outline {
    text-shadow:
        2px 0px 0px #fff, -2px 0px 0px #fff,
        0px 2px 0px #fff, 0px -2px 0px #fff,
        1.5px 1.5px 0px #fff, -1.5px 1.5px 0px #fff,
        1.5px -1.5px 0px #fff, -1.5px -1.5px 0px #fff;
}

.text-shadow {
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.6);
}

/* Ruby */
ruby {
    ruby-align: center;
}

rt {
    font-size: 0.5em;
    color: inherit;
}

/* Responsive */
@media (max-width: 650px) {
    .manuscript-paper {
        transform: scale(0.6);
        margin: -160px 0;
        /* Compensation for scale gap */
    }

    .tateyomi-wrapper textarea {
        height: 120px;
    }
}